Implement multi-pass optimization: some of the variables might be avoided and inlined after the first pass