Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

A South Carolina psychologist tried to intervene with Dylann Storm Roof four months before Roof killed nine black worshipers at a Charleston church in 2015, but the attempt failed, according to newly unsealed federal court documents.

Roof, 22, who is white, was sentenced to death last month after his conviction on 33 federal hate crime charges in the massacre on June 17, 2015, at Emanuel African Methodist Episcopal Church, known as Mother Emanuel, one of the nation's oldest and most revered historically black congregations.

According to some of the more than 170 previously secret documents unsealed this week by U.S. District Judge Richard Gergel, several medical and psychological specialists concluded that Roof suffered from a variety of mental disorders. They include depression, social anxiety disorder and substance abuse, as well as possible autistic spectrum disorder, according to the documents.

Police lead suspected shooter Dylann Roof into court after his capture in Shelby, North Carolina, on June 18, 2015. Jason Miczek / Reuters file

A court-appointed psychologist concluded that Roof's "high IQ is compromised by a significant discrepancy between his ability to comprehend and to process information and a poor working memory," according to one of the documents, which was filed shortly before his trial began in December.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

More dramatic was the intended testimony of Dr. Thomas Hiers, a board member and former director of the Charleston/Dorchester Community Mental Health Center.

In February 2015, four months before the shootings, Hiers stumbled upon a post on Craigslist by a young man seeking companions to visit Charleston for "a historical tour," according to a document that informed the judge about what Hiers would say were he called to testify.

According to the document, the ad specified "no Jews, queers, or [N-words]."

Hiers, a retired child psychologist, was deeply concerned by the ad and tracked Roof down, striking up a correspondence in order to offer help, according to the court document. But Roof continued to make racist and anti-semitic comments in their correspondence and politely declined Hiers's offer to pay him to watch online TED Talks as a way to expand his view of the world.

According to the document, Roof told Hiers that he considered him a "nice man" but that he couldn't accept the offer because "I am in bed, so depressed I cannot get out of bed."

Dylann Roof speaks in court in Charleston, South Carolina, on Jan. 10. Robert Maniscalco

"My life is wasted," Roof wrote to Hiers, according to the court document. "I have no friends even though I am cool. I am going back to sleep."

Hiers didn't give up, seeking out a "very experienced professional colleague" in Columbia, near where Roof lived, to try to set up a lunch meeting. Roof never responded, according to the court document.

Four months later, Roof showed up at Mother Emanuel, sat politely through a prayer service and then opened fire.

Roof, who represented himself at times during his prosecution and trial, didn't want the mental assessments to become known. He blocked his standby lawyers' efforts to get the assessments presented, so they were sealed, and the jury that convicted Roof never heard about them.

Roof still faces a second trial, by the state of South Carolina, at which he also faces the death penalty. A trial date hasn't been set.