NEW YORK (AP) - After Garry Shandling died two years ago, his longtime friend Judd Apatow went through emails he and the comedian had recently shared. Then he started bawling.

“I realized that every single time I asked him for anything or wanted him to come to some event or to read something for me, he said ‘yes’ every single time,” said Apatow. “It really made me cry.”

Shandling, a groundbreaking comedian not far from the neurotic characters he played, had dedicated his last years to consciously encourage and mentor his friends and fellow comedians but Apatow hadn’t realized the full extent of his generosity.

“He had a lot of conflicts with people but he was also trying very hard to figure it all out so he could do better,” he said. “He was a complete, complex human being with all the flaws and all the greatness as anybody else in the world.”

Apatow decided to memorialize his friend in an appropriate way. Shandling, who masterminded a brand of phony docudrama with “The Larry Sanders Show,” is now the subject of Apatow’s four-hour HBO documentary called “The Zen Diaries of Garry Shandling.”

The film includes interviews with James L. Brooks, Linda Doucett, David Duchovny, Sacha Baron Cohen, Jay Leno, Kevin Nealon, Conan O’Brien, Bob Saget, Sarah Silverman and Jeffrey Tambor. The documentary airs in two parts on March 26 and March 27.

While four hours sounds like a lot, Apatow goes deep, drawing on 30 years of Shandling’s intimate diaries and notes, childhood movies, stand-up performances and raw footage. Michael Cera reads the diary entries, which show a man trying to quiet his demons. “You are scared of awakening. Let go of that,” one entry reads.

“It was very difficult to sit down and read his diaries,” said Apatow. “It was like living in Garry’s head for a while. It was very emotional. I felt all his pain and his joy.”

“The Larry Sanders Show” was the forerunner to a new kind of painfully awkward, authentic comedy that would inspire “The Office,” ”Curb Your Enthusiasm,” ”Arrested Development” and a generation of comics.

In the series, Shandling played an insecure and spineless late-night TV talk-show host with a regular habit of watching his show in bed at night. Shandling had already made a name for himself with the comedy series “It’s Garry Shandling’s Show,” in which the actors routinely broke the fourth wall to comment on what they were up to.

Apatow had a long history with Shandling, interviewing the comic when he was a 16-year-old high-school student doing a radio show on Long Island. He went on to write for Shandling, direct episodes of “The Larry Sanders Show” and considered his “Freaks and Geeks” a version of “The Larry Sanders Show,” only set in high school.

“The Zen Diaries of Garry Shandling” explores the development of both hit TV shows and delves into Shandling’s childhood, his tortured romance with Doucett, his messy break with former manager Brad Grey and the time he became a target of private eye Anthony Pellicano.

Nealon praises the documentary, calling Apatow “a skilled surgeon when it comes to putting the right things in there. He could have made it an eight-hour documentary and we still would have been riveted to it.”

The film reveals that the death of Shandling’s older brother from cystic fibrosis when Shandling was 10 became a pivotal event, reverberating in his relationship with his suddenly clingy mother, his future love affairs and his quest for honesty.

“When his brother died, his family didn’t talk about it ever. That’s how they dealt with it - by not talking about it. And I think Garry became obsessed with presence and truth because he didn’t get that as this important moment,” said Apatow.

“This moment changed him. He was very happy as a little kid. He had a dream relationship with his brother. I can’t say he ever seemed as much at peace in footage as he does in the footage when he’s a little kid rising around with his brother.”

Shandling died of a heart attack at age 66 in 2016. Apatow channeled much of his grief into the documentary, which grew out of short films he made for the memorial service.

“Now that’s over I’m very sad because it’s like letting go of my relationship with Garry,” he said. “I already miss him because the project is over.”