#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int foo(int arg) {
  switch (arg) {
  case 0:
    return 1;
  case 1:
    return 2;
  case 2:
    printf("Hello world!\n");
    return 3;
  case 3: {
    int a = 4;
    return a;
  }
  case 4:
    return 5;
  case 5:
    printf("Hello world!\n");
    return 6;
  case 6: {
    int a = 7;
    return a;
  }
  case 7:
    return 8;
  case 8:
    return 9;
  case 9:
    return 10;
  case 10:
    return 11;
  case 11:
    return 12;
  case 12:
    return 13;
  case 13:
    return 14;
  case 14:
    return 15;
  case 15:
    return 16;
  case 16:
    return 17;
  case 17:
    return 18;
  case 18:
    return 19;
  default:
    return arg++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x12,%rax
ja     1248 <foo+0x138>
mov    -0x18(%rbp),%rax
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x2,-0x4(%rbp)
jmp    1256 <foo+0x146>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
movl   $0x3,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x4,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x5,-0x4(%rbp)
jmp    1256 <foo+0x146>
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x6,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x7,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x8,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x9,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xa,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xb,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xc,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xd,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xe,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0xf,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x10,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x11,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x12,-0x4(%rbp)
jmp    1256 <foo+0x146>
movl   $0x13,-0x4(%rbp)
jmp    1256 <foo+0x146>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x8(%rbp)
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rax
mov    %edi,%eax
cmp    $0x12,%edi
ja     11c7 <foo+0xb7>
mov    %eax,%eax
lea    0xedb(%rip),%rcx
movslq (%rcx,%rax,4),%rdx
add    %rcx,%rdx
mov    $0x1,%eax
jmp    *%rdx
mov    $0x2,%eax
pop    %rcx
ret
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
mov    $0x3,%eax
pop    %rcx
ret
mov    $0x4,%eax
pop    %rcx
ret
mov    $0x5,%eax
pop    %rcx
ret
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
mov    $0x6,%eax
pop    %rcx
ret
mov    $0x7,%eax
pop    %rcx
ret
mov    $0x8,%eax
pop    %rcx
ret
mov    $0x9,%eax
pop    %rcx
ret
mov    $0xa,%eax
pop    %rcx
ret
mov    $0xb,%eax
pop    %rcx
ret
mov    $0xc,%eax
pop    %rcx
ret
mov    $0xd,%eax
pop    %rcx
ret
mov    $0xe,%eax
pop    %rcx
ret
mov    $0xf,%eax
pop    %rcx
ret
mov    $0x10,%eax
pop    %rcx
ret
mov    $0x11,%eax
pop    %rcx
ret
mov    $0x12,%eax
pop    %rcx
ret
mov    $0x13,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@str.1 = [13 x i8] c"Hello world!\00"
define i32 @foo(i32 %0) {
switch i32 %0, label %22 [
i32 0, label %23
i32 1, label %2
i32 2, label %3
i32 3, label %5
i32 4, label %6
i32 5, label %7
i32 6, label %9
i32 7, label %10
i32 8, label %11
i32 9, label %12
i32 10, label %13
i32 11, label %14
i32 12, label %15
i32 13, label %16
i32 14, label %17
i32 15, label %18
i32 16, label %19
i32 17, label %20
i32 18, label %21
]
2: ; preds = %1
br label %23
3: ; preds = %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.1, i64 0, i64 0))
br label %23
5: ; preds = %1
br label %23
6: ; preds = %1
br label %23
7: ; preds = %1
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.1, i64 0, i64 0))
br label %23
9: ; preds = %1
br label %23
10: ; preds = %1
br label %23
11: ; preds = %1
br label %23
12: ; preds = %1
br label %23
13: ; preds = %1
br label %23
14: ; preds = %1
br label %23
15: ; preds = %1
br label %23
16: ; preds = %1
br label %23
17: ; preds = %1
br label %23
18: ; preds = %1
br label %23
19: ; preds = %1
br label %23
20: ; preds = %1
br label %23
21: ; preds = %1
br label %23
22: ; preds = %1
br label %23
23: ; preds = %1, %22, %21, %20, %19, %18, %17, %16, %15, %14, %13, %12, %11, %10, %9, %7, %6, %5, %3, %2
%24 = phi i32 [ %0, %22 ], [ 19, %21 ], [ 18, %20 ], [ 17, %19 ], [ 16, %18 ], [ 15, %17 ], [ 14, %16 ], [ 13, %15 ], [ 12, %14 ], [ 11, %13 ], [ 10, %12 ], [ 9, %11 ], [ 8, %10 ], [ 7, %9 ], [ 6, %7 ], [ 5, %6 ], [ 4, %5 ], [ 3, %3 ], [ 2, %2 ], [ 1, %1 ]
ret i32 %24
}