#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ usleep(int);
int main(int argc, char **argv) {
  printf("Test program\n");
  fflush(stdout);
  if (argc >= 2 && !strcmp(argv[1], "return"))
    return atoi(argv[2]);
  else if (argc >= 2 && !strcmp(argv[1], "sleep"))
    sleep(atoi(argv[2]));
  else if (argc >= 2 && !strcmp(argv[1], "usleep"))
    usleep(atoi(argv[2]));
  else if (argc >= 1 && !strcmp(argv[1], "sigsegv"))
    return *(int *)(0x123521231);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
cmpl   $0x2,-0x8(%rbp)
jl     11cc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe65(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11cc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x4(%rbp)
jmp    129d <main+0x13d>
cmpl   $0x2,-0x8(%rbp)
jl     120c <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe31(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    120c <main+0xac>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1070 <sleep@plt>
jmp    1291 <main+0x131>
cmpl   $0x2,-0x8(%rbp)
jl     124c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    124c <main+0xec>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1080 <usleep@plt>
jmp    128c <main+0x12c>
cmpl   $0x1,-0x8(%rbp)
jl     1287 <main+0x127>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdb7(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1287 <main+0x127>
movabs $0x123521231,%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    129d <main+0x13d>
jmp    128c <main+0x12c>
jmp    1291 <main+0x131>
jmp    1296 <main+0x136>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
cmp    $0x2,%ebx
jl     11d7 <main+0x77>
mov    0x8(%r14),%rbx
lea    0xe6d(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1207 <main+0xa7>
lea    0xe62(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1217 <main+0xb7>
lea    0xe4e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    11e2 <main+0x82>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1080 <usleep@plt>
jmp    1227 <main+0xc7>
xor    %eax,%eax
cmp    $0x1,%ebx
jne    1229 <main+0xc9>
mov    0x8(%r14),%rbx
lea    0xe25(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    1229 <main+0xc9>
movabs $0x123521231,%rax
mov    (%rax),%eax
jmp    1229 <main+0xc9>
mov    0x10(%r14),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <atoi@plt>
mov    0x10(%r14),%rdi
call   1060 <atoi@plt>
mov    %eax,%edi
call   1070 <sleep@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Test program\0A\00"
@stdout = global i32 0
@.str.1 = [7 x i8] c"return\00"
@.str.2 = [6 x i8] c"sleep\00"
@.str.3 = [7 x i8] c"usleep\00"
@.str.4 = [8 x i8] c"sigsegv\00"
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 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stdout
%8 = call i32 @fflush(i32 %7)
%9 = load i32, i32* %4
%10 = icmp sge i32 %9, 2
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %11
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %3
br label %67
22: ; preds = %11, %2
%23 = load i32, i32* %4
%24 = icmp sge i32 %23, 2
br i1 %24, label %25, label %37
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @strcmp(i8* %28, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp ne i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %25
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32 @atoi(i8* %34)
%36 = call i32 @sleep(i32 %35)
br label %65
37: ; preds = %25, %22
%38 = load i32, i32* %4
%39 = icmp sge i32 %38, 2
br i1 %39, label %40, label %52
40: ; preds = %37
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i32 @strcmp(i8* %43, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp ne i32 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %40
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
%51 = call i32 @usleep(i32 %50)
br label %64
52: ; preds = %40, %37
%53 = load i32, i32* %4
%54 = icmp sge i32 %53, 1
br i1 %54, label %55, label %63
55: ; preds = %52
%56 = load i8**, i8*** %5
%57 = getelementptr inbounds i8*, i8** %56, i64 1
%58 = load i8*, i8** %57
%59 = call i32 @strcmp(i8* %58, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%60 = icmp ne i32 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %55
%62 = load i32, i32* inttoptr (i64 4887548465 to i32*)
store i32 %62, i32* %3
br label %67
63: ; preds = %55, %52
br label %64
64: ; preds = %63, %46
br label %65
65: ; preds = %64, %31
br label %66
66: ; preds = %65
store i32 0, i32* %3
br label %67
67: ; preds = %66, %61, %17
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@stdout = global i32 0
@.str.1 = [7 x i8] c"return\00"
@.str.2 = [6 x i8] c"sleep\00"
@.str.3 = [7 x i8] c"usleep\00"
@.str.4 = [8 x i8] c"sigsegv\00"
@str = [13 x i8] c"Test program\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = load i32, i32* @stdout
%5 = tail call i32 @fflush(i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %32
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32 @atoi(i8* %14)
br label %43
16: ; preds = %7
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %16
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = tail call i32 @sleep(i32 %22)
br label %43
24: ; preds = %16
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @atoi(i8* %29)
%31 = tail call i32 @usleep(i32 %30)
br label %43
32: ; preds = %2
%33 = icmp eq i32 %0, 1
br i1 %33, label %34, label %43
34: ; preds = %32
%35 = getelementptr inbounds i8*, i8** %1, i64 1
%36 = load i8*, i8** %35
br label %37
37: ; preds = %34, %24
%38 = phi i8* [ %36, %34 ], [ %9, %24 ]
%39 = tail call i32 @strcmp(i8* dereferenceable(1) %38, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i32, i32* inttoptr (i64 4887548465 to i32*)
br label %43
43: ; preds = %27, %37, %32, %19, %41, %12
%44 = phi i32 [ %42, %41 ], [ %15, %12 ], [ 0, %19 ], [ 0, %32 ], [ 0, %37 ], [ 0, %27 ]
ret i32 %44
}