Kumail Nanjiani pitched Judd Apatow a film called "Ghost Witch," but wound up adapting his real-life love story for the screen.

“On day two of the coma, I started taking notes,” joked Kumail Nanjiani during a panel at this month’s Hamptons International Film Festival, when asked how he and wife Emily V. Gordon went from vigil-keeper and patient to co-screenwriters of the year’s second-highest-earning indie, “The Big Sick.”

Though the couple married in 2007 — months after their relationship endured the illness depicted onscreen — a half-decade passed before producer Judd Apatow encouraged comedian Nanjiani to write a film adaptation of their ordeal, which doubled as a terribly-timed introduction to his future in-laws. Screenwriter Gordon’s notes dramatically improved her husband’s first draft, and they proceeded to finish the script together, laboring over its development for the next three years, with guidance from producers Apatow and Barry Mendel and director Michael Showalter.

I culled through my and other staff interviews with Nanjiani, Gordon and Showalter, as well as transcripts from Variety’s”10 Actors to Watch” talk moderated by Eric Kohn and the film’s New York press day, to assemble a detailed oral history of the “The Big Sick” screenplay, which is the most likely awards season prospect from Amazon Studios.

Read it and weep: this reveals how long and tough it can be for seasoned producers, directors and screenwriters to develop and craft an award-worthy final shooting script.

KUMAIL NANJIANI: For a long time, [Emily’s illness] was this paralyzing thing that happened that – at least for me when I thought about it – was too big, too much…like touching a live wire.

EMILY V. GORDON: We really did not touch it creatively together for about five years. Right after I got out of the hospital, I wrote a couple of essays about being sick for women’s websites. The essays were awful…That was the extent of it for me [for a while].

KN: I’d met Judd Apatow at a festival, and he was like, “Let’s work together. Do you have any ideas?” I went down and I pitched him a bunch. One was about a ghost witch – it was a witch woman who died and came back as a ghost. He was like, “Do you have any other ideas?”

EVG: I think we’d joked about [our story becoming a movie]… I don’t know that we could have done it [on our own], because we maybe would have drowned in our own story.

KN: Then I said [to Apatow], “You know, the weird thing that happened to us was when Emily and I were first dating, she got really sick and was in a coma for eight days and I hung out with her parents, who I didn’t know at all.” And he was like, “That’s it! Let’s work on that. Go prepare a pitch, come back, and pitch it to me as a movie.” I think he wanted to see if I would put in the work.

The first draft I wrote was 180 pages – he was like, “Just write everything you remember.” I showed it to Emily and Emily had so many great thoughts – they weren’t just notes, it was another perspective in the movie.

EVG: [One scene] was just Kumail showing his new girlfriend one of his favorite movies, and she loves it! When I read it, I added in, “Guys are always doing this thing where they want to introduce you to their pop culture world when you start dating them.” It’s just such a funny little thing to me that I’ve experienced my entire life because I’ve always dated nerd guys.

KN: And I was like, “I think we have to write this together.”

EVG: I took a couple of days to think over whether or not I wanted to be involved in it, because it is such a personal and vulnerable thing. A lot of my close friends didn’t know that I’d been sick, because it just wasn’t something I talked about a whole lot…But part of me always knew that this was something that we were going to tackle because we’re both creative people, and this was such a huge thing for us and it changed our lives so much…We realized that this story needed to be told by both of us if it was going to be told at all.

I thought we’d have to make a pitch to Judd like, “This is why we think [we should write it together].” We went in and [he] was like, “Oh yeah, that’s wonderful, great!” It was the easiest thing possible.

KN: We started writing together and that was 2012.

EVG: He was really encouraging about, “The first draft should just be a vomit draft: just take it, put it all on the page, and then you can start shaping it”…The first draft was emotionally difficult – literally just us telling our story in a narrative sense – and then all the drafts after that were much harder.

