void test_computed_goto() {
  struct {
    void *x, *y, *z, *a;
  } t = {&&x, &&y, &&z, &&a};
  int acc = 0;
  goto *t.x;
  acc = 5;
x:
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/control.c",
          247, 0, acc);
  ;
  int i = 0;
  acc = 0;
y:
  if (i > 10)
    goto *t.z;
  acc += i++;
  goto *t.y;
z:
  if (i > 11)
    goto *t.a;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/control.c",
          255, 55, acc);
  ;
  i++;
  goto *t.y;
a:;
  static void *p = &&L;
  goto *p;
L:;
}


x86 assembly (clang, -O0):
<test_computed_goto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2ce1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cde(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2cdb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2cd8(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
mov    -0x24(%rbp),%ecx
lea    0xe9e(%rip),%rdi
mov    $0xf7,%esi
xor    %edx,%edx
mov    $0x0,%al
call   1030 <fexpect@plt>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0xa,-0x28(%rbp)
jle    1195 <test_computed_goto+0x85>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
mov    -0x28(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x28(%rbp)
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
cmpl   $0xb,-0x28(%rbp)
jle    11ca <test_computed_goto+0xba>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
mov    -0x24(%rbp),%ecx
lea    0xe2c(%rip),%rdi
mov    $0xff,%esi
mov    $0x37,%edx
mov    $0x0,%al
call   1030 <fexpect@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
mov    0x2e26(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    1211 <test_computed_goto+0x101>
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x30(%rbp),%rax
jmp    *%rax

x86 assembly (clang, -O2):
<test_computed_goto>:
push   %rbp
push   %r14
push   %rbx
lea    0x15(%rip),%rax
xor    %r14d,%r14d
xor    %ebx,%ebx
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xec9(%rip),%rdi
mov    $0xf7,%esi
xor    %edx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fexpect@plt>
lea    0x1(%r14),%ebp
lea    (%r14,%r14,1),%ebx
lea    0xa(%rip),%rax
jmp    *%rax
nopl   0x0(%rax,%rax,1)
lea    0x19(%rip),%rax
cmp    $0xa,%ebp
jg     11b2 <test_computed_goto+0xa2>
add    %ebp,%ebx
add    $0x1,%ebp
lea    -0x18(%rip),%rax
jmp    *%rax
nopw   0x0(%rax,%rax,1)
lea    0x39(%rip),%rax
cmp    $0xb,%ebp
jg     11b2 <test_computed_goto+0xa2>
lea    0xe6d(%rip),%rdi
mov    $0xff,%esi
mov    $0x37,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fexpect@plt>
add    $0x1,%ebp
lea    -0x50(%rip),%rax
jmp    *%rax
jmp    *%rax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x2(%rip),%rax
jmp    *%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.anon = type { i8*, i8*, i8*, i8* }
@__const.test_computed_goto.t = %struct.anon { i8* blockaddress(@test_computed_goto, %7), i8* blockaddress(@test_computed_goto, %10), i8* blockaddress(@test_computed_goto, %23), i8* blockaddress(@test_computed_goto, %36) }
@.str = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/control.c\00"
@test_computed_goto.p = internal global i8* blockaddress(@test_computed_goto, %38)
define void @test_computed_goto() {
%1 = alloca %struct.anon
%2 = alloca i32
%3 = alloca i32
%4 = bitcast %struct.anon* %1 to i8*
store i32 0, i32* %2
%5 = getelementptr inbounds %struct.anon, %struct.anon* %1, i32 0, i32 0
%6 = load i8*, i8** %5
br label %39
7: ; preds = %39
%8 = load i32, i32* %2
%9 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fexpect to i32 (i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 247, i32 0, i32 %8)
store i32 0, i32* %3
store i32 0, i32* %2
br label %10
10: ; preds = %7, %39
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 10
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = getelementptr inbounds %struct.anon, %struct.anon* %1, i32 0, i32 2
%15 = load i8*, i8** %14
br label %39
16: ; preds = %10
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 1
store i32 %18, i32* %3
%19 = load i32, i32* %2
%20 = add nsw i32 %19, %17
store i32 %20, i32* %2
%21 = getelementptr inbounds %struct.anon, %struct.anon* %1, i32 0, i32 1
%22 = load i8*, i8** %21
br label %39
23: ; preds = %39
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 11
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = getelementptr inbounds %struct.anon, %struct.anon* %1, i32 0, i32 3
%28 = load i8*, i8** %27
br label %39
29: ; preds = %23
%30 = load i32, i32* %2
%31 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fexpect to i32 (i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 255, i32 55, i32 %30)
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
%34 = getelementptr inbounds %struct.anon, %struct.anon* %1, i32 0, i32 1
%35 = load i8*, i8** %34
br label %39
36: ; preds = %39
%37 = load i8*, i8** @test_computed_goto.p
br label %39
38: ; preds = %39
ret void
39: ; preds = %36, %29, %26, %16, %13, %0
%40 = phi i8* [ %6, %0 ], [ %15, %13 ], [ %22, %16 ], [ %28, %26 ], [ %35, %29 ], [ %37, %36 ]
indirectbr i8* %40, [label %7, label %10, label %23, label %36, label %38]
}

LLVM IR (-O2):
@.str = [130 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/control.c\00"
define void @test_computed_goto() {
br label %1
1: ; preds = %8, %0
%2 = phi i32 [ %12, %8 ], [ 0, %0 ]
%3 = phi i32 [ %11, %8 ], [ undef, %0 ]
%4 = phi i8* [ blockaddress(@test_computed_goto, %7), %8 ], [ blockaddress(@test_computed_goto, %5), %0 ]
br label %17
5: ; preds = %23
%6 = tail call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fexpect to i32 (i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 247, i32 0, i32 %2)
br label %8
7: ; preds = %23
br i1 %21, label %23, label %8
8: ; preds = %7, %5
%9 = phi i32 [ 0, %5 ], [ %18, %7 ]
%10 = phi i32 [ 0, %5 ], [ %2, %7 ]
%11 = add nsw i32 %9, 1
%12 = add nsw i32 %10, %9
br label %1
13: ; preds = %23
br i1 %20, label %23, label %14
14: ; preds = %13
%15 = tail call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @fexpect to i32 (i8*, i32, i32, i32, ...)*)(i8* getelementptr inbounds ([130 x i8], [130 x i8]* @.str, i64 0, i64 0), i32 255, i32 55, i32 %2)
%16 = add nsw i32 %18, 1
br label %17
17: ; preds = %1, %14
%18 = phi i32 [ %3, %1 ], [ %16, %14 ]
%19 = phi i8* [ %4, %1 ], [ blockaddress(@test_computed_goto, %7), %14 ]
%20 = icmp sgt i32 %18, 11
%21 = icmp sgt i32 %18, 10
br label %23
22: ; preds = %23
ret void
23: ; preds = %17, %23, %13, %7
%24 = phi i8* [ blockaddress(@test_computed_goto, %13), %7 ], [ blockaddress(@test_computed_goto, %23), %13 ], [ blockaddress(@test_computed_goto, %22), %23 ], [ %19, %17 ]
indirectbr i8* %24, [label %5, label %7, label %13, label %23, label %22]
}