#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 foo1();
int foo2();
int foo3();
int foo4();
int foo5();
int foo6();
int main(int argc, char *argv[]) {
  switch (argc) {
  case 1:
    return foo1();
  case 2:
    return foo2();
  case 3:
    return foo3();
  case 4:
    return foo4();
  case 5:
    return foo5();
  case 6:
    return foo6();
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11f9 <main+0x99>
mov    -0x18(%rbp),%rax
lea    0xe6a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1080 <foo1@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
mov    $0x0,%al
call   1050 <foo2@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
mov    $0x0,%al
call   1060 <foo3@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
mov    $0x0,%al
call   1030 <foo4@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
mov    $0x0,%al
call   1070 <foo5@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
mov    $0x0,%al
call   1040 <foo6@plt>
mov    %eax,-0x4(%rbp)
jmp    1200 <main+0xa0>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     117f <main+0x1f>
lea    0xe91(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
jmp    1080 <foo1@plt>
mov    $0xffffffff,%eax
ret
xor    %eax,%eax
jmp    1050 <foo2@plt>
xor    %eax,%eax
jmp    1060 <foo3@plt>
xor    %eax,%eax
jmp    1030 <foo4@plt>
xor    %eax,%eax
jmp    1070 <foo5@plt>
xor    %eax,%eax
jmp    1040 <foo6@plt>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
switch i32 %6, label %19 [
i32 1, label %7
i32 2, label %9
i32 3, label %11
i32 4, label %13
i32 5, label %15
i32 6, label %17
]
7: ; preds = %2
%8 = call i32 (...) @foo1()
store i32 %8, i32* %3
br label %20
9: ; preds = %2
%10 = call i32 (...) @foo2()
store i32 %10, i32* %3
br label %20
11: ; preds = %2
%12 = call i32 (...) @foo3()
store i32 %12, i32* %3
br label %20
13: ; preds = %2
%14 = call i32 (...) @foo4()
store i32 %14, i32* %3
br label %20
15: ; preds = %2
%16 = call i32 (...) @foo5()
store i32 %16, i32* %3
br label %20
17: ; preds = %2
%18 = call i32 (...) @foo6()
store i32 %18, i32* %3
br label %20
19: ; preds = %2
store i32 -1, i32* %3
br label %20
20: ; preds = %19, %17, %15, %13, %11, %9, %7
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
switch i32 %0, label %15 [
i32 1, label %3
i32 2, label %5
i32 3, label %7
i32 4, label %9
i32 5, label %11
i32 6, label %13
]
3: ; preds = %2
%4 = tail call i32 (...) @foo1()
br label %15
5: ; preds = %2
%6 = tail call i32 (...) @foo2()
br label %15
7: ; preds = %2
%8 = tail call i32 (...) @foo3()
br label %15
9: ; preds = %2
%10 = tail call i32 (...) @foo4()
br label %15
11: ; preds = %2
%12 = tail call i32 (...) @foo5()
br label %15
13: ; preds = %2
%14 = tail call i32 (...) @foo6()
br label %15
15: ; preds = %2, %13, %11, %9, %7, %5, %3
%16 = phi i32 [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ -1, %2 ]
ret i32 %16
}