(Repeats story published on Saturday; no changes to text)
By Stephen Eisenhammer and Anthony Boadle
BELO HORIZONTE/BRASILIA, Nov 27 (Reuters) - With leaking windows, moldy walls and piles of paper where you might expect computers, the office of Brazil's National Department of Mineral Production speaks volumes about the regulation of the country's mining industry.
The office, in the capital city of the mine-rich state of Minas Gerais, is the state headquarters for a team of inspectors that is supposed to vet mines like one 100 km (60 miles) to the southeast, where a dam burst on Nov. 5, spilling mineral waste across 800 km and into the Atlantic Ocean.
Understaffed and underfunded because of long-delayed changes to Brazil's mining laws, the agency is now under fire for failing to prevent the disaster, which killed at least 13 people and left 11 more missing.
Although no cause has been determined for the rupture at the Samarco mine, owned by multinational mining companies Vale SA VALE5.SA and BHP Billiton BLT.L , prosecutors argue its roots lie in negligent licensing and lax regulation.
"Does it have the resources to do the job?" asks Carlos Eduardo Pinto, the state prosecutor who is leading the probe into the disaster, before answering his own question. "You just have to look at the offices to know."
Legislators and mining experts say the haggard state of the agency has to do with a long-pending overhaul of Brazil's so-called "mining code," the regulatory framework for the industry.
The code, stalled in Congress since 2013, in theory would create a new and better-funded regulator. In practice, though, the law has foundered due to disagreements over royalties and exploration rights.
As a result, funding for the existing agency, known as the DNPM, stalled even as Brazil's mining profits soared.
After the dam burst, President Dilma Rousseff authorized emergency funding of 9 million reais ($2.4 million) for the agency to ramp up inspections in Minas Gerais through next year.
The figure dwarfs the amount the DNPM had previously been allotted.
In the first 10 months of this year, the agency spent 1.3 million reais on regulation, according to the Ministry of Mines and Energy. That, in turn, was less than half the 3.6 million reais spent in all of 2014.
Until 2010, dams used to store waste water, known as tailings, from the mining process were not independently regulated in Brazil.
That year, however, the government tasked the DNPM, which had mostly managed exploration rights and calculated royalties, with the additional responsibility of monitoring the dams.
"We weren't given any extra money to do it," said Paulo Santana, an agency ombudsman.
A study by Brazil's national water agency found that between 2013 and 2014 the DNPM had inspected just 15 percent of 663 registered dams. Only 153 of those dams have a contingency plan in the event of a rupture, the report said.
The Samarco dam had not been inspected since 2012, according to the Ministry of Mines and Energy, which oversees the DNPM.
Late last year, the agency created a team of specialized dam inspectors. According to Santana, the ombudsman, the group so far has just four inspectors for the entire country, but a ministry spokesman said officials from elsewhere in the agency also conduct inspections.
At the DNPM's national headquarters in Brasilia, Brazil's capital, staffing is also shaky. The head of the agency, Celso Luiz Garcia, quit unexpectedly last week, citing ill health.
Comparable agencies in other big mining countries appear to be much better staffed.
In the Canadian state of British Columbia, eight engineers inspect each of 68 tailings dams at least once a year. Australia's state of South Australia has eight government inspectors for 17 tailings dams.
LOBBYING AND CAMPAIGN DONATIONS
Inspections alone cannot guarantee safety.
After a dam breach in British Columbia last year, investigators said regulators had fulfilled their obligations and the accident had occurred due to a foundation failure that no number of inspections would have uncovered.
And mining companies argue that no one knows their dams better, or have more at stake in keeping them safe, than they do. Consider the billions of reais in fines and clean-up costs that Samarco is expected to pay because of the recent disaster.
Brazil's mining ministry appears to agree. It says the DNPM's role is only to complement self-regulation by companies and the licensing of projects by state and environmental bodies.
But watchdog groups say a strong regulator is necessary to provide an objective voice, focused exclusively on safety.
"If you leave companies to do it themselves, cost will ultimately be the driving factor," said David Chambers, a geophysicist who heads the U.S.-based Center for Science and Public Participation, a consultancy group on environmental issues related to mining.
Advocates say independent regulators are also crucial because of the close ties that mining companies, like many industries, sometimes forge with elected officials through lobbying, campaign donations or the sheer import of their business on the local economy.
In Minas Gerais, critics have pointed to funding by Vale for the recent campaign of Fernando Pimentel, the state's governor and a proponent of speedier licensing for mines. According to electoral records, Vale and subsidiaries donated 3.1 million reais to Pimentel's campaign, or 6 percent of the total.
Duarte Junior, the mayor of Mariana, the nearest town to the breached dam, said 80 percent of City Hall revenue comes from mining. Both Pimentel and Junior have been careful not to criticize the companies for the accident.
Meanwhile, critics contrast the industry's wealth with the shoestring budget for regulators.
So shoddy is the DNPM office in Belo Horizonte that the local fire brigade nearly closed it down in recent years.
"The building was unsafe," said congressman Leonardo Quintao, the legislator behind the long-pending mining code. "The department is on the scrap heap."
($1 = 3.7 reais)