The world might be knee-deep in cow patties and other animal waste today were it not for dung beetles.

Dung beetles roll the waste of large animals into tiny balls that they bury underground to snack on later. Burying the dung fertilizes the soil and reduces disease, but the benefits don't stop there.

A new study of 30 million-year-old fossilized mega-dung balls, as big as three inches (seven centimeters) in diameter and produced from the dung of extinct giant South American mammals, reveals that the dung was also a food source for a number of insects that would steal a bite while the dung beetles weren't looking.

"Traces [in the fossilized dung] record the behavior of animals actively stealing the food resources set aside by the dung beetles," said Victoria Sanchez, a graduate student at the Museum of Natural Sciences in Buenos Aires and a co-author on the study. "The shapes and sizes of these fossilized burrows and borings in the dung balls indicate that other beetles, flies and earthworms were the culprits. Although none of these animals are preserved in these rocks, the fossil dung balls preserve in amazing detail a whole dung-based ecosystem."

About 30 million years ago, South America was home to giant extinct herbivores that produced mega-sized dung. Paleontologists have dug up evidence of bone-covered armadillos the size of small cars, ground sloths nearly 20 feet tall (6 meters tall) and elephant-sized hoofed mammals.

Although the dung beetles themselves did not fossilize, the results of their work are preserved as fossil dung balls, some more than 40 million years old and as large as tennis balls, the researchers said.

The study is detailed in the July issue of the journal Palaeontology.