What if I'm wiped out battling against the legendary Pokémon?
If you got wiped out by your legendary during the story, renter the Cave of Origin. On the second floor when going down, there is the normal stair-case, as well as another entrance to the west. Take the entrance and keep going downwards that way. You should eventually be able to encounter your respective legendary in another room.
Source: thanks to the user "[Dark Star] Greninja" on pokemondb.