#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 */
struct lsm_tree {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ interactive(struct lsm_tree *);
int /*<<< orphan*/ isprint(char);
struct lsm_tree *lsm_tree_default_init();
char *optarg;
char optopt;
int /*<<< orphan*/ quit(struct lsm_tree *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ test_bloom();
int /*<<< orphan*/ workload(struct lsm_tree *, char *);
int main(int argc, char *argv[]) {
  int iflag = 0;
  int bflag = 0;
  char *wfile = NULL;
  int c;
  while ((c = getopt(argc, argv, "ibw:")) != -1) {
    switch (c) {
    case 'i':
      iflag = 1;
      break;
    case 'w':
      wfile = optarg;
      break;
    case 'b':
      bflag = 1;
      break;
    case '?':
      if (optopt == 'w') {
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      } else if (isprint(optopt)) {
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      } else {
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      }
      return 1;
    default:
      abort();
    }
  }
  if (iflag && wfile) {
    fprintf(stderr,
            "Too many arguments - try either workload or interactive mode "
            "with -w [filename] or -i\n");
    return 1;
  } else if (!iflag && !wfile && !bflag) {
    fprintf(stderr,
            "Not enough arguments - try either workload or interactive mode "
            "with -w [filename] or -i\n");
    return 1;
  }
  if (iflag) {
    struct lsm_tree *tree = lsm_tree_default_init();
    interactive(tree);
  } else if (wfile) {
    struct lsm_tree *tree = lsm_tree_default_init();
    workload(tree, wfile);
    quit(tree);
  } else if (bflag) {
    test_bloom();
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe36(%rip),%rdx
call   10b0 <getopt@plt>
mov    %eax,-0x24(%rbp)
cmp    $0xffffffff,%eax
je     1302 <main+0x172>
mov    -0x24(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x3f,%eax
je     124d <main+0xbd>
jmp    11ef <main+0x5f>
mov    -0x3c(%rbp),%eax
sub    $0x62,%eax
je     1241 <main+0xb1>
jmp    1200 <main+0x70>
mov    -0x3c(%rbp),%eax
sub    $0x69,%eax
je     1222 <main+0x92>
jmp    1211 <main+0x81>
mov    -0x3c(%rbp),%eax
sub    $0x77,%eax
je     122e <main+0x9e>
jmp    12f6 <main+0x166>
movl   $0x1,-0x14(%rbp)
jmp    12fd <main+0x16d>
mov    0x2dc3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
jmp    12fd <main+0x16d>
movl   $0x1,-0x18(%rbp)
jmp    12fd <main+0x16d>
mov    0x2d8c(%rip),%rax
movsbl (%rax),%eax
cmp    $0x77,%eax
jne    1286 <main+0xf6>
mov    0x2d69(%rip),%rax
mov    (%rax),%edi
mov    0x2d70(%rip),%rax
movsbl (%rax),%edx
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12ea <main+0x15a>
mov    0x2d53(%rip),%rax
movsbl (%rax),%edi
call   10a0 <isprint@plt>
cmp    $0x0,%eax
je     12c4 <main+0x134>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
mov    0x2d32(%rip),%rax
movsbl (%rax),%edx
lea    0xd6f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12e5 <main+0x155>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
mov    0x2d0c(%rip),%rax
movsbl (%rax),%edx
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12ea <main+0x15a>
movl   $0x1,-0x4(%rbp)
jmp    13f0 <main+0x260>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    11bc <main+0x2c>
cmpl   $0x0,-0x14(%rbp)
je     133a <main+0x1aa>
cmpq   $0x0,-0x20(%rbp)
je     133a <main+0x1aa>
mov    0x2cb2(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f0 <main+0x260>
cmpl   $0x0,-0x14(%rbp)
jne    137c <main+0x1ec>
cmpq   $0x0,-0x20(%rbp)
jne    137c <main+0x1ec>
cmpl   $0x0,-0x18(%rbp)
jne    137c <main+0x1ec>
mov    0x2c70(%rip),%rax
mov    (%rax),%edi
lea    0xd4e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13f0 <main+0x260>
jmp    1381 <main+0x1f1>
cmpl   $0x0,-0x14(%rbp)
je     13a4 <main+0x214>
mov    $0x0,%al
call   1040 <lsm_tree_default_init@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1090 <interactive@plt>
jmp    13f0 <main+0x260>
cmpq   $0x0,-0x20(%rbp)
je     13d5 <main+0x245>
mov    $0x0,%al
call   1040 <lsm_tree_default_init@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <workload@plt>
mov    -0x38(%rbp),%rdi
call   1070 <quit@plt>
jmp    13eb <main+0x25b>
cmpl   $0x0,-0x18(%rbp)
je     13e6 <main+0x256>
mov    $0x0,%al
call   1060 <test_bloom@plt>
jmp    13eb <main+0x25b>
jmp    13f0 <main+0x260>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%ebp
xor    %r14d,%r14d
lea    0xe56(%rip),%r15
xor    %r12d,%r12d
xor    %ebx,%ebx
mov    %ebx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ecx,%ebx
mov    %ebp,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   10b0 <getopt@plt>
mov    $0x1,%ecx
cmp    $0x69,%eax
je     11c0 <main+0x30>
cmp    $0x61,%eax
jle    1208 <main+0x78>
cmp    $0x62,%eax
je     1200 <main+0x70>
cmp    $0x77,%eax
jne    130f <main+0x17f>
mov    0x2e05(%rip),%rax
mov    (%rax),%r14
jmp    11af <main+0x1f>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%r12d
jmp    11af <main+0x1f>
cmp    $0xffffffff,%eax
je     123d <main+0xad>
cmp    $0x3f,%eax
jne    130f <main+0x17f>
mov    0x2dc3(%rip),%rbx
mov    (%rbx),%al
cmp    $0x77,%al
jne    1258 <main+0xc8>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
lea    0xdd2(%rip),%rsi
mov    $0x77,%edx
jmp    12be <main+0x12e>
test   %ebx,%ebx
je     1279 <main+0xe9>
test   %r14,%r14
je     1279 <main+0xe9>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xe0a(%rip),%rsi
jmp    1297 <main+0x107>
movsbl %al,%edi
call   10a0 <isprint@plt>
mov    0x2d69(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
je     12b7 <main+0x127>
lea    0xdb0(%rip),%rsi
jmp    12be <main+0x12e>
test   %ebx,%ebx
jne    12a0 <main+0x110>
test   %r14,%r14
jne    12a0 <main+0x110>
test   %r12d,%r12d
jne    12a0 <main+0x110>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
lea    0xe20(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    12c5 <main+0x135>
test   %ebx,%ebx
je     12db <main+0x14b>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <lsm_tree_default_init@plt>
mov    %rax,%rdi
call   1090 <interactive@plt>
jmp    12ca <main+0x13a>
lea    0xd80(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
test   %r14,%r14
je     1301 <main+0x171>
xor    %eax,%eax
call   1040 <lsm_tree_default_init@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <workload@plt>
mov    %rbp,%rdi
call   1070 <quit@plt>
jmp    12ca <main+0x13a>
test   %r12d,%r12d
je     12ca <main+0x13a>
xor    %eax,%eax
call   1060 <test_bloom@plt>
jmp    12ca <main+0x13a>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.lsm_tree = type { i32 }
@.str = [5 x i8] c"ibw:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.4 = [87 x i8] c"Too many arguments - try either workload or interactive mode with -w [filename] or -i\0A\00"
@.str.5 = [89 x i8] c"Not enough arguments - try either workload or interactive mode with -w [filename] or -i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca %struct.lsm_tree*
%11 = alloca %struct.lsm_tree*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
br label %12
12: ; preds = %50, %2
%13 = load i32, i32* %4
%14 = load i8**, i8*** %5
%15 = call i32 @getopt(i32 %13, i8** %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %15, i32* %9
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %51
17: ; preds = %12
%18 = load i32, i32* %9
switch i32 %18, label %48 [
i32 105, label %19
i32 119, label %20
i32 98, label %22
i32 63, label %23
]
19: ; preds = %17
store i32 1, i32* %6
br label %50
20: ; preds = %17
%21 = load i8*, i8** @optarg
store i8* %21, i8** %8
br label %50
22: ; preds = %17
store i32 1, i32* %7
br label %50
23: ; preds = %17
%24 = load i8, i8* @optopt
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 119
br i1 %26, label %27, label %32
27: ; preds = %23
%28 = load i32, i32* @stderr
%29 = load i8, i8* @optopt
%30 = sext i8 %29 to i32
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %47
32: ; preds = %23
%33 = load i8, i8* @optopt
%34 = call i32 @isprint(i8 signext %33)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* @stderr
%38 = load i8, i8* @optopt
%39 = sext i8 %38 to i32
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %37, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %46
41: ; preds = %32
%42 = load i32, i32* @stderr
%43 = load i8, i8* @optopt
%44 = sext i8 %43 to i32
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %42, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %41, %36
br label %47
47: ; preds = %46, %27
store i32 1, i32* %3
br label %97
48: ; preds = %17
%49 = call i32 (...) @abort()
unreachable
50: ; preds = %22, %20, %19
br label %12
51: ; preds = %12
%52 = load i32, i32* %6
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i8*, i8** %8
%56 = icmp ne i8* %55, null
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %97
60: ; preds = %54, %51
%61 = load i32, i32* %6
%62 = icmp ne i32 %61, 0
br i1 %62, label %72, label %63
63: ; preds = %60
%64 = load i8*, i8** %8
%65 = icmp ne i8* %64, null
br i1 %65, label %72, label %66
66: ; preds = %63
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %3
br label %97
72: ; preds = %66, %63, %60
br label %73
73: ; preds = %72
%74 = load i32, i32* %6
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %73
%77 = call %struct.lsm_tree* (...) @lsm_tree_default_init()
store %struct.lsm_tree* %77, %struct.lsm_tree** %10
%78 = load %struct.lsm_tree*, %struct.lsm_tree** %10
%79 = call i32 @interactive(%struct.lsm_tree* %78)
br label %97
80: ; preds = %73
%81 = load i8*, i8** %8
%82 = icmp ne i8* %81, null
br i1 %82, label %83, label %90
83: ; preds = %80
%84 = call %struct.lsm_tree* (...) @lsm_tree_default_init()
store %struct.lsm_tree* %84, %struct.lsm_tree** %11
%85 = load %struct.lsm_tree*, %struct.lsm_tree** %11
%86 = load i8*, i8** %8
%87 = call i32 @workload(%struct.lsm_tree* %85, i8* %86)
%88 = load %struct.lsm_tree*, %struct.lsm_tree** %11
%89 = call i32 @quit(%struct.lsm_tree* %88)
br label %96
90: ; preds = %80
%91 = load i32, i32* %7
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %90
%94 = call i32 (...) @test_bloom()
br label %95
95: ; preds = %93, %90
br label %96
96: ; preds = %95, %83
br label %97
97: ; preds = %47, %57, %69, %96, %76
%98 = load i32, i32* %3
ret i32 %98
}

LLVM IR (-O2):
%struct.lsm_tree = type { i32 }
@.str = [5 x i8] c"ibw:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.1 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.2 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.3 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@.str.4 = [87 x i8] c"Too many arguments - try either workload or interactive mode with -w [filename] or -i\0A\00"
@.str.5 = [89 x i8] c"Not enough arguments - try either workload or interactive mode with -w [filename] or -i\0A\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %13, %2
%4 = phi i8* [ %14, %13 ], [ null, %2 ]
%5 = phi i32 [ %8, %13 ], [ 0, %2 ]
%6 = phi i32 [ %11, %13 ], [ 0, %2 ]
br label %7
7: ; preds = %10, %3
%8 = phi i32 [ %5, %3 ], [ 1, %10 ]
%9 = phi i32 [ %6, %3 ], [ %11, %10 ]
br label %10
10: ; preds = %7, %10
%11 = phi i32 [ 1, %10 ], [ %9, %7 ]
%12 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %12, label %31 [
i32 -1, label %33
i32 105, label %10
i32 119, label %13
i32 98, label %7
i32 63, label %15
]
13: ; preds = %10
%14 = load i8*, i8** @optarg
br label %3
15: ; preds = %10
%16 = load i8, i8* @optopt
%17 = icmp eq i8 %16, 119
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 119)
br label %59
21: ; preds = %15
%22 = tail call i32 @isprint(i8 signext %16)
%23 = icmp eq i32 %22, 0
%24 = load i32, i32* @stderr
%25 = load i8, i8* @optopt
%26 = sext i8 %25 to i32
br i1 %23, label %29, label %27
27: ; preds = %21
%28 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %59
29: ; preds = %21
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %59
31: ; preds = %10
%32 = tail call i32 (...) @abort()
unreachable
33: ; preds = %10
%34 = icmp ne i32 %11, 0
%35 = icmp ne i8* %4, null
%36 = select i1 %34, i1 %35, i1 false
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.4, i64 0, i64 0))
br label %59
40: ; preds = %33
%41 = select i1 %34, i1 true, i1 %35
%42 = icmp ne i32 %8, 0
%43 = select i1 %41, i1 true, i1 %42
br i1 %43, label %47, label %44
44: ; preds = %40
%45 = load i32, i32* @stderr
%46 = tail call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.5, i64 0, i64 0))
br label %59
47: ; preds = %40
br i1 %34, label %48, label %51
48: ; preds = %47
%49 = tail call %struct.lsm_tree* (...) @lsm_tree_default_init()
%50 = tail call i32 @interactive(%struct.lsm_tree* %49)
br label %59
51: ; preds = %47
br i1 %35, label %52, label %56
52: ; preds = %51
%53 = tail call %struct.lsm_tree* (...) @lsm_tree_default_init()
%54 = tail call i32 @workload(%struct.lsm_tree* %53, i8* %4)
%55 = tail call i32 @quit(%struct.lsm_tree* %53)
br label %59
56: ; preds = %51
br i1 %42, label %57, label %59
57: ; preds = %56
%58 = tail call i32 (...) @test_bloom()
br label %59
59: ; preds = %48, %56, %57, %52, %18, %29, %27, %44, %37
%60 = phi i32 [ 1, %37 ], [ 1, %44 ], [ 1, %27 ], [ 1, %29 ], [ 1, %18 ], [ 0, %52 ], [ 0, %57 ], [ 0, %56 ], [ 0, %48 ]
ret i32 %60
}