KN: We wrote for three years, just in our off-time, writing and re-writing and re-writing and re-writing and re-writing… Once we’d gotten our story down as it happened, [Apatow and Mendel] were like, “Now you have to separate yourself from the story, and trust that the emotional core will stay. Just make it a good story.” So that was most of the work we did.

Tara Mays/Variety/REX/Shutterstock

EVG: Because we live together, that’s quite helpful in a lot of ways – it’s not like you have to get dressed and go meet your writing partner. Kumail and I have two separate writing spaces in our house; no matter how tiny or large our houses have been, it’s always been that we need two separate writing places that we can go and be away from each other, because we drive each other crazy… When he was a stand-up comedian primarily and I was a freelancer primarily, we would both be in the house all the time, and it was like, “Listen, if you are in my face all the time, not only will I not get anything done, I don’t know if I’ll love you anymore.” We need to be a little disciplined and a little separate, and that really helped working on something together.

“Here’s a breakdown of what scenes we have, this is what needs to be written, I’m going to take this, you’re going to take this, let’s split up and go do our work.” Very often you’re not in clothes, you’re in pajamas, you look a mess, your hair is terrible, and that’s it. The grunt work of it is that you’re spending hours and hours and hours writing those drafts, and then we would email those drafts to each other, rewrite each other’s drafts, and then end up yelling from across the house, “Wait, why did you change this?…Let’s get together, be in the same room, and discuss it.”

KN: You’re kind of forcing yourself to relive the most traumatic experiences of your life. [Later, when we were shooting,] I remember walking down the hospital hall and being like, Why am I going through this again? I already did this and now I have to do it with like 20 people watching me and giving me notes on how I’m doing this?

Ultimately it was very therapeutic, [it] really helped me deal with that whole strange experience that I hadn’t really thought about until we started writing about it… [Apatow and Mendel] were like, “So what were you thinking [back then]? What was going on? What was the plan?” And that’s when I realized, Oh, there was no plan…Emily was always very, very honest in the relationship from the beginning; there weren’t any surprises there. What was surprising was to me was talking to her friends while writing and finding out what she had been saying to her friends about me. Her friend was like, “Well it took you forever to say, I love you,” and I was like, “I didn’t know that was expected of me at an earlier date.”

EVG: During our [first year of] meeting[s], [Apatow] wouldn’t open our scripts, he would just put his hand on top of the script and talk about what scripts should be. He’s very macro like, “Here’s a diagram. We want this to happen at this chunk in the movie, this has to happen at this chunk.”

[Apatow and Mendel]’re both very experimental. “What other jobs could Kumail have? What other personality types could Emily’s parents be? What could happen in the third act that feels completely surprising? Should there be a heckling scene?” That was all of their work with getting us to keep trying different options, and not be married to any one specific thing, and certainly not be married to exactly how things happened… Then a couple months later we would come back having tried many of the things [they] suggested, and then we would kind of just keep going from there. And if it was something we felt strongly about, we’d be like, “Here’s why we didn’t do this”…Emily’s parents having their own storyline is something that we were like, “I don’t think we’re going to have room for that,” and they were really great about being like, “Oh, just give it a try, see what little beats you can put in there to show [that] these people are going through stuff, too, and they’re real, actual people.” They also really encouraged us to keep it messy and to not tie everything neatly with a bow…They’re the ones that really got us to stop being precious with the story—and Mike [Showalter] did that a bit, too.

MICHAEL SHOWALTER: It’s not actually you. It’s a fictional character based on something that happened to you. Characters start to take on really interesting dimensions when they start to exist as fully-dimensional fictional characters that you can start building onto. It tends to be hard sometimes to not want to write yourself in a kind of idealized way.

KN: [Showalter] would say to us often, “Separate yourself from this,” and I think Emily understood that before I did.

Bumphre/StarPix/REX/Shutterstock

