int main() {This way of writing C is quite similar to assembly--in fact, there's a one-to-one correspondence between lines of C code written this way and machine language instructions. More complicated C, like the "for" construct, expands out to many lines of assembly.
int i=0;
if (i>=10) goto byebye;
std::cout<<"Not too big!\n";
byebye: return 0;
}
int i=0;(executable NetRun link)
start: std::cout<<"In loop: i=="<<i<<"\n";
i++;
if (i<10) goto start;
return i;
Normal C |
Expanded C |
if (A) { ... } |
if (!A) goto END; { ... } END: |
if (!A) { ... } |
if (A) goto END; { ... } END: |
if (A&&B) { ... } |
if (!A) goto END; if (!B) goto END; { ... } END: |
if (A||B) { ... } |
if (A) goto STUFF; if (B) goto STUFF; goto END; STUFF: { ... } END: |
while (A) { ... } |
goto TEST; START: { ... } TEST: if (A) goto START; |
do { ... } while (A) |
START: { ... } if (A) goto START; |
for (i=0;i<n;i++) { ... } |
i=0; /* Version A */ goto TEST; START: { ... } i++; TEST: if (i<n) goto START; |
for (i=0;i<n;i++) { ... } |
i=0; /* Version B */ START: if (i>=n) goto END; { ... } i++; goto START; END: |