Dick Clark underwent prostate surgery the day before he died from a heart attack ... this according to the death certificate obtained by TMZ.
According to the death certificate, doctors performed a transurethral resection of the prostate for benign prostatic hyperplasia on April 17. The procedure is usually performed when the prostate is so enlarged, it makes it extremely difficult to urinate.
The certificate shows ... Clark died from acute myocardial infarction -- the technical term for a heart attack. He also suffered from coronary artery disease.
The document also notes that Clark suffered from acute urinary retention -- a condition caused by a benign prostatic hyperplasia ... which is why he underwent surgery on the 17th.
TMZ broke the story ... Clark died from a massive heart attack at St. John's Hospital in Santa Monica on April 18. He was 82.