The Machinist is a 2004 psychological thriller film directed by Brad Anderson and written by Scott Kosar. It stars Christian Bale as the title character, a machinist struggling with paranoia and delusion after being unable to sleep for an entire year. Jennifer Jason Leigh, Aitana Sánchez-Gijón, John Sharian, and Michael Ironside appear in supporting roles.
 The film drew attention due to Bale's commitment, having lost 62 pounds (28 kg) in preparation for his role. Upon release, The Machinist was well received by critics, with praise for Bale's performance, and grossed $8.2 million on a $5 million budget. In later years it has gained a cult status.
 Trevor Reznik is a machinist whose insomnia has led to him becoming emaciated. His appearance and behavior keep his coworkers away, and they eventually turn against him when he is involved in an accident, which causes his coworker, Miller, to lose his left arm. Trevor, who was distracted by an unfamiliar coworker named Ivan, is blamed for the accident. No one at the factory knows of Ivan and there are no records of him. Trevor seems to find comfort in the arms of Stevie, a prostitute with genuine affection for him, and with Maria, a waitress at an airport diner he frequents. He is haunted by brief flashes of recurring imagery, and things such as his car cigarette lighter take on a menacing air. A mysterious series of post-it notes appear on his refrigerator, depicting a game of hangman.
 These vague incidents send him further into paranoia, but he nonetheless attempts to establish a relationship with Maria. Meeting her at an amusement park, Trevor goes with her son Nicholas on a dark ride called "Route 666". The ride starts as a harmless scare ride, but begins to show increasingly disturbing images as it advances, until its flashing lights cause Nicholas to suffer an epileptic seizure. No longer able to think clearly, Trevor suspects that the bizarre events are a concerted effort to drive him insane, as do recurring clues such as a photo of Ivan fishing with Trevor's coworker Reynolds, which he discovers in Ivan's wallet when Ivan leaves it unattended in a pub. Another near-accident at work causes Trevor to lash out in rage at his coworkers; as a result, he is immediately fired. Increasingly distracted and alienated, Trevor forgets to pay his utility bills and his electricity is disconnected. A dark, viscous liquid begins trickling out of the freezer, coating the refrigerator door with streaks of what appears to be blood.
 After several attempts to confront Ivan, Trevor tries to trace his license plate, but runs out of gas while in pursuit of his car. When a DMV clerk insists that personal information cannot be released unless a crime has been committed, Trevor throws himself in front of a car in order to accuse Ivan of committing a hit and run. He files a police report with Ivan's plate number, only to be baffled when he is told that the car in question is his own, and that he had reported it totaled one year ago. He flees the police and goes to Stevie, who bathes and clothes him, but he is disturbed by the discovery of the photo of Ivan and Reynolds framed in her home. Trevor accuses her of conspiring against him. Confused, Stevie says the picture is of Reynolds and Trevor, but he refuses to look at it, and after a violent argument, Stevie throws him out. He goes to the airport diner, but is told by an unfamiliar waitress that they've never had an employee named Maria. The waitress at the counter tells Trevor she has served him every day for a year, and, in all that time, he spoke so little that she thought he was mute.
 Trevor sees Ivan take Nicholas into Trevor's apartment and, fearing the worst, sneaks inside. Nicholas is nowhere to be seen and doesn't respond to Trevor's calls. Trevor confronts Ivan in the bathroom, and Ivan tells him "you know he's dead". Trevor, believing Ivan has killed Nicholas and his body is in the bathtub, attacks and seemingly kills him. He pulls back the shower curtain, only to find the bathtub empty. He goes to the refrigerator and opens it to find rotting fish, matching those in the fishing photo, which he at last realizes was of himself with Reynolds, just as Stevie claimed; Trevor hallucinated Ivan's presence in the photo. Trevor takes a rolled-up carpet containing Ivan's body to the ocean to dispose of it, only for the rug to unroll as he does so and reveal nothing inside. Ivan, unharmed, approaches Trevor from behind, and laughs as he tells Trevor that he has some explaining to do.
 Trevor stares into a mirror at home, repeating the words, "I know who you are." He remembers that one year prior, a then-healthy Trevor ran over and killed a boy (identical to Nicholas) after taking his eyes off the road to use the car's cigarette lighter, which was witnessed by the boy's mother (identical to Maria). Trevor fled the scene in his car, and the resulting guilt became the root of his insomnia, emaciation and repressed memories. Ivan was a figment of Trevor's imagination and a manifestation of his guilt. He fills the missing letters on the hangman note, spelling out "killer". The next day, he puts all his personal items in boxes meant to be donated, as he tells his landlord. He briefly considers going to the airport to escape, but instead drives to police headquarters. He is accompanied by a silent but encouraging Ivan, who bids him an approving farewell outside the station as he enters and confesses to the hit-and-run. Two police officers escort Trevor to a cell, where after stating that he only wants to sleep, he does, for the first time in a year.
 Despite its setting in California, the film was shot in its entirety in and around Barcelona, Spain. It was produced by the Fantastic Factory label of Filmax and Castelao Productions.
 Christian Bale strenuously dieted for over four months prior to filming, as his character needed to look drastically thin. According to a biography of Bale written by his former assistant, this daily diet consisted of "water, an apple and one cup of coffee per day, with the occasional whiskey" (approximately 55–260 calories). According to the DVD commentary, he lost 62 pounds (28 kg), reducing his body weight to 120 pounds (54 kg). Bale wanted to continue down to 99 pounds (45 kg), but the filmmakers would not allow it due to health concerns. In fact, the target weight to which the 6 ft (183 cm) Bale dropped was intended for a much shorter actor, but Bale insisted on seeing if he could make it anyway. At the end of filming he was left with just six weeks to regain enough mass to be ready for the screen test for his role in Batman Begins, which he achieved through weightlifting and binging on pizzas and ice cream.
 Brad Anderson hurt his back during filming and directed much of the film while lying on a gurney.
 The name Trevor Reznik is derived from Trent Reznor, the founder and primary creative force behind the industrial rock band Nine Inch Nails, and the original script had Nine Inch Nails lyrics on the first page. Other Nine Inch Nails tributes include early press articles describing Reznik as experiencing a "downward spiral".
 However, the strongest literary influence is the Russian novelist Fyodor Dostoyevsky. In the DVD commentary, writer Scott Kosar states that he was influenced by Dostoyevsky's novel The Double.
 The Machinist opened on 22 October 2004 in three theatres in North America and grossed $1,082,715 with an average of $21,553 per theatre ranking 45th at the box office. The film's widest release was 72 theatres and it grossed $1,082,715 in North America and $7,120,520 in other countries for a total of $8,203,235.
 The Machinist has a score of 77% on Rotten Tomatoes based on 142 reviews and an average rating of 6.6/10. The critical consensus states: "Brad Anderson's dark psychological thriller about a sleepless factory worker is elevated by Christian Bale's astonishingly committed performance." On Metacritic the film has a score of 61 based on reviews from 32 critics, indicating "generally favorable reviews".
 Roger Ebert gave the film three stars out of four and stated in his review for the film: "The director Brad Anderson, working from a screenplay by Scott Kosar, wants to convey a state of mind, and he and Bale do that with disturbing effectiveness. The photography by Xavi Gimenez and Charlie Jiminez is cold slates, blues and grays, the palate of despair. We see Trevor's world so clearly through his eyes that only gradually does it occur to us that every life is seen through a filter. We get up in the morning in possession of certain assumptions through which all of our experiences must filter. We cannot be rid of those assumptions, although an evolved person can at least try to take them into account. Most people never question their assumptions, and so reality exists for them as they think it does, whether it does or not. Some assumptions are necessary to make life bearable, such as the assumption that we will not die in the next 10 minutes. Others may lead us, as they lead Trevor, into a bleak solitude. Near the end of the movie, we understand him when he simply says, 'I just want to sleep.'"