Rio de Janeiro (AFP) - Pulling in at one of Rio's swishest buildings, the driver of the blue luxury car turns on the blinkers, pauses for the security gate to open -- and suddenly is staring into the barrel of a gun.

A man in a dark top runs up, pointing the firearm at the side window. Two more assailants yank open the doors and grab items before all three flee, and the car continues toward the garage.

Twenty seconds have passed on the security camera footage. And the crime statistics for one of the most tourist-friendly neighborhoods in this Olympic host city have just risen another notch.

Deadly violence in Rio de Janeiro's poorest areas, known as favelas, has been famous internationally at least since the hit Brazilian film "City of God" in 2002.

But while the half million tourists and 10,500 athletes expected to attend the Olympics starting August 5 will be cautious about entering favelas, there are growing fears for their safety in even the fanciest areas of the city.

The car hold-up occurred last week outside an imposing residence called the Diamond Tower, near the beach in ultra-chic Ipanema. A similar armed attack in the same street a month ago made waves because the daughter of Rio state's acting governor was in the car.

For the increasingly weary inhabitants of privileged neighborhoods, violent crime is no longer something that happens to others.

"We're afraid of going to the bank to get money. At night we don't feel safe. It's so sad, we have a country without authority or laws," said Tito Martis, a 75-year-old Ipanema resident, waving a rolled up newspaper in anger. "It's brutal and absurd."

- Olympians at risk? -

About 85,000 soldiers and police will be deployed in Rio for the Games, twice as many as at the 2012 London Olympics. But it is unclear how effective they will be in a city sometimes resembling the Wild West.

Automatic weapons battles often erupt between police and drug traffickers. Although isolated to favelas, these clashes can be only blocks away -- within stray bullet range -- from the supposedly quiet zones where Olympians and tourists will congregate.

Story continues

Recent firefights have taken place near the Athletes' Village in Barra and in Chapeu Mangueira, near Copacabana, which will host the beach volleyball and several other competitions. An hours-long confrontation involving heavy exchanges of automatic fire took place last weekend in the Rocinha favela, near Ipanema.

Some Olympic teams will make a point of visiting favelas, often to boost local NGOs bringing sport to deprived communities. However these visits are likely to be tightly controlled.

Australia however has gone so far as banning its athletes from favelas altogether.

Richer Rio residents tend to shrug at the fate of favela dwellers, who run the biggest risks from gun violence. But the danger is spilling out.

Last weekend, three members of the Spanish Olympic sailing team were robbed at gunpoint by five youths in Santa Teresa, one of Rio's most picturesque and tourist friendly areas. In February an Argentine tourist was murdered while being mugged on Copacabana beach.

And gun-toting thieves regularly raid major highways north of the city, meaning that anyone can stumble into crossfire.

Few would go as far as former Brazilian football star Rivaldo, who this month urged foreigners to "stay in your country. Here your life is in danger."

But the fear is real.

- 'Prisoners at home' -

Ipanema, just like other wealthy areas of Rio, boasts glitzy shops and residential buildings with fanciful names like the Golden Dune. But the rich live behind tall fences, bars and barbed wire.

During the Olympics "we'll be the prisoners in our houses instead of the bandits," said model Beth Grego, 64, as she walked with her friend Gilse Prates, a 39-year-old doctor.

"Fifteen years ago here I'd come home at night and I wouldn't have a problem. Now I'd never come back by bus alone," Prates said.

The two, both of them carrying large Louis Vuitton handbags, said that not walking alone, keeping your bag in front, and taking taxis instead of public transport are now standard practice.

Although Brazil has long been one of the world's most violent countries, budget problems after years of financial decline appear to be eating into police numbers just when they are most needed.

A study by Globo news found that of the 47,500 street cops in Rio state, only about half are available for day-to-day beats due to deployments to favelas, medical leave and other factors.

With Rio state in financial freefall, funds are running short for overtime and even for patrol car fuel, according to Brazilian media.

And that thin line of officers has to deal with shocking casualties.

By mid-May, 39 police officers had been killed this year in Rio state -- two thirds of them while off duty -- the Estadao daily reported. For all 2015 the figure was 85.

Rio's state security chief Jose Mariano Beltrame is calling for more soldiers, saying that they could guard transport routes during the Olympics.

"Our idea is to free up the police for their primary function, which is public security and looking after the tourists," he told O Dia daily.