It's 2am, you've got a throbbing bicuspid, and you can't sleep, so you go into the bathroom to pop an aspirin or two.

Our Neanderthal cousins might not have had the luxury of choosing between gel-caps and dissolvable, but according to recent research, at least one poor caveman with an abscess might have sought relief from a herbal form of aspirin.

A team led by the University of Adelaide's Australian Centre for Ancient DNA (ACAD) dug into the hardened gunk of Neanderthal teeth preserved in Europe around 42,000 to 50,000 years ago to extract the genetic material trapped inside.

Dental plaque is a sticky film of proteins and polysaccharides made by our mouth's bacteria to help them stick to your teeth; it's also a material that combines with minerals in your saliva to build into a yellow-brown solid called tartar.

This substance might make your dentist curse, but for those studying the diets of our ancestors, it's a treasure-trove of preserved DNA.

"Dental plaque traps microorganisms that lived in the mouth and pathogens found in the respiratory and gastrointestinal tract, as well as bits of food stuck in the teeth – preserving the DNA for thousands of years," says Laura Weyrich from ACAD.

In this case, the DNA taken from four individuals from cave sites in Spy, Belgium, and El Sidrón in Spain revealed that not only did Neanderthals have radically different culinary cultures, they also probably used plants to treat ailments.

It appears Neanderthals from Spy Cave chowed down on a particularly meaty diet, with DNA matching woolly rhinoceros and wild sheep found embedded in their plaque, as well as evidence of wild mushrooms.

Those from Sidrón Cave, however, were more accustomed to a vegetarian main course, including pine nuts, mushrooms, bark, and moss.

One El Sidrón specimen held DNA from a poplar (Populus trichocarpa), or black cottonwood, known for containing salicylic acid – the chemical basis of acetylsalicylic acid, or aspirin.

Since this individual had a dental abscess on its jawbone and signs of an intestinal parasite, it's no great leap to imagine the plant was consumed for pain-relief more than nourishment.

There were also traces of Penicillium – a mould known for producing a chemical that forms the basis of a family of antibiotics ­– stuck to this Neanderthal's choppers, opening the way for a debate over whether the fungus was used to treat infections in prehistoric times.

"The use of antibiotics would be very surprising, as this is more than 40,000 years before we developed penicillin. Certainly our findings contrast markedly with the rather simplistic view of our ancient relatives in popular imagination," says the director of ACAD, Alan Cooper.

Not only was the DNA of food items preserved, but the zoo of bacteria in their mouths also left behind their genetic fingerprints, providing us with insights into how our oral microflora evolved over time.

The researchers pieced together the genetic sequence of a bacterium responsible for gum-disease called Methanobrevibacter oralis, not only setting a new record for the oldest reconstruction of a bacterial genome, but also showing that Neanderthals and ancient humans were sharing pathogens as recently as 180,000 years ago – long after the two groups split from their shared ancestry.

Interestingly, the general make-up of the bacteria living in the mouths of the Spanish Neanderthals resembled those of our foraging African ancestors, while those in the Belgian Neanderthals looked more like those of early farmers and hunter-gatherer communities.

Analysing Neanderthal tartar isn't itself all that novel, with research published back in 2012 using the material extracted from the hardened plaque revealing our distant cousin's vegetarian diet, medical treatments, and evidence of cooking.

Yet together with this new research, such evidence helps us build a clearer picture of Neanderthal culture, helping to dispel the sense they were unsophisticated brutes who had to suffer their toothaches and eat their woolly rhino shanks cold.

This research was published in Nature.