int main() {
  void *nextstate = &&Loop;
  int x = 0;
  int acc = 0;
  int count = 5;
Loop:
  if (x == 10)
    nextstate = &&Done;
  acc += x;
  x++;
  goto *nextstate;
Done:
  if (acc != 11 * 10 / 2) {
    printf("Bad result: %d\n", acc);
    return 1;
  }
  if (count <= 0)
    return 0;
  acc = 0;
  x = 0;
  nextstate = &&Loop;
  count--;
  goto *nextstate;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0x19(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x5,-0x1c(%rbp)
cmpl   $0xa,-0x14(%rbp)
jne    1154 <main+0x44>
lea    0x23(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e8 <main+0xd8>
cmpl   $0x37,-0x18(%rbp)
je     119a <main+0x8a>
mov    -0x18(%rbp),%esi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11df <main+0xcf>
cmpl   $0x0,-0x1c(%rbp)
jg     11b0 <main+0xa0>
movl   $0x0,-0x4(%rbp)
jmp    11df <main+0xcf>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x86(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e8 <main+0xd8>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x28(%rbp),%rax
jmp    *%rax

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x5,%ecx
xor    %eax,%eax
lea    0x21(%rip),%rdi
cmp    $0xa,%eax
lea    0x27(%rip),%r8
mov    %rdi,%rdx
cmove  %r8,%rdx
lea    (%rax,%rax,1),%esi
add    $0x1,%eax
jmp    *%rdx
nopl   0x0(%rax,%rax,1)
cmp    $0xa,%eax
cmove  %r8,%rdx
add    %eax,%esi
add    $0x1,%eax
jmp    *%rdx
xchg   %ax,%ax
cmp    $0x37,%esi
jne    1167 <main+0x57>
xor    %eax,%eax
test   %ecx,%ecx
jle    117a <main+0x6a>
add    $0xffffffff,%ecx
xor    %esi,%esi
mov    %rdi,%rdx
xor    %eax,%eax
jmp    *%rdi
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Bad result: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i8* blockaddress(@main, %6), i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 5, i32* %5
br label %6
6: ; preds = %33, %0, %33
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, 10
br i1 %8, label %9, label %10
9: ; preds = %6
store i8* blockaddress(@main, %17), i8** %2
br label %10
10: ; preds = %9, %6
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = add nsw i32 %12, %11
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
store i32 %15, i32* %3
%16 = load i8*, i8** %2
br label %33
17: ; preds = %33
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 55
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %21)
store i32 1, i32* %1
br label %31
23: ; preds = %17
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 0, i32* %1
br label %31
27: ; preds = %23
store i32 0, i32* %4
store i32 0, i32* %3
store i8* blockaddress(@main, %6), i8** %2
%28 = load i32, i32* %5
%29 = add nsw i32 %28, -1
store i32 %29, i32* %5
%30 = load i8*, i8** %2
br label %33
31: ; preds = %26, %20
%32 = load i32, i32* %1
ret i32 %32
33: ; preds = %27, %10
%34 = phi i8* [ %16, %10 ], [ %30, %27 ]
indirectbr i8* %34, [label %6, label %17, label %6]
}

LLVM IR (-O2):
@.str = [16 x i8] c"Bad result: %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %20
%2 = phi i8* [ blockaddress(@main, %1), %0 ], [ %24, %20 ]
%3 = phi i32 [ 0, %0 ], [ %21, %20 ]
%4 = phi i32 [ 0, %0 ], [ %22, %20 ]
%5 = phi i32 [ 5, %0 ], [ %23, %20 ]
%6 = icmp eq i32 %3, 10
%7 = select i1 %6, i8* blockaddress(@main, %10), i8* %2
%8 = add nsw i32 %4, %3
%9 = add nsw i32 %3, 1
br label %20
10: ; preds = %20
%11 = icmp eq i32 %22, 55
br i1 %11, label %14, label %12
12: ; preds = %10
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %18
14: ; preds = %10
%15 = icmp slt i32 %23, 1
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = add nsw i32 %23, -1
br label %20
18: ; preds = %14, %12
%19 = phi i32 [ 1, %12 ], [ 0, %14 ]
ret i32 %19
20: ; preds = %16, %1
%21 = phi i32 [ %9, %1 ], [ 0, %16 ]
%22 = phi i32 [ %8, %1 ], [ 0, %16 ]
%23 = phi i32 [ %5, %1 ], [ %17, %16 ]
%24 = phi i8* [ %7, %1 ], [ blockaddress(@main, %1), %16 ]
indirectbr i8* %24, [label %1, label %10]
}