#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*/ ex1();
int /*<<< orphan*/ ex2();
int /*<<< orphan*/ ex3();
int /*<<< orphan*/ ex4();
int getExerciseNumber(int, char **);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  int ex = getExerciseNumber(argc, argv);
  switch (ex) {
  case 1:
    ex1();
    return 0;
  case 2:
    ex2();
    return 0;
  case 3:
    ex3();
    return 0;
  case 4:
    ex4();
    return 0;
  default:
    printf("\n The exercise does not exist!\n");
    printf("You specified exercise: %d", ex);
    return 0;
  }
}


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),%edi
mov    -0x10(%rbp),%rsi
call   1080 <getExerciseNumber@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11fa <main+0x9a>
mov    -0x20(%rbp),%rax
lea    0xe5b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1030 <ex1@plt>
movl   $0x0,-0x4(%rbp)
jmp    1220 <main+0xc0>
mov    $0x0,%al
call   1070 <ex2@plt>
movl   $0x0,-0x4(%rbp)
jmp    1220 <main+0xc0>
mov    $0x0,%al
call   1040 <ex3@plt>
movl   $0x0,-0x4(%rbp)
jmp    1220 <main+0xc0>
mov    $0x0,%al
call   1060 <ex4@plt>
movl   $0x0,-0x4(%rbp)
jmp    1220 <main+0xc0>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
call   1090 <getExerciseNumber@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%eax
cmp    $0x3,%eax
ja     1199 <main+0x29>
lea    0xe79(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
call   1030 <ex1@plt>
jmp    11d0 <main+0x60>
lea    0xe8b(%rip),%rdi
call   1050 <puts@plt>
lea    0xe64(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11d0 <main+0x60>
xor    %eax,%eax
call   1080 <ex2@plt>
jmp    11d0 <main+0x60>
xor    %eax,%eax
call   1040 <ex3@plt>
jmp    11d0 <main+0x60>
xor    %eax,%eax
call   1070 <ex4@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [32 x i8] c"\0A The exercise does not exist!\0A\00"
@.str.1 = [27 x i8] c"You specified exercise: %d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @getExerciseNumber(i32 %7, i8** %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
switch i32 %10, label %19 [
i32 1, label %11
i32 2, label %13
i32 3, label %15
i32 4, label %17
]
11: ; preds = %2
%12 = call i32 (...) @ex1()
store i32 0, i32* %3
br label %23
13: ; preds = %2
%14 = call i32 (...) @ex2()
store i32 0, i32* %3
br label %23
15: ; preds = %2
%16 = call i32 (...) @ex3()
store i32 0, i32* %3
br label %23
17: ; preds = %2
%18 = call i32 (...) @ex4()
store i32 0, i32* %3
br label %23
19: ; preds = %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %6
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %21)
store i32 0, i32* %3
br label %23
23: ; preds = %19, %17, %15, %13, %11
%24 = load i32, i32* %3
ret i32 %24
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"You specified exercise: %d\00"
@str = [31 x i8] c"\0A The exercise does not exist!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getExerciseNumber(i32 %0, i8** %1)
switch i32 %3, label %12 [
i32 1, label %4
i32 2, label %6
i32 3, label %8
i32 4, label %10
]
4: ; preds = %2
%5 = tail call i32 (...) @ex1()
br label %15
6: ; preds = %2
%7 = tail call i32 (...) @ex2()
br label %15
8: ; preds = %2
%9 = tail call i32 (...) @ex3()
br label %15
10: ; preds = %2
%11 = tail call i32 (...) @ex4()
br label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %3)
br label %15
15: ; preds = %12, %10, %8, %6, %4
ret i32 0
}