Warning: This story contains details about methods of execution that some readers may find distressing.
His last words were "I love you", followed by a Muslim prayer. Then Charles Brooks Jr - a convicted murderer - looked away from his girlfriend and felt death creep in.
He was lying on a white stretcher, dressed head-to-toe in typical 80s fashion, including gold pants and a shirt with all the buttons open. He had an intravenous line in one arm and doctors hovered nearby. The man could have been a hospital patient.
Instead, his final moments were spent in the death chamber at a Texas prison. It was 1982 and this was the first time the lethal injection had been used to kill a criminal in the United States.
Before this pioneering moment, the nation's favourite mode of execution was the electric chair, which is today widely regarded as torture. It was so violent, sometimes the victim's eyeballs would pop out and rest on their cheeks. It regularly set hair on fire, leading guards to stash extinguishers nearby, just in case.
The lethal injection was hailed as kinder and more technologically advanced, with no blood and no screaming. One witness to Brooks' death said that he simply yawned and heaved his stomach. Minutes later, a doctor said "I pronounce this man dead."
To this day, the method is the first choice in every US state where capital punishment is legal. But it might not be quite as peaceful as it looks. The problem is, no one actually checked. There was no research or testing of any kind.
Back in 2005, when more than a thousand deaths-by-injection had already taken place, a team of scientists decided to take a look. Led by Leonidas Koniaris, a surgeon based in Indiana, Indianapolis, they studied execution records from Texas and Virginia and discovered that 44% of inmates may have been aware as they died - and likely in agonising pain. They weren't able to writhe or scream, because the toxic cocktail contains a muscle paralytic.
Several executions have been botched
Further research revealed one of the drugs, which was supposed to stop the heart, wasn't working. "What one comes away with based on the data is this very, very disturbing conclusion that the mechanism of death was suffocation," he says. "It's a nightmare scenario. If you step back, you might say we've just moved away from visually brutal methods of killing people." Though the majority of Americans agree with the death penalty, very few think that it should hurt.
Now an ongoing shortage of execution drugs has led some states to experiment with alternatives. As a result, several executions have been botched, including one in which the man reportedly took two hours and 640 gasps before he died. It's safe to say the lethal injection is in crisis.
Is there a more humane option?
For thousands of years, execution was a spectacle to be relished by the public. From drowning people in sacks with animals, to pulling out their lungs through their backs, humankind seemed to have no shortage of imaginative ideas - and few moral qualms about enacting them.
In ancient Persia, there was "schapism", in which the victim was sandwiched between two rowing boats - one on top of the other, with the person's arms and legs sticking out - then covered in milk and honey and left to be eaten alive by vermin. Meanwhile one traveller visiting Delhi, India, in the 14th Century, reported that elephants had been trained to slice prisoners to pieces using blades attached to their tusks.
However, interest in more humane capital punishment is hundreds of years in the making. The movement started in 1789, with the introduction of the guillotine. At the time, the French Revolution was just getting started and the heads of Parisian nobles were beginning to roll. After a series of gory, drawn-out executions - sometimes several blows of the axe were necessary - it was clear the process was in need of some modernising.
Enter Joseph-Ignace Guillotin, a doctor who was determined that executions should be conducted more humanely. He suggested using guillotines instead, boasting in a speech "Now, with my machine, I cut off your head in the twinkling of an eye, and you never feel it." They were later named after him, though he didn't actually invent them.
The guillotine involved a slanted knife, suspended over the victim by a wooden frame. Some models also featured a collection basket for their head. It proved to be quicker and more reliable than beheading by hand, due to the weight of the blade.
One study from 1975 reported that signs of conscious awareness persisted for between nine and 18 seconds after the animals were beheaded. This timeframe has since been demonstrated in other animals too, so it could be a reasonable proxy for humans.
Beheading is still practiced to this day, particularly in Saudi Arabia where 146 people were executed by beheading in 2017. But by far the most widespread form of execution today is hanging.
There are two ways this is done: the 'short drop' and the 'long drop'. As the names suggest, the former involves dropping the person from a lower height and leads to death by suffocation. This is generally considered to be extremely painful.
The 'long drop' is thought to be the more humane option. In the "best-case" scenario, the rope will break the second bone on the victim's neck. The 'hangman's fracture' also severs the spinal cord, causing their blood pressure to plummet to zero in less than a second. The victim usually loses consciousness immediately, though it may take up to 20 minutes for their heart to stop beating.
The catch is that the method requires scrupulous calculation. If the drop is too long, the person's head will come clean off. If it's too short, they'll choke to death. "In my experience there are so many administration errors that even though a method should work in theory, because of either errors or incompetence, mistakes happen," says Megan McCracken of the Death Penalty Clinic at UC Berkeley. No one has been hanged in the US since 1996.
Though it's often associated with war and military crimes, death by firing squad has recently been adopted by the State of Utah as a back-up, and it is already routinely used in North Korea.
In the typical set up, a criminal is strapped to a chair with a hood over their head. Then five anonymous marksmen fire shots at their chest. One gun contains a blank.
In 1938, the very same state used the method to execute a 40-year-old man, John Deering, who was convicted of murder. He took the unusual decision to have himself hooked up to an electrocardiogram while it happened, so we have an idea of how swiftly the method works.
The monitor revealed that Deering's heart stopped beating just 15 seconds after being hit. It's impossible to know for sure how long he was in pain, but once again rodents can provide some hints. A 2015 study of cardiac arrests in rats suggests that they're usually followed by a surge of brain activity that lasts around 30 seconds, which may explain why those who have survived near-death experiences report feelings of heightened awareness. Then the world goes dark.
The electric chair was first invented as a more humane alternative to hanging. Like the guillotine and the lethal injection, it was seen as civilised and scientific. It all started with a chilling report commissioned by the State of New York in 1887, which evaluated 34 ways to kill a human.
One of its authors, a dentist, recalled hearing about a drunken dock worker who had touched an electric generator some years before and died instantly. He came up with the idea for the electric chair, which was used to dispatch an axe murderer just three years later.
The honeymoon phase didn't last long. It soon became clear to the public that these deaths were often messy and drawn-out, with chairs acquiring nicknames such as "Gruesome Gertie" and "Sizzling Sally". Nine US States have retained the method as a back-up, though this is controversial.
Which brings us to the latest idea: "Nitrogen hypoxia", which involves replacing air with an inert gas such as nitrogen or helium. It first gained traction after a BBC documentary presented by former Conservative MP Michael Portillo. In How to Kill a Human Being, he declared that the method is "a perfect killing device".
For a start, air is 78% nitrogen anyway, so it's easy to get hold of. The method is also a surprisingly quick demise. One study from the 1960s found that volunteers breathing pure nitrogen lost consciousness in around 17-20 seconds. Based on animal studies, it's thought that they would have stopped breathing after three seconds.
And due to a quirk of biology it's apparently painless. That's because the body can't actually detect a lack of oxygen - just an excess of carbon dioxide, which acidifies the blood and causes that aching feeling in your legs after exercise. This means it doesn't feel like suffocation.
So what does it feel like?
John Levinson, a cardiologist and pilot based in Boston, Massachusetts, has some insights. Some years ago he was flying his prized Mooney plane at 23,000 feet (7km) , a height at which the Earth's atmosphere is thinner and pilots must use supplemental oxygen.
Then he did something risky: he tilted up a corner of his mask and kept breathing. "After about 30 seconds I felt truly weird," he says. "I didn't have hallucinations, or pain, or confusion, I just felt weird. It wasn't like alcohol or any other substance like that."
The subtle symptoms of hypoxia make it particularly deadly to pilots at high altitude, who may not recognise that anything is wrong. It's thought to have claimed the life of a man earlier this year, who appeared unconscious in his small plane before going missing over the Gulf of Mexico.
In Levinson's case, he was flying with his instructor, who would have brought the plane down safely in the event that he passed out. The idea was to get a sense of what hypoxia is like, so that he could recognise when it was happening in the future. Years later, while flying with his wife, he started to get the same weird feeling. He recognised it immediately and fixed a kink in his oxygen line before anyone got hurt.
Three US States have now authorised the method as a back-up. But is this just another mistake?
No pharmaceutical company wants its drugs used to kill people
Robert Dunham, a litigator and the Executive Director of the Death Penalty Information Center, certainly thinks so. "The American Veterinary Medical Association and World Animal Protection both say that nitrogen hypoxia is inappropriate for veterinary euthanasia," he says. "It's not quick as has been advertised - cats and dogs are aware of their impending death before they lose consciousness and it takes at least seven minutes to put to death a pig."
One of the primary issues is that the method relies on the cooperation of the prisoner: if they hold their breath, or their breathing is too shallow, it might take much longer to kill them. "I understand, of course, the theory behind it, that suggests it would be a humane method," says McCracken. "But that is a far cry from how it would actually be performed in an execution chamber."
According to Dunham, in all likelihood the victim would have to be anaesthetised first. And this brings us back to the issues facing the lethal injection: no pharmaceutical company wants its drugs used to kill people.
"The key problem the United States has is that it doesn't want the gruesome or visceral aspects of capital punishment. It wants the prisoner executed, but it doesn't want on its conscience that it's brutally killing somebody. That's an internal contradiction," he says.
"When it comes to execution, I think people need to understand that the death penalty is not a humane act."
If you liked this story, sign up for the weekly bbc.com features newsletter, called "If You Only Read 6 Things This Week". A handpicked selection of stories from BBC Future, Earth, Culture, Capital, and Travel, delivered to your inbox every Friday.