After a four-year break, Rick Shapiro is back at Edinburgh this month.

The comedian is booked in for 26 dates at Assembly George Square, but right now it's late July, a few days before he flies to Scotland, and I'm a little worried that he's not even going to get through this interview. It's about one in the afternoon in Los Angeles and he's talking to me down the phone. Except talking might be too kind a description. His words are slightly slurred. That's when they come. There are these huge pauses between them as he struggles for what he wants to say, and every so often I hear him turn to his manager Tracy for prompting. As I listen to him, I'm thinking: "This guy is going to be on stage next week? Really?"

When we finish talking, his physiotherapist Lance, "who looks like a lance", is coming over, Shapiro says, "to kick my ass". Seems like life has been kicking the comedian's ass for the past five years. Five years ago, Shapiro was involved in a serious car accident. He suffered severe head injuries, which left him with amnesia. His Edinburgh show is called Rebirth and comes after four years of intensive physical and mental rehabilitation. Not enough, I'm thinking right now, but he says he's looking forward to it. "I don't know if you know I had a little thing happen, so it'll be interesting. I know on stage I'm great. I'm still fine. I'm great, I'm fine, I'm great, I'm fine," he repeats himself like a stuck record for a moment and then the needle jumps. "But on stage the pain comes up. But I should be fine. I'm ready to have a really good time."

It's only in the middle of this exchange that I realise he's not actually talking about the crash. "The car accident? No, that was a few years ago." He pauses, turns to Tracy for help before adding: "2007." But that's not what's kicking his ass today. No, turns out it's a heart thing. "I'm not too sure what was happening. Medications clashed and there was an infection in my heart. It was like everything just gave. My body had enough. I'd been working every night for years and years and then they added an anti-depressant and it didn't match the other one. They called it a myocardial event." When was this? "April 13." He doesn't have to ask about that date. He must have broken a lot of mirrors, I say. He laughs. "I know. That must be it."

Shapiro, for those who don't know, is on the wild and crazy end of the comedy spectrum, "a sort of punk-rock, white Richard Pryor ... part Iggy Pop, part Philip Roth," according to one reviewer (and yes, he has inhaled. And a lot more.) In the past he's joked about everything. As in EVERYTHING. 9/11, paedophilia, Aids. Check, check, check. In short, he's not a cosy night out. In Edinburgh this August, what can we expect?

"The unexpected." Do you know what to expect, Rick? "I have no idea."

He loves the city though, loves the way that it takes comedy seriously. "That's where I met people who have passion for comedy instead of gym muscles."

He's talking more coherently, making jokes, not seeking help. He reckons he's in better shape than he was when he started performing after the accident. "I went back against my manager's orders and I did weird things. I'd bring a lamp on stage and call it my girlfriend. And if someone said it was a lamp I would jump into the audience and I would fight. And I don't do stuff like that. I wasn't getting calls to come back to Edinburgh and now I'm called to come back." He sounds triumphant.

Has his memory returned? "It's all back. Unless I conveniently don't want to remember somebody." Given all that he's gone through, I wonder, does he think he's a different person now? "No ... yeah ... I think it's made it more complex. And fun, actually. I know that there is a zone where you can have even less punchlines than I've ever had. I was never big on punchlines. I can call attention to things and take more risks." It's hard to imagine how many more risks he could take, frankly.

Who makes him laugh? He hums and haws and throws a few names at me. Jim Jefferies, Paul Provenza, our own Janey Godley. "But it's hard to say because I'm narcissistic and I focus on my own work. I have to make sure I make myself laugh."

The more he talks, the better he gets at it. He's like an old engine that just needs to idle for a while to make him run steadily, if a bit roughly. We discuss the Aurora shooting. "It's mind-boggling. Do these people wake up evil? When they're in their pyjamas do they wake up like vulnerable human beings and then become evil, or do they wake up with a roar?" he asks. "I think there's got to be a solution between Occupy and a handgun."

Time is moving on. I'm aware that Lance is due soon for some ass-kicking ("I never thought I'd become the guy who did football exercises," Shapiro says with a chuckle). He sounds more a lot normal now. Does he feel it? "For sure. It's weird. My shows are great but I'm so uncomfortable after the show. I'm hoping that doesn't interfere with me having a really great time in Edinburgh."

Rick Shapiro is back. All being well.

Rick Shapiro – Rebirth is at Assembly George Square until August 27.