// File: /workspace/github_c_makefile_star2_O3/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, 0x1a1947(%rip)    # 0x5a47f0
jne 0x403052
movq $0x0, 0x8(%rsp)
movl 0x1a1939(%rip), %r8d    # 0x5a47f8
incl %r8d
movl %r8d, 0x1a192f(%rip)    # 0x5a47f8
movq $0x5a4870, %rax         # imm = 0x5A4870
movq (%rax), %rcx
leaq 0x147298(%rip), %rdx    # 0x54a172
leaq 0xf0(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4869f0
leaq 0x1a18f8(%rip), %rsi    # 0x5a47f0
movq %rbx, %rdi
callq 0x414112
testl %eax, %eax
jne 0x403071
movq $0x5a4864, %rax         # imm = 0x5A4864
movl (%rax), %ecx
leaq 0x147282(%rip), %rdx    # 0x54a19a
leaq 0x80(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4869f0
movq 0x1a18ba(%rip), %rdi    # 0x5a47f0
leaq 0x8(%rsp), %r8
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f472
testl %eax, %eax
jne 0x403076
movq $0x5a4860, %rax         # imm = 0x5A4860
movl (%rax), %ecx
cmpl $0x400, %ecx            # imm = 0x400
je 0x402f9b
leaq 0x14724a(%rip), %rdx    # 0x54a1b1
leaq 0x10(%rsp), %rbx
movl $0x64, %esi
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4869f0
movq 0x1a186e(%rip), %rdi    # 0x5a47f0
leaq 0x8(%rsp), %r8
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f472
testl %eax, %eax
jne 0x403080
movq $0x5a486a, %rax         # imm = 0x5A486A
cmpb $0x1, (%rax)
jne 0x402fef
movq 0x1a1842(%rip), %rdi    # 0x5a47f0
leaq 0x147212(%rip), %rsi    # 0x54a1c7
leaq 0x8(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f472
testl %eax, %eax
jne 0x40308a
movq 0x1a181e(%rip), %rdi    # 0x5a47f0
leaq 0x147208(%rip), %rsi    # 0x54a1e1
leaq 0x8(%rsp), %r8
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x40f472
testl %eax, %eax
jne 0x403094
leaq 0x14720c(%rip), %rax    # 0x54a202
movq %rax, 0x10(%rsp)
leaq 0x147220(%rip), %rax    # 0x54a222
movq %rax, 0x18(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
leaq 0x8(%rsp), %rbx
movq 0x1a17d1(%rip), %rdi    # 0x5a47f0
movq 0x10(%rsp,%r14,8), %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %rbx, %r8
callq 0x40f472
testl %eax, %eax
jne 0x403048
incq %r14
cmpq $0x3, %r14
jne 0x403018
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r14
retq
leaq 0x8(%rsp), %rdi
callq 0x401abf
leaq 0x1470eb(%rip), %rdi    # 0x54a144
leaq 0x1470f0(%rip), %rsi    # 0x54a150
leaq 0x1470f5(%rip), %rcx    # 0x54a15c
movl $0x141, %edx            # imm = 0x141
callq 0x47f6a0
callq 0x4019d0
leaq 0x8(%rsp), %rdi
callq 0x401a03
leaq 0x8(%rsp), %rdi
callq 0x401a32
leaq 0x8(%rsp), %rdi
callq 0x401a61
leaq 0x8(%rsp), %rdi
callq 0x401a90