SAN JOSE — Mentally ill inmate Michael Tyree suffered at least 34 separate injuries — cuts, bruises and a torn liver and spleen, from his skull down to his ankles — before he bled to death in his cell, a Santa Clara County medical examiner testified Monday.

In painstaking detail, Dr. Joseph O’Hara Tyree recounted the extensive damage Tyree allegedly sustained at the hands of three jail guards accused of second-degree murder in his Aug. 26, 2015, death and of assaulting another mentally ill inmate, Juan Villa, earlier that same evening.

The guards — Jereh Lubrin, Rafael Rodriguez and Matthew Farris — have pleaded not guilty, denying that they beat Tyree so thoroughly for mouthing off to a nurse that his spleen was nearly torn in half.

Instead, their lawyers contend the 31-year-old bipolar inmate sustained most of the injuries on the front, back and sides of his body from falling 3 feet or so off his cell sink, either accidentally or intentionally.

O’Hara said the cause of Tyree’s death was blunt force injuries, and the manner was homicide.

“He died a painful death,” O’Hara said, adding that Tyree first vomited and then lost control control of his bowels, before passing out from internal bleeding and dying within five to 50 minutes after being injured.

O’Hara spent most of the day describing Tyree’s injuries in graphic detail, as prosecutor Matt Braker showed grisly autopsy photographs to jurors for the first time since the trial started in Santa Clara County Superior Court about six weeks ago. However, because most of his injuries occurred so close to the time of death, they appeared deceptively minor because they didn’t have time to turn a livid blue or purple, the doctor told the jury.

Correctional deputies are trained to try to avoid hitting inmates in the head. But Tyree sustained cuts and bruises to his eyebrow, cheek, chin and the soft tissue under his skull, consistent with being hit with a blunt object or slammed up against a cell wall, O’Hara said.

However, a shallow laceration and hemorrhage to Tyree’s heart could have been caused by multiple guards and medical staffers aggressively trying to revive his lifeless body using CPR, O’Hara said.

The blank-faced guards looked on Monday as Braker played video clips showing the desperate attempt to revive Tyree. Each time the left side of the nude inmate’s chest was pressed down, his stomach rippled, as the blood and fluid from his massive internal injuries moved like a wave through his abdomen, O’Hara said. Tyree lost 40 to 50 percent of his blood from his lacerated liver and spleen, the doctor said.

A constellation of bruises on Tyree’s back could have come from a boot, O’Hara said.

The guards’ lawyers have suggested that some of the abrasions on Tyree’s body could have come from him scratching or picking at his own skin. But O’Hara said Tyree had no body lice and the injuries did not appear to be self-inflicted.

However, under cross examination by Lubrin’s attorney, Judith Odbert, the doctor conceded that it is possible that Tyree’s liver, which was also torn, could have been damaged during CPR.

Odbert also made much of the writing on Tyree’s cell wall, suggesting that the religious references about forgiveness may have been tantamount to a suicide note he wrote before throwing himself off the sink.

Braker has argued it’s unclear when the writing appeared and who scribbled on the wall. But Odbert persuaded Judge David A. Cena to let her bring in another jail guard who she says will testify that the wall was scrubbed earlier in the day, meaning Tyree was the only one who could have written on it.

If convicted, Farris and Rodriguez, both 28, and Lubrin, 30, could be sentenced to life in prison. They are free on $1.5 million bail each and on paid administrative leave.

The prosecution doesn’t have to prove they intended to kill Tyree, only that his death was caused by their dangerous conduct and reckless disregard for human life.

O’Hara is set to continue testifying Tuesday.