Scientists have a firm grasp on the purpose of certain automatic physical functions, like blinking, breathing, or digestion. When it comes to sleep, however, researchers still aren’t clear on why exactly your body needs to shut off every night. Details aside, one thing’s for sure: When you don’t sleep, your body revolts.

The effects of acute sleep deprivation—which is more akin to pulling an all-nighter than to getting just a few hours of sleep every night for weeks at a time (that’s chronic sleep deprivation)—generally kick in after 16 to 18 hours of being awake and get progressively worse with each proceeding hour. Your mind, heart, endocrine system, and immune system are all affected, malfunctioning in ways both subtle and severe.

The consequences of chronic sleep deprivation are far worse than one sleepless night. But the decision to pull an all-nighter just once can leave some serious damage in its wake.

Mind

When it comes to the effects of acute sleep deprivation, “It’s really all about the brain,” says Steven Feinsilver, director of sleep medicine at Lenox Hill Hospital and a leading sleep researcher. The first signal that your body is overtired will be a sluggish mind. Your reaction time will begin lagging around hour 18; after a full night without sleep, it will nearly triple—which, for context, is about the same as being legally drunk. Your ability to form memories will start deteriorating, and after a while, your capacity to create any new memories at all will shut off entirely.

“It’s almost as though without sleep, the memory inbox of the brain shuts down,” Matthew Walker, a UC-Berkeley professor and author of Why We Sleep, told Business Insider last year. “So those new incoming informational emails are just bounced.”

From hour 18 onward, your decision-making and math-processing abilities and your spatial awareness slowly deteriorate.

Stay up longer than 24 hours and your brain, now in panic mode, will soon take over and force sleep upon you. “You’re basically going to have microsleeps,” Feinsilver says. Though you will appear to be awake—walking, talking, eyes open—your brain will quite literally put itself to sleep for ten to 20 seconds at a time.

During these microsleeps, you can’t process what you’re seeing around you. “We say during sleep you are cortically blind—your brain does not process visual information,” Feinsilver says. “Your brain goes on on autopilot. So, if you’re driving, you might realize that you missed your exit and don’t remember the last ten minutes. And that’s really scary stuff, because it means you’ve been asleep for moments when you really should be awake.”

Stay up for longer than 35 hours, as Walker and a team of scientists from Berkeley and Harvard had research subjects do in a 2007 study, and your emotional mind will start behaving irrationally. When you’re up for that long, the emotion-emitting amygdala becomes 60 percent more reactive to negative stimuli or experience, while also limiting communication with the part of the brain that regulates emotion and contextualizes experiences. In other words, you’re more reactive and judgmental to the people and events around you, and your brain loses its natural ability to run things through a filter or any internal voice of reason.

If you’re up past 48 hours, hallucinations are common, as Feinsilver experienced firsthand years ago as a medical student. It was October, just before Halloween, and while he was suffering from both acute and weeks of chronic sleep deprivation, a nearby pumpkin started talking to him. “I realized, okay, it’s time to go home,” Feinsilver says.

Stay up for longer than 48 hours and you’re looking at behavior that mimics psychosis—incoherent rambling, disconnection from reality, prone to outbursts. Push yourself longer than a few days without sleep, and the effects can be lethal. The exact ways in which sleep deprivation can cause you to die aren’t entirely understood, but researchers believe it has to do with your mind losing its ability to control life-giving processes and the total disruption of your system that results.

So, why exactly does the brain malfunction in such a profound way without sleep? Researchers aren’t exactly sure, but their best guess has to do with something they’ve dubbed “substance S.”

“The brain is a very active metabolic area. When it works full-time, it generates toxic products,” Feinsilver says. “It’s like when you work out: Your muscles build up lactate, and eventually you can’t do anything more because it hurts, and it’s time to let them relax. Your brain is kind of on all the time while you’re awake, and sleep is designed to be a time to get rid of the toxic products that build up.” Substance S—which scientists think might be adenosine, a byproduct of metabolism that builds up in the blood—might be the toxic metabolite that accumulates in the brain throughout the day, and the need to flush it could be the reason your brain demands sleep every night.

