Structure _Do-While_ Statement
- You have a conditional jump to a previous label.
Make the intermediate statements the body of a do-while loop.
next: /* loop */ ... if(cond) goto next;
⇓
do { /* loop */ ... } while(cond);
Motivation
Do-while statements (and sometimes other kinds of loop statements) are translated as conditional back jumps. This refactoring recovers those original control structures.
Mechanics
Make the set of skipped statements the body of the do-while statement.
Make the jump condition the condition of the while clause.
- Remove the label, if no longer used.