In 1939, when Jerry Parr was 9 years old, his father took him to the movies to see “Code of the Secret Service.”

“A cone of light flickered from the projection room onto the screen,” Parr later wrote. “The Capitol. The Washington Monument. The Lincoln Memorial.”

The frame then shifted to an office door. “Secret Service Division,” the sign said. Suddenly, agent Brass Bancroft emerges. The actor playing him was a handsome young man named Ronald Reagan.

“My nine-year-old imagination took off,” Parr wrote.

At that moment, Parr dreamed of becoming a Secret Service agent, protecting presidents from bad guys. But he never imagined how his life, and the actor’s on screen, would intersect decades later.

Parr grew up to become a Secret Service agent. Reagan grew up to become president of the United States.

On March 30, 1981 — 40 years ago today — Parr saved the president’s life.

Reagan had just finished giving a speech at the Washington Hilton hotel. Parr, the agent in charge of presidential security, was escorting Reagan to his limousine when John W. Hinckley Jr., a deranged man trying to impress actress Jodie Foster, opened fire.

Footage shows the March 30, 1981 assassination attempt of president Ronald Reagan. Former press secretary James Brady, who is highlighted in this video, was shot in the head, leaving him partially paralyzed. (Reuters)

The shots — six in total — were heard up and down Connecticut Avenue NW, including at a nearby office building, where Parr’s wife, Carolyn, was working as a lawyer. Parr had told her that Reagan would be nearby that morning, so she was outside to try to catch a glimpse.

She ran to the hotel.

“I was crying and shaking out of control,” Carolyn said in an interview.

She saw three bodies lying in the street. One was James Brady, the White House press secretary. Another was Secret Service agent Tim McCarthy. The third was D.C. police officer Thomas K. Delahanty.

“I’m Jerry Parr’s wife,” Carolyn remembers shouting. “Where’s my husband?”

An agent replied, “In the car — with the man.”

As soon as Parr heard the shots, he grabbed Reagan by his belt and pants and threw him onto the floor of the armored limo, ordering the driver to return to “the crown” — the code name for the White House.

Nobody realized Reagan had been wounded.

“Checking him for blood, I methodically worked my hands around his body from the belt line up, under each arm, along his back, neck, and head — looking for blood, feeling for a wound or a painful spot,” Parr wrote in his memoir, “In the Secret Service.” “With immeasurable relief, I assessed that he had escaped unharmed, at least for the moment.”

But moments later, Parr noticed that Reagan was pale and grimacing when he tried to take in air.

“Is it your heart?” Parr asked.

“I don’t think so,” the president replied, according to the memoir. “I think you broke my rib.”

Reagan then wiped his lips with a napkin. Blood oozed out.

“I must have cut the inside of my mouth,” Reagan said.

But Parr suspected a lung injury. They were now passing through the tunnel underneath Dupont Circle, racing toward the White House. Parr changed his mind.

“Mr. President,” he said, “we’re going to GW Hospital.” Reagan’s wife, Nancy, would later tell CNN host Larry King that “if Jerry hadn’t made the change, I wouldn’t have a husband.”

Reagan, insisting on walking into the hospital himself, collapsed on arrival. Parr helped carry him into a trauma room. Doctors and nurses stripped his clothes off looking for the wound, finding it under his left arm. The bullet was lodged in his lung.

Parr stood next to the president, watching as a chest tube was inserted. The president regained consciousness.

“Mr. President,” a surgeon asked, “do you know what happened?”

“No, not really,” he replied.

“Someone shot you,” the surgeon said.

By now, the first lady had arrived. The president had also regained some of his signature charm.

“Honey,” he told Nancy, “I forgot to duck.”

Doctors told him he was going to an operating room.

“I hope these guys are Republicans,” Reagan joked to Parr. When he repeated the line to doctors in the OR, one of them — a lifelong Democrat — replied, “Mr. President, today we’re all Republicans.”

The president came through. Parr retired in 1985, later serving in the clergy. He died in 2015 from congestive heart failure.

In an interview in 2011 with Del Quentin Wilber, the author of “Rawhide Down: The Near Assassination of Ronald Reagan,” Parr said March 30, 1981, was “my best day and my worst day.”

Somehow, it all seemed preordained.

After the shooting, Parr asked Reagan, “Did you know you were an agent of your own destiny?”

The president didn’t know what he was talking about. Parr told him about seeing “Code of the Secret Service” as a boy and how it inspired him to become a Secret Service agent.

The president smiled.

“It was,” he said, “one of the cheapest films I ever made.”

Read more Retropolis: