Implement multi-pass optimization: some of the variables might be avoide...

...d and inlined after the first pass