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");
  goto op_end;
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    11aa <main+0x8a>
movslq -0x8(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rax
mov    %rax,-0x28(%rbp)
jmp    11b2 <main+0x92>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x8a>
lea    0xe67(%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     1165 <main+0x45>
lea    0x2cc3(%rip),%rcx
jmp    *(%rcx,%rax,8)
lea    0xeb2(%rip),%rdi
jmp    1160 <main+0x40>
lea    0xea3(%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"
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 %21
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 %22
17: ; preds = %22
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %21
19: ; preds = %22
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17, %11
ret i32 0
22: ; preds = %12
%23 = phi i8* [ %16, %12 ]
indirectbr i8* %23, [label %17, label %19]
}

LLVM IR (-O2):
@__const.main.label_array = [2 x i8*] [i8* blockaddress(@main, %10), i8* blockaddress(@main, %9)]
@.str = [3 x i8] c"%d\00"
@str = [6 x i8] c"world\00"
@str.3 = [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 %13, 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 %10, label %9]
9: ; preds = %5
br label %10
10: ; preds = %5, %9
%11 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0), %9 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0), %5 ]
%12 = call i32 @puts(i8* dereferenceable(1) %11)
br label %13
13: ; preds = %10, %0
ret i32 0
}