int main() {
  int c = 1;
  void *label_array[] = {&&op_hello, &&op_world};
  scanf("%d", &c);
  if (c < 0 || c > 1) {
    goto op_end;
  } else
    goto *label_array[c];
op_hello:
  printf("hello\n");
  goto op_end;
op_world : { printf("world\n"); }
  printf("abc\r\n");
op_end:
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    0x2cd3(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cd0(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xead(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1172 <main+0x52>
cmpl   $0x1,-0x8(%rbp)
jle    1177 <main+0x57>
jmp    11b8 <main+0x98>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0x28(%rbp)
jmp    11c0 <main+0xa0>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b8 <main+0x98>
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    -0x28(%rbp),%rax
jmp    *%rax

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xed0(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x1,%rax
ja     1171 <main+0x51>
lea    0x2cc3(%rip),%rcx
jmp    *(%rcx,%rax,8)
lea    0xeb7(%rip),%rdi
jmp    116c <main+0x4c>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.main.label_array = [2 x i8*] [i8* blockaddress(@main, %17), i8* blockaddress(@main, %19)]
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"hello\0A\00"
@.str.2 = [7 x i8] c"world\0A\00"
@.str.3 = [6 x i8] c"abc\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i8*]
store i32 0, i32* %1
store i32 1, i32* %2
%4 = bitcast [2 x i8*]* %3 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = load i32, i32* %2
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %12
11: ; preds = %8, %0
br label %22
12: ; preds = %8
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [2 x i8*], [2 x i8*]* %3, i64 0, i64 %14
%16 = load i8*, i8** %15
br label %23
17: ; preds = %23
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %22
19: ; preds = %23
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %19, %17, %11
ret i32 0
23: ; preds = %12
%24 = phi i8* [ %16, %12 ]
indirectbr i8* %24, [label %17, label %19]
}

LLVM IR (-O2):
@__const.main.label_array = [2 x i8*] [i8* blockaddress(@main, %11), i8* blockaddress(@main, %9)]
@.str = [3 x i8] c"%d\00"
@str = [6 x i8] c"world\00"
@str.4 = [5 x i8] c"abc\0D\00"
@str.5 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
store i32 1, i32* %1
%2 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%3 = load i32, i32* %1
%4 = icmp ugt i32 %3, 1
br i1 %4, label %14, label %5
5: ; preds = %0
%6 = zext i32 %3 to i64
%7 = getelementptr inbounds [2 x i8*], [2 x i8*]* @__const.main.label_array, i64 0, i64 %6
%8 = load i8*, i8** %7
indirectbr i8* %8, [label %11, label %9]
9: ; preds = %5
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
br label %11
11: ; preds = %5, %9
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.4, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.5, i64 0, i64 0), %5 ]
%13 = call i32 @puts(i8* dereferenceable(1) %12)
br label %14
14: ; preds = %11, %0
ret i32 0
}