#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*/ db_destroy();
int /*<<< orphan*/ db_init_test(int);
int /*<<< orphan*/ db_read_random_test();
int /*<<< orphan*/ db_read_seq_test();
int /*<<< orphan*/ db_remove_test();
int /*<<< orphan*/ db_tests();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ print_environment();
int /*<<< orphan*/ print_header();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  long i, count, op;
  int show = 1;
  if (argc != 2) {
    fprintf(stderr, "Usage: nessdb_benchmark <op>\n");
    exit(1);
  }
  if (strcmp(argv[1], "add") == 0) {
    op = 1;
    show = 0;
  } else if (strcmp(argv[1], "get") == 0)
    op = 2;
  else if (strcmp(argv[1], "walk") == 0)
    op = 3;
  else if (strcmp(argv[1], "remove") == 0)
    op = 4;
  else {
    printf("not supported op %s\n", argv[1]);
    exit(1);
  }
  srand(time(NULL));
  print_header();
  print_environment();
  db_init_test(show);
  if (op == 1)
    db_tests();
  else if (op == 3)
    db_read_seq_test();
  else if (op == 2)
    db_read_random_test();
  else if (op == 4)
    db_remove_test();
  db_destroy();
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x2c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1226 <main+0x46>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
lea    0xde9(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xde9(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1258 <main+0x78>
movq   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
jmp    1306 <main+0x126>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdbb(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    1283 <main+0xa3>
movq   $0x2,-0x28(%rbp)
jmp    1301 <main+0x121>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd94(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12ae <main+0xce>
movq   $0x3,-0x28(%rbp)
jmp    12fc <main+0x11c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd6e(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
jne    12d9 <main+0xf9>
movq   $0x4,-0x28(%rbp)
jmp    12f7 <main+0x117>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xd4a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    12fc <main+0x11c>
jmp    1301 <main+0x121>
jmp    1306 <main+0x126>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
mov    $0x0,%al
call   10f0 <print_header@plt>
mov    $0x0,%al
call   1060 <print_environment@plt>
mov    -0x2c(%rbp),%edi
call   10a0 <db_init_test@plt>
cmpq   $0x1,-0x28(%rbp)
jne    1343 <main+0x163>
mov    $0x0,%al
call   1050 <db_tests@plt>
jmp    1392 <main+0x1b2>
cmpq   $0x3,-0x28(%rbp)
jne    135a <main+0x17a>
mov    $0x0,%al
call   10d0 <db_read_seq_test@plt>
jmp    138d <main+0x1ad>
cmpq   $0x2,-0x28(%rbp)
jne    1371 <main+0x191>
mov    $0x0,%al
call   1040 <db_read_random_test@plt>
jmp    1388 <main+0x1a8>
cmpq   $0x4,-0x28(%rbp)
jne    1383 <main+0x1a3>
mov    $0x0,%al
call   10c0 <db_remove_test@plt>
jmp    1388 <main+0x1a8>
jmp    138d <main+0x1ad>
jmp    1392 <main+0x1b2>
mov    $0x0,%al
call   10e0 <db_destroy@plt>
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edi
jne    12ef <main+0x10f>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     125e <main+0x7e>
mov    0x8(%rbx),%rdi
lea    0xe0e(%rip),%rsi
call   1080 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     126d <main+0x8d>
mov    0x8(%rbx),%rdi
lea    0xdf8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
je     1277 <main+0x97>
mov    0x8(%rbx),%rdi
lea    0xde8(%rip),%rsi
call   1080 <strcmp@plt>
test   %rax,%rax
jne    130e <main+0x12e>
mov    $0x1,%r15b
xor    %ebx,%ebx
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    1282 <main+0xa2>
xor    %r14d,%r14d
mov    $0x1,%bl
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %ebp,%ebp
jmp    1282 <main+0xa2>
mov    $0x1,%r12b
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    127f <main+0x9f>
mov    $0x1,%r14b
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %edi,%edi
call   10b0 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
xor    %eax,%eax
call   10f0 <print_header@plt>
xor    %eax,%eax
call   1060 <print_environment@plt>
mov    %ebp,%edi
call   10a0 <db_init_test@plt>
test   %bl,%bl
je     12b2 <main+0xd2>
xor    %eax,%eax
call   1050 <db_tests@plt>
jmp    12da <main+0xfa>
test   %r14b,%r14b
je     12c0 <main+0xe0>
xor    %eax,%eax
call   10d0 <db_read_seq_test@plt>
jmp    12da <main+0xfa>
test   %r12b,%r12b
je     12ce <main+0xee>
xor    %eax,%eax
call   1040 <db_read_random_test@plt>
jmp    12da <main+0xfa>
test   %r15b,%r15b
je     12da <main+0xfa>
xor    %eax,%eax
call   10c0 <db_remove_test@plt>
xor    %eax,%eax
call   10e0 <db_destroy@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
lea    0xd01(%rip),%rsi
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x8(%rbx),%rsi
lea    0xd19(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: nessdb_benchmark <op>\0A\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"get\00"
@.str.3 = [5 x i8] c"walk\00"
@.str.4 = [7 x i8] c"remove\00"
@.str.5 = [21 x i8] c"not supported op %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i64 1, i64* %8
store i32 0, i32* %9
br label %53
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %23
store i64 2, i64* %8
br label %52
30: ; preds = %23
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 1
%33 = load i8*, i8** %32
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %30
store i64 3, i64* %8
br label %51
37: ; preds = %30
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %37
store i64 4, i64* %8
br label %50
44: ; preds = %37
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 1
%47 = load i8*, i8** %46
%48 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %47)
%49 = call i32 @exit(i32 1)
unreachable
50: ; preds = %43
br label %51
51: ; preds = %50, %36
br label %52
52: ; preds = %51, %29
br label %53
53: ; preds = %52, %22
%54 = call i32 @time(i32* null)
%55 = call i32 @srand(i32 %54)
%56 = call i32 (...) @print_header()
%57 = call i32 (...) @print_environment()
%58 = load i32, i32* %9
%59 = call i32 @db_init_test(i32 %58)
%60 = load i64, i64* %8
%61 = icmp eq i64 %60, 1
br i1 %61, label %62, label %64
62: ; preds = %53
%63 = call i32 (...) @db_tests()
br label %82
64: ; preds = %53
%65 = load i64, i64* %8
%66 = icmp eq i64 %65, 3
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 (...) @db_read_seq_test()
br label %81
69: ; preds = %64
%70 = load i64, i64* %8
%71 = icmp eq i64 %70, 2
br i1 %71, label %72, label %74
72: ; preds = %69
%73 = call i32 (...) @db_read_random_test()
br label %80
74: ; preds = %69
%75 = load i64, i64* %8
%76 = icmp eq i64 %75, 4
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (...) @db_remove_test()
br label %79
79: ; preds = %77, %74
br label %80
80: ; preds = %79, %72
br label %81
81: ; preds = %80, %67
br label %82
82: ; preds = %81, %62
%83 = call i32 (...) @db_destroy()
ret i32 1
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [30 x i8] c"Usage: nessdb_benchmark <op>\0A\00"
@.str.1 = [4 x i8] c"add\00"
@.str.2 = [4 x i8] c"get\00"
@.str.3 = [5 x i8] c"walk\00"
@.str.4 = [7 x i8] c"remove\00"
@.str.5 = [21 x i8] c"not supported op %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %29, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %13
%18 = load i8*, i8** %9
%19 = tail call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = load i8*, i8** %9
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %9
%27 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %21, %17, %13, %8
%30 = phi i1 [ true, %8 ], [ false, %13 ], [ false, %17 ], [ false, %21 ]
%31 = phi i1 [ false, %8 ], [ false, %13 ], [ true, %17 ], [ false, %21 ]
%32 = phi i1 [ false, %8 ], [ true, %13 ], [ false, %17 ], [ false, %21 ]
%33 = phi i1 [ false, %8 ], [ false, %13 ], [ false, %17 ], [ true, %21 ]
%34 = phi i32 [ 0, %8 ], [ 1, %13 ], [ 1, %17 ], [ 1, %21 ]
%35 = tail call i32 @time(i32* null)
%36 = tail call i32 @srand(i32 %35)
%37 = tail call i32 (...) @print_header()
%38 = tail call i32 (...) @print_environment()
%39 = tail call i32 @db_init_test(i32 %34)
br i1 %30, label %40, label %42
40: ; preds = %29
%41 = tail call i32 (...) @db_tests()
br label %51
42: ; preds = %29
br i1 %31, label %43, label %45
43: ; preds = %42
%44 = tail call i32 (...) @db_read_seq_test()
br label %51
45: ; preds = %42
br i1 %32, label %46, label %48
46: ; preds = %45
%47 = tail call i32 (...) @db_read_random_test()
br label %51
48: ; preds = %45
br i1 %33, label %49, label %51
49: ; preds = %48
%50 = tail call i32 (...) @db_remove_test()
br label %51
51: ; preds = %43, %48, %49, %46, %40
%52 = tail call i32 (...) @db_destroy()
ret i32 1
}