Former New York City mayor Rudolph Giuliani speaks during a campaign event for Donald Trump in Miami. (European Pressphoto Agency)

Fans of Rudy Giuliani are wondering: What is he thinking?

The former New York mayor is shilling for Donald Trump almost nonstop on cable news, serving as attack dog on less-than-savory topics such as Hillary Clinton’s health and the Clinton marriage. Highlights from the past few days include his comment that “everyone” commits marital infidelity and that Trump is an economic “genius” who is better for the United States “than a woman.” Those are just the latest examples.

So why would someone be trying to publicly out-Trump Trump five weeks before the election?

We’ll give you 15 guesses.

Giuliani is eyeing the role of Trump’s attorney general if he’s elected in November, according to sources close to the process. And to campaign for it — after all, he’s got to beat Chris Christie — he’s giving the surrogate performance of a lifetime. Trump’s preferred policy of stop-and-frisk? Giuliani claims it brought about an 85-percent reduction in crime in New York City. Black Lives Matter? “Inherently racist.” And police relations? He’s holding a meet-and-greet for Trump with Cleveland’s police union Tuesday.

Giuliani denied he’s pursuing “any office or position in a future administration.”

“I’m very happy practicing law at Greenberg Traurig and business consulting at Giuliani Partners, solving cybersecurity problems both domestically and internationally, and doing security analysis for companies and governments around the world,” he said in a statement.

Still, associates say he’d make a wonderful leader for U.S. law enforcement.

“I have a great deal of affection for Chris Christie, too,” said Ted Olson, a partner with Gibson, Dunn & Crutcher who called Giuliani a “very good friend.”

“But Rudy was a tremendous associate attorney general and U.S. Attorney for the Southern District of New York, which is more important than any of the other federal prosecutorial districts. I doubt there is anyone in the country who could come close in terms of his experience. … He had the job of number three [at the Justice Department], then was U.S. attorney, then ran for mayor. He is exquisitely well-suited for attorney general.”

Giuliani might also have a leg up if the “Bridgegate” scandal keeps revealing unflattering details about Christie, the head of Trump’s transition team who could want the job himself if the GOP nominee wins the White House. One member of the Star-Ledger editorial board recently called the case “pure New Jersey stink” — not a great association for a future AG.

At least there’s always Homeland Security.