Please don't blame yourself. As Emz says, you did the best you could with the information you had at the time. Your friend only felt unwell when he woke you. He didn't know he was going to have a heart attack either, so how could you?
My dad had a heart attack and phoned me from work to go and pick him up as he didn't feel well. He insisted on coming home rather than letting me take him to the hospital as thought he would feel better if he just rested for a while. Neither of us knew he had had a heart attack. By the time he did decide he ought to let me take him to hospital, much of the damage was done and he only lived for another three months, then had another and that one killed him. Again, we had no idea it was going to happen and neither did he. I just walked into the bedroom and found him lying on the bed. He was already gone.
You cannot see into the future. You cannot do more than what you think is right at the time. You did basic life support well. I have been trained in that and I know that if you break the ribs, it mean that you are doing it hard enough to work, rather than not hard enough, so you did your best. It is just a fact that even with life support help, only a small percentage of people survive. You didn't do anything wrong. It just wasn't meant to be. You really shouldn't be beating yourself up about this.
I know we all do the thing of thinking what if I had done this or that or if only I had done this or that, but that is part of the guilt all of us experiences when something hasn't turned out as we would have hoped. The truth is that sometimes the worst happens despite our best efforts and would have done even if we had done whatever we wish we had done anyway. Don't blame yourself. You did do your best for your friend. Sadly, this time it was never going to have been enough. You are not to blame.