inversion optimization technique applied to while loops
+ correcting array update codegen