BUENOS AIRES, Argentina — Argentines desperately searched hospitals Thursday in hopes that loved ones survived a train crash that killed 50 people and sent hundreds to emergency rooms. A stunned government declared two days of mourning, with flags flying at half staff across the nation.

A federal judge was leading an investigation into what caused the rush-hour commuter train to slam into a barrier at the end of the track at a downtown station, crumpling cars around 1,500 panicked riders on Wednesday.

Passengers said the train’s motorman struggled repeatedly with the brakes during the journey, overrunning platforms and missing one station entirely before crashing at the end of the line.

But the nation’s auditor general and other critics said official inaction could have contributed to the accident, noting that the private Trains of Buenos Aires company failed to meet safety requirements despite years of warnings.

“Back in 2008 we had verification of dramatic and alarming brake problems,” said the auditor, Leandro Despouy. He called the accident foreseeable and preventable, noting that repeated audits had recommended ending the concession the company has held had since 1995.

The motorman, Marcos Antonio Cordoba, 28, is a five-year veteran with a good record who should have been rested because it was his first trip of the day. He remained in intensive care Thursday and had yet to make a statement, but Transportation Secretary J.P. Schiavi said investigators will also be able to pinpoint the cause through GPS devices, cameras and recordings of the motorman’s conversations with .

The city’s emergency medical director, Alberto Crescenti, praised rescuers who had to use vaseline and oil to pull the living and dead from a tangle of limbs and metal in the collapsed space where the momentum of the train shoved the first two cars together. It took hours to separate the bodies of more than a hundred people who were compressed into a few square feet (meters).

“The image of all those people pleading with us to pull them out was very powerful,” Crescenti said.

Emergency workers sent the injured to a dozen hospitals around Buenos Aires, and in the confusion, thousands of people were unsure whether their family and friends had survived, sending them on a frantic search of the city’s hospitals and morgues. Many complained that the names they sought didn’t show up on any lists of survivors, injured and dead.

“I’m sure my daughter is a ’Name Unknown’ in some emergency room,” Viviana Acevedo, 51, said outside the judicial system’s morgue after a fruitless search for Sabrina Espindola, 29.

Hours later, they learned Sabrina was dead. Her body had been pulled from the first car, said her husband, Ezequiel Mercado.

“She was studying to become a surgical instrument maker,” he said, sobbing. “She was getting her degree this year.”

Mirta Soria had hoped her that 19-year old niece, Sofia Peralta, lost her wallet in the crash and was laying unidentified in some hospital. “I am tired, and just have to keep going. I am waiting, and waiting, hoping that she is here,” she said.

But later, Peralta also was identified among the dead. “We just learned the worst thing,” she texted to a reporter Thursday. “Sofi’s body was found at the morgue.”

Scores of other families kept checking lists of the injured — 703 according to Thursday’s tally — posted at hospitals and the Once de Septiembre station.

At the Ramos Mejia Hospital in the city’s Balvanera neighborhood, close to the crash scene, Oscar Cesar Zapiola, spent all day and night searching for his 14-year-old niece, Carina Mariela Altamirada, who had been on the Sarmiento Line train.

“I went to 11 hospitals. I started here, and ended here” at the same hospital, Zapiola said. “I have no information. I do not want to go to the morgue. It is the last place.”

At the relatively small Hospital Bernardino Rivadavia, emergency room chief Guillermo Aiello said that all nonessential medical appointments were canceled as hospitals struggled to deal with the scope of the tragedy. His emergency room alone treated 102 people.

Official condolences came in from around the world. Pope Benedict XVI said he was “profoundly distressed” by Argentina’s deadliest train accident in decades. President Evo Morales of Bolivia also offered his support. Many Bolivians live in Buenos Aires and use the Sarmiento train line, including a pregnant consular official who was killed, Nayda Tatiana Lezano Alandia.