Compilation of cum-swapping