In a small courthouse north of Mosul, Mohammad Dawd, 27, sits on the floor in the hall facing a wall, like other prisoners.
The hands of some of the prisoners are bound, but Dawd's are not. One man prays. Mosul was once the Islamic State militants' most prized stronghold in Iraq, and now more than 4,000 suspects are being tried for terrorism here.
Human rights groups have criticized Iraqi courts for hastily trying masses of detainees under broad laws that often carry the death penalty. But officials here say with thousands of people in custody and limited resources they are doing their best to swiftly punish the guilty and release the innocent.
IS lost nearly all of its self-described "caliphate" in Iraq and Syria, but attacks continue and tens of thousands of suspected militants remain at large in an area that was very recently a war zone, says Chief Judge Ra'ad Hamid Hussein at the court.
"We face too many challenges to name," Hussein says. "Sometimes the suspects even give fake names."
A typical case
Dawd's trial, one of four that day, takes less than 30 minutes and judges say the quick proceedings follow months of investigations. Dawd, like many other prisoners, claims he was tortured during the investigation and forced to confess to crimes he did not commit.
"The investigator threatened to kill me," he tells a panel of three judges in black robes.
Neither Dawd nor his lawyer offers any other defense. He is accused of fighting in Ramadi and Mosul for IS, with a salary equivalent to $225 (266,000 Iraqi dinar) per month. Dawd's head drops to his chest as the judge reads the confession and asks Dawd to respond.
"Why would the investigative judge make up so many details if he didn't know you?" asks Judge Jamal Dawd Sinjari.
The confession is again entered into the record and Dawd's lawyer asks for his client to be released for lack of evidence. The courtroom is cleared.
The sentence
Compared to most of the gaunt-looking prisoners sitting and facing the walls, Dawd appears strong and fit. His sweatshirt bulges out of his dirty yellow prison jumper.
After a 10-minute wait, a guard ushers Dawd, his lawyer and a few spectators back into the room where a judge reads the sentence. "I sentence you to be hanged until you are dead," he says.
If Dawd is shocked or scared, the emotion does not register on his face. He is the second that day to be sentenced to die. The other condemned man also appeared calm on hearing his sentence earlier in the day.
"Many of them have seen a lot of fighting," Judge Sinjari later says. "Their hearts are dead and they know what they are going to hear."
The judge explains that an automatic appeal of Dawd's case will be sent to Baghdad for review by 30 judges and the sentence may be upheld, cancelled, or reduced to 10 or 15 years in prison under Iraqi counterterrorism laws. A guard quickly escorts Dawd out of the courtroom.
Condemned for membership
The United Nations has condemned the application of the death penalty in Iraq in general. Following mass executions of convicted militants this fall it said, "The Iraqi justice system as a whole is too flawed to allow for any executions."
Human Rights Watch says because Iraqi terrorism laws can condemn suspects for IS membership alone, the trials threaten to overly punish non-violent offenders.
At the courthouse, Judge Sinjari defends the law, saying, "Their leader told all members to fight when Iraqi forces closed in on them. So if they had sworn loyalty, they fought."
This distinction is made clearer as more suspects are brought in. Mohammad Hani, 29, a tall and lanky former medical student, is accused of fixing computers for IS militants. He doesn't claim his confession was forced.
"The militants brought their computers to my shop; I fixed three of them," Hani says. "I couldn't say no to them. A month later, I closed the shop. They broke in, took most of the things and blew it up."
At the sentencing, the judge agrees. "Since you had a computer shop before IS, we have no evidence you were a member. It is your right to go free," Judge Sinjari says.
Two days later, another man receives a 15-year prison sentence for being a traffic cop under IS. Because the man was not in that job beforehand, judges say his new position and his confession show he was an IS member.
"You can appeal the case in 30 days," adds Sinjari, as the defendant, appearing stunned, tries to interrupt with protests. A guard steps in and quietly escorts him out of the room.
"Most sworn IS members fought with IS, even if that wasn't their man job," Sinjari says.