At this point, though, the daily buildup of this metabolite and whether the brain is responsible for purging it during sleep is still only a theory “It’s just a good way of explaining why people might need sleep—it’s the most efficient way to purge a toxic product,” Feinsilver says.

Mechanism aside, we know that “wakefulness is essentially low-level brain damage,” Walker said in an interview with Business Insider.

Heart

Your blood pressure rises over the course of the day, usually due to the physical and emotional stressors you inevitably encounter. Every night while you sleep, your blood pressure (as well as your heart rate) drops back down. Sleep, in other words, is a natural blood pressure medication. Without that daily reboot, it steadily rises, and your risk of heart attack, stroke, and even long-term heart disease skyrockets.

If you’re awake for longer than 18 hours, your heart doesn’t get its daily respite, and that can have lethal consequences. In fact, research has found that on the Monday after spring daylight saving time, when we lose an hour of sleep, there’s a 25 percent increase in heart attacks. Conversely, in the fall, when we gain an extra hour, there is a 21 percent reduction in heart attacks. While scientists aren’t exactly sure why this is happening, it is clear that sleep—or lack thereof—has an immediate effect on your heart.

Endocrine System

Sleep is vital for hormone production, and if you’re up for more than 18 hours, your testosterone will slowly deplete, affecting energy levels. The good news: Studies have shown that a subsequent night of good sleep can work to return testosterone levels to normal.

Where you get into real trouble, hormonally speaking, is after days, weeks, or months of bad sleep—when you dig yourself into a hole that your body can’t get out of. Studies have shown that just one week of sleep deprivation—less than five hours per night—dropped young male’s testosterone levels by a whopping 10 to 15 percent. For comparison, a healthy individual’s testosterone will naturally decline by 1 to 2 percent per year. In other words, as far as your hormonal system is concerned, a week of bad sleep will age you a decade.

Immune System

As you stay awake for longer than 18 hours, your body starts to build up pro-inflammatory proteins like IL-6, a blood marker associated with chronic health conditions and heart disease. Your number of immune cells begins to decline as well, as your body is deprived of its opportunity to make more.

Fight sleep even longer and your body will have a harder time producing natural killer cells, which fight cancer and virus-infected cells in your body. In fact, researchers have found that just one night of poor sleep reduces the amount by over 70 percent. Not sleeping will profoundly and immediately increase your risk for cancer, which is part of the reason that, in 2007, the World Health Organization deemed nighttime shift work a probable carcinogen.

Performance

If the body malfunctions, it’s safe to assume that your performance takes a hit as well, right? Yes, but the effect is more mental than physical. According to Shona Halson, senior recovery physiologist at the Australian Institute of Sport who specializes in sleep, “During exercise, you don’t see many changes in the physiological systems.” Instead, she says, “What we tend to see are changes in perception of effort. Everything feels harder, so you’ll do worse on a performance test, not because of physiological changes, but because your perception of effort has changed.”

And that’s a fact worth broadcasting, says Halson, because everyone has felt that panic after only managing a few hours of sleep before a big race. You’ll certainly feel tired, and your brain might be a little foggy, but you can still extract your fitness potential. “It’s important to tell athletes that if you get one bad night of sleep, the 20 years of training you have previously done doesn’t go away,” Halson says. “Your fatigability may have gone up a little bit after one bad night, but if it’s an important event, adrenaline usually kicks in.”

That’s not to say you shouldn’t be mindful of your performance after a bad night’s sleep. Halson says that in long endurance events or team sports, where there are more cognitive and emotional components than, say, a 100-meter sprint, a sleep-deprived brain can play tricks on the body. The best thing you can do: Remind yourself that you’ve put in the work and that the cloudiness you’re feeling is more likely than not just your brain asking for sleep.

Illustration by Bill Butcher