Rapid recovery of program execution under power failures for embedded systems with NVM