How is retreating through obstacles handled in Memoir '44?
As long as the terrain isn't Impassable, you can retreat through terrain without penalty.  

From the Retreat rules, page 10 (emphasis mine):


The player controlling the unit decides which hex his unit retreats onto using the following rules:
A unit must always retreat toward its controlling player’s side of the board.
Terrain has no effect on retreat moves, therefore a retreating unit may move through a forest or village without stopping. However, impassable terrain may not be moved through during a retreat move.
A unit may not retreat onto, or through, a hex already containing another unit (regardless if friend or foe).
If a unit cannot retreat; is forced to retreat off the limits of the battlefield; or would be pushed back onto a sea hex, one figure must be removed from the unit for each retreat move that cannot be completed.
Some obstacles will allow certain units to ignore the first flag rolled against them.


Since the Barbed Wire terrain type isn't impassable, you can retreat through the Barbed Wire without stopping.  

In your case the answer would be 3: some other thing.  Specifically, you would retreat twice from the two flags and keep all of your units, assuming you can satisfy all other retreat conditions.