Repsol swings to loss as asset impairments bite