#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 */
typedef int /*<<< orphan*/ sqlite3;

/* Variables and functions */
int /*<<< orphan*/ *_db_connect(unsigned char const *);
int /*<<< orphan*/ _insert_into(int /*<<< orphan*/ *, unsigned char const *,
                                unsigned int, unsigned int);
int /*<<< orphan*/ _join_nloop(int /*<<< orphan*/ *, char *, char *,
                               unsigned int);
int /*<<< orphan*/ _select_from_unit(int /*<<< orphan*/ *,
                                     unsigned char const *, unsigned int,
                                     int /*<<< orphan*/);
int /*<<< orphan*/ _update_table(int /*<<< orphan*/ *, unsigned char const *,
                                 unsigned int, unsigned int);
unsigned int atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sqlite3_close(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(unsigned char const *, char *);
int main(int argc, char *argv[]) {
  unsigned int nb_rec = 0, sz_rec = 0, i = 0, _max = 0;
  unsigned const char *db_name = NULL, *tab_name = NULL, *q_type = NULL,
                      *tab_name_2 = NULL;
  sqlite3 *db = NULL;
  printf("Micro Benchmark for SQLite embedded database \n");
  if (argc < 5) {
    printf("Usage: %s QuType DBFile TabName NbRec QSize [Join:TabName_2] \n",
           argv[0]);
    return 1;
  }
  q_type = argv[1];
  db_name = argv[2];
  tab_name = argv[3];
  nb_rec = atoi(argv[4]);
  sz_rec = atoi(argv[5]);
  tab_name_2 = argv[6];
  if (strcmp(q_type, "insert") == 0) {
    db = _db_connect(db_name);
    _insert_into(db, tab_name, nb_rec, sz_rec);
    sqlite3_close(db);
  } else if (strcmp(q_type, "select") == 0) {
    db = _db_connect(db_name);
    fprintf(stdout, "Select query with sequantial pattern... \n");
    _select_from_unit(db, tab_name, nb_rec, 0);
    sqlite3_close(db);
  } else if (strcmp(q_type, "update") == 0) {
    db = _db_connect(db_name);
    _update_table(db, tab_name, nb_rec, sz_rec);
    sqlite3_close(db);
  } else if (strcmp(q_type, "join") == 0) {
    db = _db_connect(db_name);
    _join_nloop(db, "table_1", "table_2", nb_rec);
    sqlite3_close(db);
  } else {
    printf("Invalid request of %d  size %d \n", nb_rec, sz_rec);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x48(%rbp)
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x5,-0x8(%rbp)
jge    1233 <main+0x93>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13e8 <main+0x248>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   10c0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xde0(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12cb <main+0x12b>
mov    -0x28(%rbp),%rdi
call   10b0 <_db_connect@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <_insert_into@plt>
mov    -0x48(%rbp),%rdi
call   1080 <sqlite3_close@plt>
jmp    13e1 <main+0x241>
mov    -0x38(%rbp),%rdi
lea    0xd9f(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1327 <main+0x187>
mov    -0x28(%rbp),%rdi
call   10b0 <_db_connect@plt>
mov    %rax,-0x48(%rbp)
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1040 <_select_from_unit@plt>
mov    -0x48(%rbp),%rdi
call   1080 <sqlite3_close@plt>
jmp    13dc <main+0x23c>
mov    -0x38(%rbp),%rdi
lea    0xd74(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    136f <main+0x1cf>
mov    -0x28(%rbp),%rdi
call   10b0 <_db_connect@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1090 <_update_table@plt>
mov    -0x48(%rbp),%rdi
call   1080 <sqlite3_close@plt>
jmp    13d7 <main+0x237>
mov    -0x38(%rbp),%rdi
lea    0xd33(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    13be <main+0x21e>
mov    -0x28(%rbp),%rdi
call   10b0 <_db_connect@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%ecx
lea    0xd0e(%rip),%rsi
lea    0xd0f(%rip),%rdx
call   10a0 <_join_nloop@plt>
mov    -0x48(%rbp),%rdi
call   1080 <sqlite3_close@plt>
jmp    13d2 <main+0x232>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xcf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    13d7 <main+0x237>
jmp    13dc <main+0x23c>
jmp    13e1 <main+0x241>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%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,%rbx
mov    %edi,%ebp
lea    0xeed(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x4,%ebp
jg     11ec <main+0x3c>
mov    (%rbx),%rsi
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
jmp    1329 <main+0x179>
mov    0x8(%rbx),%rbp
mov    0x10(%rbx),%r13
mov    0x18(%rbx),%r15
mov    0x20(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r14d
mov    0x28(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %eax,%r12d
lea    0xe28(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1283 <main+0xd3>
lea    0xe1b(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a1 <main+0xf1>
lea    0xe38(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12dd <main+0x12d>
lea    0xe27(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12fb <main+0x14b>
lea    0xe24(%rip),%rdi
xor    %ebx,%ebx
mov    %r14d,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1329 <main+0x179>
mov    %r13,%rdi
call   10c0 <_db_connect@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r12d,%ecx
call   1040 <_insert_into@plt>
jmp    131f <main+0x16f>
mov    %r13,%rdi
call   10c0 <_db_connect@plt>
mov    %rax,%rbp
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
lea    0xd91(%rip),%rsi
call   1080 <fprintf@plt>
xor    %ebx,%ebx
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1050 <_select_from_unit@plt>
mov    %rbp,%rdi
call   1090 <sqlite3_close@plt>
jmp    1329 <main+0x179>
mov    %r13,%rdi
call   10c0 <_db_connect@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %r14d,%edx
mov    %r12d,%ecx
call   10a0 <_update_table@plt>
jmp    131f <main+0x16f>
mov    %r13,%rdi
call   10c0 <_db_connect@plt>
mov    %rax,%rbx
lea    0xd76(%rip),%rsi
lea    0xd77(%rip),%rdx
mov    %rax,%rdi
mov    %r14d,%ecx
call   10b0 <_join_nloop@plt>
mov    %rbx,%rdi
call   1090 <sqlite3_close@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Micro Benchmark for SQLite embedded database \0A\00"
@.str.1 = [63 x i8] c"Usage: %s QuType DBFile TabName NbRec QSize [Join:TabName_2] \0A\00"
@.str.2 = [7 x i8] c"insert\00"
@.str.3 = [7 x i8] c"select\00"
@stdout = global i32 0
@.str.4 = [42 x i8] c"Select query with sequantial pattern... \0A\00"
@.str.5 = [7 x i8] c"update\00"
@.str.6 = [5 x i8] c"join\00"
@.str.7 = [8 x i8] c"table_1\00"
@.str.8 = [8 x i8] c"table_2\00"
@.str.9 = [33 x i8] c"Invalid request of %d size %d \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 i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32*
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 i32 0, i32* %8
store i32 0, i32* %9
store i8* null, i8** %10
store i8* null, i8** %11
store i8* null, i8** %12
store i8* null, i8** %13
store i32* null, i32** %14
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 5
br i1 %17, label %18, label %23
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8* %21)
store i32 1, i32* %3
br label %106
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %12
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
store i8* %29, i8** %10
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
store i8* %32, i8** %11
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 4
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %6
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 5
%39 = load i8*, i8** %38
%40 = call i32 @atoi(i8* %39)
store i32 %40, i32* %7
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 6
%43 = load i8*, i8** %42
store i8* %43, i8** %13
%44 = load i8*, i8** %12
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %57
47: ; preds = %23
%48 = load i8*, i8** %10
%49 = call i32* @_db_connect(i8* %48)
store i32* %49, i32** %14
%50 = load i32*, i32** %14
%51 = load i8*, i8** %11
%52 = load i32, i32* %6
%53 = load i32, i32* %7
%54 = call i32 @_insert_into(i32* %50, i8* %51, i32 %52, i32 %53)
%55 = load i32*, i32** %14
%56 = call i32 @sqlite3_close(i32* %55)
br label %105
57: ; preds = %23
%58 = load i8*, i8** %12
%59 = call i64 @strcmp(i8* %58, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%60 = icmp eq i64 %59, 0
br i1 %60, label %61, label %72
61: ; preds = %57
%62 = load i8*, i8** %10
%63 = call i32* @_db_connect(i8* %62)
store i32* %63, i32** %14
%64 = load i32, i32* @stdout
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32*, i32** %14
%67 = load i8*, i8** %11
%68 = load i32, i32* %6
%69 = call i32 @_select_from_unit(i32* %66, i8* %67, i32 %68, i32 0)
%70 = load i32*, i32** %14
%71 = call i32 @sqlite3_close(i32* %70)
br label %104
72: ; preds = %57
%73 = load i8*, i8** %12
%74 = call i64 @strcmp(i8* %73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %86
76: ; preds = %72
%77 = load i8*, i8** %10
%78 = call i32* @_db_connect(i8* %77)
store i32* %78, i32** %14
%79 = load i32*, i32** %14
%80 = load i8*, i8** %11
%81 = load i32, i32* %6
%82 = load i32, i32* %7
%83 = call i32 @_update_table(i32* %79, i8* %80, i32 %81, i32 %82)
%84 = load i32*, i32** %14
%85 = call i32 @sqlite3_close(i32* %84)
br label %103
86: ; preds = %72
%87 = load i8*, i8** %12
%88 = call i64 @strcmp(i8* %87, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %98
90: ; preds = %86
%91 = load i8*, i8** %10
%92 = call i32* @_db_connect(i8* %91)
store i32* %92, i32** %14
%93 = load i32*, i32** %14
%94 = load i32, i32* %6
%95 = call i32 @_join_nloop(i32* %93, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %94)
%96 = load i32*, i32** %14
%97 = call i32 @sqlite3_close(i32* %96)
br label %102
98: ; preds = %86
%99 = load i32, i32* %6
%100 = load i32, i32* %7
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %99, i32 %100)
br label %102
102: ; preds = %98, %90
br label %103
103: ; preds = %102, %76
br label %104
104: ; preds = %103, %61
br label %105
105: ; preds = %104, %47
store i32 0, i32* %3
br label %106
106: ; preds = %105, %18
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@.str.1 = [63 x i8] c"Usage: %s QuType DBFile TabName NbRec QSize [Join:TabName_2] \0A\00"
@.str.2 = [7 x i8] c"insert\00"
@.str.3 = [7 x i8] c"select\00"
@stdout = global i32 0
@.str.4 = [42 x i8] c"Select query with sequantial pattern... \0A\00"
@.str.5 = [7 x i8] c"update\00"
@.str.6 = [5 x i8] c"join\00"
@.str.7 = [8 x i8] c"table_1\00"
@.str.8 = [8 x i8] c"table_2\00"
@.str.9 = [33 x i8] c"Invalid request of %d size %d \0A\00"
@str = [46 x i8] c"Micro Benchmark for SQLite embedded database \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%4 = icmp slt i32 %0, 5
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0), i8* %6)
br label %52
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 4
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 5
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %8
%24 = tail call i32* @_db_connect(i8* %12)
%25 = tail call i32 @_insert_into(i32* %24, i8* %14, i32 %17, i32 %20)
%26 = tail call i32 @sqlite3_close(i32* %24)
br label %52
27: ; preds = %8
%28 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = tail call i32* @_db_connect(i8* %12)
%32 = load i32, i32* @stdout
%33 = tail call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%34 = tail call i32 @_select_from_unit(i32* %31, i8* %14, i32 %17, i32 0)
%35 = tail call i32 @sqlite3_close(i32* %31)
br label %52
36: ; preds = %27
%37 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = tail call i32* @_db_connect(i8* %12)
%41 = tail call i32 @_update_table(i32* %40, i8* %14, i32 %17, i32 %20)
%42 = tail call i32 @sqlite3_close(i32* %40)
br label %52
43: ; preds = %36
%44 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = tail call i32* @_db_connect(i8* %12)
%48 = tail call i32 @_join_nloop(i32* %47, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), i32 %17)
%49 = tail call i32 @sqlite3_close(i32* %47)
br label %52
50: ; preds = %43
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %17, i32 %20)
br label %52
52: ; preds = %23, %39, %50, %46, %30, %5
%53 = phi i32 [ 1, %5 ], [ 0, %30 ], [ 0, %46 ], [ 0, %50 ], [ 0, %39 ], [ 0, %23 ]
ret i32 %53
}