// File: /workspace/github_c_makefile_star2_O2/ukontainer[P]sqlite-bench/benchmark.c
// Function: benchmark_open
void benchmark_open() {
  assert(db_ == NULL);

  int status;
  char file_name[100];
  char* err_msg = NULL;
  db_num_++;

  /* Open database */
  char *tmp_dir = FLAGS_db;
  snprintf(file_name, sizeof(file_name),
            "%sdbbench_sqlite3-%d.db",
            tmp_dir,
            db_num_);
  status = sqlite3_open(file_name, &db_);
  if (status) {
    fprintf(stderr, "open error: %s\n", sqlite3_errmsg(db_));
    exit(1);
  }

  /* Change SQLite cache size */
  char cache_size[100];
  snprintf(cache_size, sizeof(cache_size), "PRAGMA cache_size = %d",
            FLAGS_num_pages);
  status = sqlite3_exec(db_, cache_size, NULL, NULL, &err_msg);
  exec_error_check(status, err_msg);

  /* FLAGS_page_size is defaulted to 1024 */
  if (FLAGS_page_size != 1024) {
    char page_size[100];
    snprintf(page_size, sizeof(page_size), "PRAGMA page_size = %d",
              FLAGS_page_size);
    status = sqlite3_exec(db_, page_size, NULL, NULL, &err_msg);
    exec_error_check(status, err_msg);
  }

  /* Change journal mode to WAL if WAL enabled flag is on */
  if (FLAGS_WAL_enabled) {
    char* WAL_stmt = "PRAGMA journal_mode = WAL";

    /* Default cache size is a combined 4 MB */
    char* WAL_checkpoint = "PRAGMA wal_autocheckpoint = 4096";
    status = sqlite3_exec(db_, WAL_stmt, NULL, NULL, &err_msg);
    exec_error_check(status, err_msg);
    status = sqlite3_exec(db_, WAL_checkpoint, NULL, NULL, &err_msg);
    exec_error_check(status, err_msg);
  }

  /* Change locking mode to exclusive and create tables/index for database */
  char* locking_stmt = "PRAGMA locking_mode = EXCLUSIVE";
  char* create_stmt =
          "CREATE TABLE test (key blob, value blob, PRIMARY KEY (key))";
  char* stmt_array[] = { locking_stmt, create_stmt, NULL };
  int stmt_array_length = sizeof(stmt_array) / sizeof(char*);
  for (int i = 0; i < stmt_array_length; i++) {
    status = sqlite3_exec(db_, stmt_array[i], NULL, NULL, &err_msg);
    exec_error_check(status, err_msg);
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
cmpq $0x0, 0x1951eb(%rip)    # 0x5977f0
jne 0x4027b1
andq $0x0, 0x8(%rsp)
movl 0x1951e0(%rip), %r8d    # 0x5977f8
incl %r8d
movl %r8d, 0x1951d6(%rip)    # 0x5977f8
movq $0x597870, %rax         # imm = 0x597870
movq (%rax), %rcx
leaq 0x135b3f(%rip), %rdx    # 0x538172
leaq 0xf0(%rsp), %rbx
pushq $0x64
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x474e90
leaq 0x1951a1(%rip), %rsi    # 0x5977f0
movq %rbx, %rdi
callq 0x4114a6
testl %eax, %eax
jne 0x4027d0
movq $0x597864, %rax         # imm = 0x597864
movl (%rax), %ecx
leaq 0x135b2b(%rip), %rdx    # 0x53819a
leaq 0x80(%rsp), %rbx
pushq $0x64
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x474e90
movq 0x195165(%rip), %rdi    # 0x5977f0
leaq 0x8(%rsp), %r14
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x40d53b
movq (%r14), %rsi
movl %eax, %edi
callq 0x402df4
movq $0x597860, %rax         # imm = 0x597860
movl (%rax), %ecx
cmpl $0x400, %ecx            # imm = 0x400
je 0x4026f8
leaq 0x135af0(%rip), %rdx    # 0x5381b1
leaq 0x10(%rsp), %rbx
pushq $0x64
popq %rsi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x474e90
movq 0x195116(%rip), %rdi    # 0x5977f0
leaq 0x8(%rsp), %r14
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r14, %r8
callq 0x40d53b
movq (%r14), %rsi
movl %eax, %edi
callq 0x402df4
movq $0x59786a, %rax         # imm = 0x59786A
cmpb $0x1, (%rax)
jne 0x402751
movq 0x1950e5(%rip), %rdi    # 0x5977f0
leaq 0x135ab5(%rip), %rsi    # 0x5381c7
leaq 0x8(%rsp), %rbx
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x40d53b
movq (%rbx), %rsi
movl %eax, %edi
callq 0x402df4
movq 0x1950bc(%rip), %rdi    # 0x5977f0
leaq 0x135aa6(%rip), %rsi    # 0x5381e1
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x40d53b
movq (%rbx), %rsi
movl %eax, %edi
callq 0x402df4
leaq 0x135aaa(%rip), %rax    # 0x538202
movq %rax, 0x10(%rsp)
leaq 0x135abe(%rip), %rax    # 0x538222
movq %rax, 0x18(%rsp)
andq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x8(%rsp), %rbx
cmpq $0x3, %r14
je 0x4027a6
movq 0x19506c(%rip), %rdi    # 0x5977f0
movq 0x10(%rsp,%r14,8), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x40d53b
movq 0x8(%rsp), %rsi
movl %eax, %edi
callq 0x402df4
incq %r14
jmp 0x402777
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r14
retq
leaq 0x13598c(%rip), %rdi    # 0x538144
leaq 0x135991(%rip), %rsi    # 0x538150
leaq 0x135996(%rip), %rcx    # 0x53815c
movl $0x141, %edx            # imm = 0x141
callq 0x46db40
movq $0x5956a8, %rax         # imm = 0x5956A8
movq (%rax), %rbx
movq 0x19500f(%rip), %rdi    # 0x5977f0
callq 0x40d88a
leaq 0x13599d(%rip), %rsi    # 0x53818a
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0x474dd0
pushq $0x1
popq %rdi
callq 0x4742a0