gen: cleanup tmp handling and fix regs array in o_swap()