IR: now using the state monad to keep track of the temporaries