#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*/ ex_debug();
int /*<<< orphan*/ ex_fork();
int /*<<< orphan*/ ex_segfault();
int /*<<< orphan*/ ex_static();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    fprintf(stderr, "error: you must specify an example to run\n");
    return -1;
  }
  if (strcmp(argv[1], "static") == 0) {
    ex_static();
  } else if (strcmp(argv[1], "segfault") == 0) {
    ex_segfault();
  } else if (strcmp(argv[1], "fork") == 0) {
    ex_fork();
  } else if (strcmp(argv[1], "debug") == 0) {
    ex_debug();
  } else {
    fprintf(stderr, "error: example \"%s\" not found\n", argv[1]);
    return -1;
  }
  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)
cmpl   $0x2,-0x8(%rbp)
jge    11a3 <main+0x43>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    128c <main+0x12c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe79(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <main+0x6d>
mov    $0x0,%al
call   1070 <ex_static@plt>
jmp    1285 <main+0x125>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe56(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11f7 <main+0x97>
mov    $0x0,%al
call   1080 <ex_segfault@plt>
jmp    1280 <main+0x120>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe35(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <main+0xc1>
mov    $0x0,%al
call   1040 <ex_fork@plt>
jmp    127b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe10(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    124b <main+0xeb>
mov    $0x0,%al
call   1030 <ex_debug@plt>
jmp    1276 <main+0x116>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xde3(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    128c <main+0x12c>
jmp    127b <main+0x11b>
jmp    1280 <main+0x120>
jmp    1285 <main+0x125>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1187 <main+0x27>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebx
jmp    1225 <main+0xc5>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe96(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11fb <main+0x9b>
mov    0x8(%rbx),%rdi
lea    0xe88(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1206 <main+0xa6>
mov    0x8(%rbx),%rdi
lea    0xe7c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1211 <main+0xb1>
mov    0x8(%rbx),%rdi
lea    0xe6c(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     121c <main+0xbc>
mov    0x2dfb(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    117d <main+0x1d>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <ex_static@plt>
jmp    1225 <main+0xc5>
xor    %ebx,%ebx
xor    %eax,%eax
call   1080 <ex_segfault@plt>
jmp    1225 <main+0xc5>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <ex_fork@plt>
jmp    1225 <main+0xc5>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <ex_debug@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"error: you must specify an example to run\0A\00"
@.str.1 = [7 x i8] c"static\00"
@.str.2 = [9 x i8] c"segfault\00"
@.str.3 = [5 x i8] c"fork\00"
@.str.4 = [6 x i8] c"debug\00"
@.str.5 = [31 x i8] c"error: example \22%s\22 not found\0A\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 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %53
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 (...) @ex_static()
br label %52
19: ; preds = %11
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = call i32 (...) @ex_segfault()
br label %51
27: ; preds = %19
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %27
%34 = call i32 (...) @ex_fork()
br label %50
35: ; preds = %27
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %35
%42 = call i32 (...) @ex_debug()
br label %49
43: ; preds = %35
%44 = load i32, i32* @stderr
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %47)
store i32 -1, i32* %3
br label %53
49: ; preds = %41
br label %50
50: ; preds = %49, %33
br label %51
51: ; preds = %50, %25
br label %52
52: ; preds = %51, %17
store i32 0, i32* %3
br label %53
53: ; preds = %52, %43, %8
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"error: you must specify an example to run\0A\00"
@.str.1 = [7 x i8] c"static\00"
@.str.2 = [9 x i8] c"segfault\00"
@.str.3 = [5 x i8] c"fork\00"
@.str.4 = [6 x i8] c"debug\00"
@.str.5 = [31 x i8] c"error: example \22%s\22 not found\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
br label %36
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = tail call i32 (...) @ex_static()
br label %36
14: ; preds = %7
%15 = load i8*, i8** %8
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 (...) @ex_segfault()
br label %36
20: ; preds = %14
%21 = load i8*, i8** %8
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 (...) @ex_fork()
br label %36
26: ; preds = %20
%27 = load i8*, i8** %8
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = tail call i32 (...) @ex_debug()
br label %36
32: ; preds = %26
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %8
%35 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %34)
br label %36
36: ; preds = %12, %24, %30, %18, %32, %4
%37 = phi i32 [ -1, %4 ], [ -1, %32 ], [ 0, %18 ], [ 0, %30 ], [ 0, %24 ], [ 0, %12 ]
ret i32 %37
}