Eight years after the death of district attorney Harvey Dent, the Dent Act grants the Gotham City Police Department powers which nearly eradicate organized crime. Police Commissioner James Gordon feels increasingly guilty for covering up the crimes committed by Dent, who was turned into a murderer by the Joker. He writes a resignation speech confessing the truth but decides not to use it.
Bruce Wayne has become a recluse, broken by the death of his childhood sweetheart Rachel Dawes and has retired as the vigilante Batman after taking the blame for Dent's crimes, as well as Dent's death. Cat burglar Selina Kyle obtains Wayne's fingerprints from his home and kidnaps congressman Byron Gilley. She sells the fingerprints to Phillip Stryver, an assistant to Wayne's business rival John Daggett. In return, she requests her payment: a "clean slate" that can wipe all traces of a person from the internet.
Stryver double-crosses Kyle, but she uses Gilley's phone to alert the police to their location. Gordon and the police arrive to find the congressman, and then pursue Stryver's men into the sewers while Selina flees. The police attempt to follow them into the sewers, but the men that enter the sewers are killed, and Gordon is captured, while the rest of the police are assailed down by sniper fire.
The assailants drag Gordon to Bane, a masked mercenary, who has him searched and finds his resignation speech. Gordon escapes and is found by John Blake, a patrol officer. Gordon promotes Blake to detective, with Blake reporting directly to him. Bane and multiple accomplices attack the Gotham Stock Exchange, using Bruce's fingerprints in a transaction that leaves Wayne bankrupt. Wayne's butler Alfred Pennyworth reveals that Rachel had intended to marry Dent before she died. Alfred then resigns in an attempt to convince Bruce to move on from being Batman.
Wayne Enterprises is losing profits after Wayne discontinued his fusion reactor project when he learned that the core could be weaponized. Fearing that Daggett, Bane's employer, would gain access to the reactor, Wayne asks Wayne Enterprises board member Miranda Tate to take over his company. Kyle agrees to take Batman to Bane but instead leads him into Bane's trap. Bane reveals that he intends to fulfill Ra's al Ghul's mission to destroy Gotham with the League of Shadows remnant. He engages Batman and delivers a crippling blow to his back, before taking him to a foreign, well-like prison where escape is virtually impossible. There, the inmates tell Wayne the story of Ra's al Ghul's child, born in the prison and cared for by a fellow prisoner before escaping the only prisoner to have ever done so. Wayne assumes the child to be Bane.
Bane lures Gotham police underground and traps them there. He kills Mayor Anthony Garcia and forces Dr. Leonid Pavel, a Russian nuclear physicist he kidnapped from Uzbekistan six months prior, to convert the reactor core into a nuclear bomb. Bane uses the bomb to hold the city hostage and isolate Gotham from the world. Using Gordon's stolen speech, Bane reveals the cover-up of Dent's crimes and releases the prisoners of Blackgate Penitentiary, initiating anarchy. The wealthy and powerful have their property expropriated, are dragged from their homes, and are given show trials presided over by Dr. Jonathan Crane, where all are sentenced to death.
After spending months recovering and re-training, Wayne escapes from the prison. He enlists Kyle, Blake, Tate, Gordon, and Lucius Fox to help stop the bomb's detonation. He hands the Batpod to Kyle, tasking her with helping people evacuate and saving herself. She asks him to come along, leaving Gotham to its fate, but he refuses. While the police and Bane's forces clash, Batman overpowers Bane. He interrogates Bane for the bomb's trigger, but Tate intervenes and stabs him. She reveals herself to be Talia al Ghul, Ra's al Ghul's daughter. Bane is her protector, who aided her escape from the prison. She uses the detonator, but Gordon has successfully approached the bomb and blocks her signal, preventing remote detonation. Talia leaves to find the bomb while Bane prepares to kill Batman, but Kyle returns on the Batpod and saves Batman by killing Bane. Batman and Kyle pursue Talia, hoping to bring the bomb back to the reactor chamber where it can be stabilized. Talia's truck crashes, but she remotely floods and destroys the reactor chamber before dying. With no way to stop the detonation, Batman uses the Bat to haul the bomb over the bay, where it detonates.
In the aftermath, Batman is presumed dead and is honored as a hero. With Wayne also presumed dead, Wayne Manor becomes an orphanage, and his remaining estate is left to Alfred. Fox discovers that Wayne had fixed the Bat's autopilot and Gordon finds the Bat-Signal refurbished. Alfred finds that Wayne is alive and well, together with Selina, while visiting Florence. Blake resigns from the police force and, following Wayne's instructions, discovers the Batcave and its contents.
Output: What is the purpose behind Alfred Pennyworth retiring?