#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 atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ parallel_openMP();
int /*<<< orphan*/ parallel_pthreads();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sequential();
int /*<<< orphan*/ usage();
void run(char **argv) {
  switch (atoi(argv[1])) {
  case 0:
    sequential();
    break;
  case 1:
    parallel_pthreads();
    break;
  case 2:
    parallel_openMP();
    break;
  case 3:
    printf("Not implemented.");
    break;
  default:
    printf("Invalid argument for test\n");
    usage();
    exit(1);
  }
}


x86 assembly (clang, -O0):
<run>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     11e1 <run+0x71>
mov    -0x10(%rbp),%rax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1070 <sequential@plt>
jmp    11fe <run+0x8e>
mov    $0x0,%al
call   1040 <parallel_pthreads@plt>
jmp    11fe <run+0x8e>
mov    $0x0,%al
call   1050 <parallel_openMP@plt>
jmp    11fe <run+0x8e>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    11fe <run+0x8e>
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run>:
push   %rax
mov    0x8(%rdi),%rdi
call   1090 <atoi@plt>
cmp    $0x3,%eax
ja     11c6 <run+0x46>
mov    %eax,%eax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rcx
jmp    1080 <sequential@plt>
xor    %eax,%eax
pop    %rcx
jmp    1060 <parallel_openMP@plt>
xor    %eax,%eax
pop    %rcx
jmp    1050 <parallel_pthreads@plt>
lea    0xe50(%rip),%rdi
pop    %rax
jmp    1040 <printf@plt>
lea    0xe54(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [17 x i8] c"Not implemented.\00"
@.str.1 = [27 x i8] c"Invalid argument for test\0A\00"
define void @run(i8** %0) {
%2 = alloca i8**
store i8** %0, i8*** %2
%3 = load i8**, i8*** %2
%4 = getelementptr inbounds i8*, i8** %3, i64 1
%5 = load i8*, i8** %4
%6 = call i32 @atoi(i8* %5)
switch i32 %6, label %15 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
i32 3, label %13
]
7: ; preds = %1
%8 = call i32 (...) @sequential()
br label %19
9: ; preds = %1
%10 = call i32 (...) @parallel_pthreads()
br label %19
11: ; preds = %1
%12 = call i32 (...) @parallel_openMP()
br label %19
13: ; preds = %1
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %19
15: ; preds = %1
%16 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 (...) @usage()
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %13, %11, %9, %7
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"Not implemented.\00"
@str = [26 x i8] c"Invalid argument for test\00"
define void @run(i8** nocapture %0) {
%2 = getelementptr inbounds i8*, i8** %0, i64 1
%3 = load i8*, i8** %2
%4 = tail call i32 @atoi(i8* %3)
switch i32 %4, label %13 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
]
5: ; preds = %1
%6 = tail call i32 (...) @sequential()
br label %17
7: ; preds = %1
%8 = tail call i32 (...) @parallel_pthreads()
br label %17
9: ; preds = %1
%10 = tail call i32 (...) @parallel_openMP()
br label %17
11: ; preds = %1
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %17
13: ; preds = %1
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 (...) @usage()
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %11, %9, %7, %5
ret void
}