EVG: I tried really hard to be open to the fact that things were going to have to change…to just be as militaristic as possible of what serves the story best…There was a scene in the hospital after I was out of the coma where Kumail brings a laptop and we like watched a movie together in my hospital room. That was both romantic but also I was in so much pain—physical pain—that I was trying really hard to act like I was cool and we were on a date when in reality I was like, Can you please leave? I need to go to sleep now, I feel terrible. So it was simultaneously a really lovely moment and not-so-lovely moment, and we worked hard to put that in the movie, and there was just no version of it that worked. And we ended up finding lateral scenes that kind of accomplished the same thing.

MS: A big part of what we were doing for the year before we shot the movie was taking this incredible true story and scenes and characters and ideas and fitting it into the form of a movie that was entertaining with a universal quality to it. A lot got changed, pushed aside, a lot was added and a lot stayed the same.

EVG: [Showalter] is such an expert in rom-coms, so he was really, really great at helping us kind of subvert a lot of rom-com stuff in the movie that I think could have gone a different direction. [Before] he came on, [the characters of] Emily and Kumail [we]re on the outs, but not fully broken up when Emily gets sick. And he was like, “Let’s push this even further.” He’s also really good with humor…that is genuinely funny but doesn’t take away from the tone of the movie…He was great both in working with the script and also in his direction—and in editing—of helping us to make sure that the movie never went unrealistic and never went too goofy, and never got so upsetting that you’re like terrified what’s going to happen.

MS: Kumail, Emily and I spent three or four months over an entire summer working together on big-picture outlining, cards on a board, scene-by-scene, mostly verbal, taking notes too, act-by-act. We presented the work to Judd and Barry. At that point, the script had made a big step forward so that now we were coming to the next phase, which was to take the script into the world for financing.

Kumail, Emily, Barry and I worked every day all day long for another four or five months, checking in with Judd.

KN: Barry’s a very tough boss to have. Because Barry’s like, “I’m living, eating, showering the film, why aren’t you?” “Alright, that’s a good point.”

ZOE KAZAN: I feel like Barry approaches his work really like an artist. I’ve never worked with a producer like Barry before. He’s so detail-oriented and I never feel like he clocks in or clocks out…Every element of this film has Barry’s touch on it. It’s incredibly rare and I think that’s why not just with Judd but with so many of the filmmakers he’s worked with, those films have come out so beautifully.

MS: Bringing in each actor, we did ten more rewrites. Everyone brought a different thing to the process, what was most important to them, the comedy or the drama, any number of things. We were figuring out what were the act breaks, the plot points, those classic milestones in a movie that guide the audience through the story…I look at it mathematically, so the movie in my brain is broken up into specific sequences and parts that are all part of a larger machine: the finished product.”

EVG: Your life doesn’t break out into a three-act structure… We were all figuring out what the movie was. It wasn’t like Judd knew, “This is what the movie is, and I will slowly knead it out for you”… There’s the story of a struggling comedian, there’s a story of an illness, there’s a story of someone with their own parents, someone with someone else’s parents, and figuring out which version of that story to tell was something we all just kind of gradually worked on together.

Spaulding/WWD/REX/Shutterstock

KN: There’s a scene where I have a breakdown on stage and that wasn’t scripted. It was always planned that I would just try and be in that place I was and just talk, so that was super tough, ‘cause it was very long and you’re forced to think about and say stuff that your whole body is wired to not think about or say.

EVG: When Kumail goes to Emily’s welcome home party and makes this big romantic pitch for her to come back to him…The audience is very aware that Emily is not thinking about a Prince Charming. She’s been through a very emotionally-intense experience, and this is just not where her head’s at. I think that’s something that we wanted to make sure that we conveyed, that Emily isn’t just going to wake up from a coma and be like, “I can’t wait to be in love!” It was also very important to us that Emily’s mother, Beth [Holly Hunter], never say to Emily, “You should go back with him, he’s a good guy,” because her daughter was just in a coma! She doesn’t really care if her daughter is in a relationship or not at this point…We’re focused on the fact that Emily has been through a lot and this isn’t just Kumail’s story, it’s also her story as well.

Eric Kohn and Anne Thompson contributed to this report.

Sign Up: Stay on top of the latest breaking film and TV news! Sign up for our Email Newsletters here.