(CNN) -- It is a gruesome scene, even in a country that has seen its share of violence: three men, beheaded, with wounds peppering their bodies on all sides.
The most surprising part? The attack happened inside a jail.
A Brazilian newspaper on Tuesday released a video of this stomach-turning scene inside the Pedrinhas jail in Brazil's northeastern state of Maranhao.
The video was recorded on December 17, the Folha de Sao Paulo newspaper reported, describing how "other prisoners pose with the bodies, showing them off like trophies."
A union of jail workers gave the gory footage to the newspaper.
Many will view the video simply for the shock value, but behind this incident is a myriad of problems in the Brazilian penal system that allow an environment where something like this could unfold.
The Pedrinhas jail was already under scrutiny even before the video was made public.
A judge visited the jail just days after the decapitations and wrote a report demanding that the state government regain control of the inmate population.
In all, 62 inmates were killed inside Pedrinhas in 2013.
The judge, Douglas Martins, also documented violence against women, saying that female visitors were forced to have sex with the leaders of gangs inside the prison.
"The relatives of the powerless prisoners inside the jail are paying this price so that they won't be murdered," Martins told Brazil's judicial news agency. "It is a serious violation of human rights."
Overcrowding is also a problem at this jail. There are 2,196 inmates at Pedrinhas, which was built to hold only 1,770, according to state jail officials.
At the root of the violence at Pedrinhas is fighting between two rival factions -- inmates from the state's capital, and inmates from the interior of the state.
In response, the federal government this week reached an agreement with the state to transfer the leaders of these warring factions to federal prisons, the state-run Agencia Brasil news agency reported.
The woes at Pedrinhas are not unique to Maranhao state.
Overcrowding and violence in jails are a problem in other parts of Brazil, as well as throughout Latin America.
Along with the video, Folha de Sao Paulo identified the three decapitated inmates: Diego Michael Mendes Coelho, 21; Manoel Laercio Santos Ribeiro, 46; and Irismar Pereira, 34.