generate code: while loop