// File: /workspace/github_c_makefile_star2_O1/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, 0x1a1957(%rip)    # 0x5a47f0
jne 0x403042
movq $0x0, 0x8(%rsp)
movl 0x1a1949(%rip), %r8d    # 0x5a47f8
incl %r8d
movl %r8d, 0x1a193f(%rip)    # 0x5a47f8
movq $0x5a4870, %rax         # imm = 0x5A4870
movq (%rax), %rcx
leaq 0x1472a8(%rip), %rdx    # 0x54a172
leaq 0xf0(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x487370
leaq 0x1a1908(%rip), %rsi    # 0x5a47f0
movq %rbx, %rdi
callq 0x41405e
testl %eax, %eax
jne 0x403061
movq $0x5a4864, %rax         # imm = 0x5A4864
movl (%rax), %ecx
leaq 0x147292(%rip), %rdx    # 0x54a19a
leaq 0x80(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x487370
movq 0x1a18ca(%rip), %rdi    # 0x5a47f0
leaq 0x8(%rsp), %r8
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f24b
testl %eax, %eax
jne 0x403066
movq $0x5a4860, %rax         # imm = 0x5A4860
movl (%rax), %ecx
cmpl $0x400, %ecx            # imm = 0x400
je 0x402f8b
leaq 0x14725a(%rip), %rdx    # 0x54a1b1
leaq 0x10(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x487370
movq 0x1a187e(%rip), %rdi    # 0x5a47f0
leaq 0x8(%rsp), %r8
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f24b
testl %eax, %eax
jne 0x403070
movq $0x5a486a, %rax         # imm = 0x5A486A
cmpb $0x1, (%rax)
jne 0x402fdf
movq 0x1a1852(%rip), %rdi    # 0x5a47f0
leaq 0x147222(%rip), %rsi    # 0x54a1c7
leaq 0x8(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f24b
testl %eax, %eax
jne 0x40307a
movq 0x1a182e(%rip), %rdi    # 0x5a47f0
leaq 0x147218(%rip), %rsi    # 0x54a1e1
leaq 0x8(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f24b
testl %eax, %eax
jne 0x403084
leaq 0x14721c(%rip), %rax    # 0x54a202
movq %rax, 0x10(%rsp)
leaq 0x147230(%rip), %rax    # 0x54a222
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x8(%rsp), %rbx
movq 0x1a17e1(%rip), %rdi    # 0x5a47f0
movq 0x10(%rsp,%r14,8), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x40f24b
testl %eax, %eax
jne 0x403038
incq %r14
cmpq $0x3, %r14
jne 0x403008
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r14
retq
leaq 0x8(%rsp), %rdi
callq 0x401aa5
leaq 0x1470fb(%rip), %rdi    # 0x54a144
leaq 0x147100(%rip), %rsi    # 0x54a150
leaq 0x147105(%rip), %rcx    # 0x54a15c
movl $0x141, %edx            # imm = 0x141
callq 0x480020
callq 0x4019b6
leaq 0x8(%rsp), %rdi
callq 0x4019e9
leaq 0x8(%rsp), %rdi
callq 0x401a18
leaq 0x8(%rsp), %rdi
callq 0x401a47
leaq 0x8(%rsp), %rdi
callq 0x401a76