FBI Director James B. Comey prepared extensively for his discussions with President Trump, out of concern that the president was unlikely to respect the legal and ethical boundaries governing their respective roles, according to associates of the now-fired FBI chief.

The associates recounted how worried Comey was about meeting with Trump and recalled conversations in which they brainstormed how to handle moments in which the president asked for details of an investigation.

One associate referred to Comey’s preparation as a kind of “murder board” — a phrase used to describe a committee of questioners that hurls tough questions at someone as practice for a difficult oral examination.

“He was pretty insistent that he would have to find a way to politically not answer it,” one associate recalled. “He was confident that he was not going to sacrifice the independence of the investigation, or his own moral compass, but at the same time, he would not try to purposely inflame his commander in chief.”

The president abruptly fired Comey on May 9, raising questions about whether he was attempting to interfere in the ongoing FBI probe into possible coordination between Trump associates and Russian operatives seeking to meddle in last year’s presidential election.

Comey was very apprehensive heading into a dinner with the president in late January, because of his previous encounters with Trump during the transition and immediately after the inauguration, according to one associate. Comey felt as if Trump did not understand or did not like the FBI director’s independence and was trying to get Comey to bend the rules for him, the associate said.

White House officials have disputed the accuracy of a memo Comey wrote describing what was said at the January dinner. In it, associates said, Comey described an effort by the president to get him to drop the investigation into former national security adviser Michael Flynn.

[Notes made by FBI Director Comey say Trump pressured him to end Flynn probe]

In his preparation for meeting Trump, Comey made clear to associates that he wanted to be responsive to the president’s questions while declining to discuss sensitive subjects “in a manner that did not come across as a slap in the face,’’ said the associate, who, like others, spoke on the condition of anonymity to discuss internal deliberations.

The FBI declined to comment, and the White House did not immediately respond to a request for comment.

Before going to the dinner, Comey practiced Trump’s likely questions and his answers with a small group of his most trusted confidants, the associates said, in part to ensure he did not give Trump any ammunition to use against him later.

The director did not take notes during the dinner with the president, but there were times, one associate recalled, when after meeting with Trump, Comey started writing notes as soon as he got into a car, “to make sure he could accurately record what was said.’’

Another associate said the notes of the January dinner conversation contained very nuanced quotes from the president and a high level of detail.

Read more:

Trump said he was thinking of Russia controversy when he decided to fire Comey

Comey associates dispute Trump’s account of conversations

The events leading up to Comey’s firing