#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 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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%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,-0x18(%rbp)
movl   $0x0,-0x1c(%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,-0x18(%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,-0x18(%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,-0x18(%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    -0x1c(%rbp),%edi
call   10a0 <db_init_test@plt>
cmpq   $0x1,-0x18(%rbp)
jne    1343 <main+0x163>
mov    $0x0,%al
call   1050 <db_tests@plt>
jmp    1392 <main+0x1b2>
cmpq   $0x3,-0x18(%rbp)
jne    135a <main+0x17a>
mov    $0x0,%al
call   10d0 <db_read_seq_test@plt>
jmp    138d <main+0x1ad>
cmpq   $0x2,-0x18(%rbp)
jne    1371 <main+0x191>
mov    $0x0,%al
call   1040 <db_read_random_test@plt>
jmp    1388 <main+0x1a8>
cmpq   $0x4,-0x18(%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    $0x20,%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 i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i64 1, i64* %6
store i32 0, i32* %7
br label %51
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i64 2, i64* %6
br label %50
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %28
store i64 3, i64* %6
br label %49
35: ; preds = %28
%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 ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %35
store i64 4, i64* %6
br label %48
42: ; preds = %35
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %45)
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %41
br label %49
49: ; preds = %48, %34
br label %50
50: ; preds = %49, %27
br label %51
51: ; preds = %50, %20
%52 = call i32 @time(i32* null)
%53 = call i32 @srand(i32 %52)
%54 = call i32 (...) @print_header()
%55 = call i32 (...) @print_environment()
%56 = load i32, i32* %7
%57 = call i32 @db_init_test(i32 %56)
%58 = load i64, i64* %6
%59 = icmp eq i64 %58, 1
br i1 %59, label %60, label %62
60: ; preds = %51
%61 = call i32 (...) @db_tests()
br label %80
62: ; preds = %51
%63 = load i64, i64* %6
%64 = icmp eq i64 %63, 3
br i1 %64, label %65, label %67
65: ; preds = %62
%66 = call i32 (...) @db_read_seq_test()
br label %79
67: ; preds = %62
%68 = load i64, i64* %6
%69 = icmp eq i64 %68, 2
br i1 %69, label %70, label %72
70: ; preds = %67
%71 = call i32 (...) @db_read_random_test()
br label %78
72: ; preds = %67
%73 = load i64, i64* %6
%74 = icmp eq i64 %73, 4
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 (...) @db_remove_test()
br label %77
77: ; preds = %75, %72
br label %78
78: ; preds = %77, %70
br label %79
79: ; preds = %78, %65
br label %80
80: ; preds = %79, %60
%81 = 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
}