#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*/ assert(int);
int atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ test1();
int /*<<< orphan*/ test2();
int /*<<< orphan*/ test3();
int /*<<< orphan*/ test4();
int main(int argc, char **argv) {
  assert(argc == 2);
  char *ch = argv[1];
  int choice = atoi(ch);
  printf("Executing test case %d\n", choice);
  switch (choice) {
  case 1:
    test1();
    break;
  case 2:
    test2();
    break;
  case 3:
    test3();
    break;
  case 4:
    test4();
    break;
  default:
    printf("Testcase not defined\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
sete   %al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1219 <main+0xa9>
mov    -0x28(%rbp),%rax
lea    0xe20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1040 <test1@plt>
jmp    1227 <main+0xb7>
mov    $0x0,%al
call   1080 <test2@plt>
jmp    1227 <main+0xb7>
mov    $0x0,%al
call   1030 <test3@plt>
jmp    1227 <main+0xb7>
mov    $0x0,%al
call   1070 <test4@plt>
jmp    1227 <main+0xb7>
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
mov    %eax,%edi
call   1070 <assert@plt>
mov    0x8(%rbx),%rdi
call   10a0 <atoi@plt>
mov    %eax,%ebx
lea    0xe6b(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0xffffffff,%ebx
cmp    $0x3,%ebx
ja     11cf <main+0x4f>
lea    0xe43(%rip),%rax
movslq (%rax,%rbx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
xor    %eax,%eax
call   1050 <test1@plt>
jmp    11f6 <main+0x76>
lea    0xe52(%rip),%rdi
call   1030 <puts@plt>
jmp    11f6 <main+0x76>
xor    %eax,%eax
call   1090 <test2@plt>
jmp    11f6 <main+0x76>
xor    %eax,%eax
call   1040 <test3@plt>
jmp    11f6 <main+0x76>
xor    %eax,%eax
call   1080 <test4@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Executing test case %d\0A\00"
@.str.1 = [22 x i8] c"Testcase not defined\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 2
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
store i8* %14, i8** %6
%15 = load i8*, i8** %6
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %7
switch i32 %19, label %28 [
i32 1, label %20
i32 2, label %22
i32 3, label %24
i32 4, label %26
]
20: ; preds = %2
%21 = call i32 (...) @test1()
br label %30
22: ; preds = %2
%23 = call i32 (...) @test2()
br label %30
24: ; preds = %2
%25 = call i32 (...) @test3()
br label %30
26: ; preds = %2
%27 = call i32 (...) @test4()
br label %30
28: ; preds = %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %30
30: ; preds = %28, %26, %24, %22, %20
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@.str = [24 x i8] c"Executing test case %d\0A\00"
@str = [21 x i8] c"Testcase not defined\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = tail call i32 @atoi(i8* %7)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %8)
switch i32 %8, label %18 [
i32 1, label %10
i32 2, label %12
i32 3, label %14
i32 4, label %16
]
10: ; preds = %2
%11 = tail call i32 (...) @test1()
br label %20
12: ; preds = %2
%13 = tail call i32 (...) @test2()
br label %20
14: ; preds = %2
%15 = tail call i32 (...) @test3()
br label %20
16: ; preds = %2
%17 = tail call i32 (...) @test4()
br label %20
18: ; preds = %2
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %20
20: ; preds = %18, %16, %14, %12, %10
ret i32 0
}