// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3Close
static int sqlite3Close(sqlite3 *db, int forceZombie){
  if( !db ){
    return SQLITE_OK;
  }
  if( !sqlite3SafetyCheckSickOrOk(db) ){
    return SQLITE_MISUSE_BKPT;
  }
  sqlite3_mutex_enter(db->mutex);

  /* Force xDisconnect calls on all virtual tables */
  disconnectAllVtab(db);

  /* If a transaction is open, the disconnectAllVtab() call above
  ** will not have called the xDisconnect() method on any virtual
  ** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()
  ** call will do so. We need to do this before the check for active
  ** SQL statements below, as the v-table implementation may be storing
  ** some prepared statements internally.
  */
  sqlite3VtabRollback(db);

  /* Legacy behavior (sqlite3_close() behavior) is to return
  ** SQLITE_BUSY if the connection can not be closed immediately.
  */
  if( !forceZombie && connectionIsBusy(db) ){
    sqlite3Error(db, SQLITE_BUSY, "unable to close due to unfinalized "
       "statements or unfinished backups");
    sqlite3_mutex_leave(db->mutex);
    return SQLITE_BUSY;
  }

#ifdef SQLITE_ENABLE_SQLLOG
  if( sqlite3GlobalConfig.xSqllog ){
    /* Closing the handle. Fourth parameter is passed the value 2. */
    sqlite3GlobalConfig.xSqllog(sqlite3GlobalConfig.pSqllogArg, db, 0, 2);
  }
#endif

  /* Convert the connection into a zombie and then close it.
  */
  db->magic = SQLITE_MAGIC_ZOMBIE;
  sqlite3LeaveMutexAndCloseZombie(db);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x14ed2
movl %esi, %r15d
movq %rdi, %r14
callq 0x15abc
testl %eax, %eax
je 0x14e85
movslq 0x28(%r14), %rax
testq %rax, %rax
jle 0x14e61
movq 0x20(%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
movq 0x8(%rcx,%rsi), %rdi
testq %rdi, %rdi
je 0x14de2
movq (%rdi), %r8
movq 0x8(%rdi), %rdi
movq %r8, 0x8(%rdi)
addq $0x20, %rsi
cmpq %rsi, %rdx
jne 0x14dcd
testl %eax, %eax
jle 0x14e61
xorl %r12d, %r12d
movq 0x20(%r14), %rax
movq %r12, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
testq %rax, %rax
je 0x14e55
movq 0x10(%rax), %r13
testq %r13, %r13
je 0x14e55
movq 0x10(%r13), %rax
testb $0x10, 0x46(%rax)
je 0x14e4f
movq 0x58(%rax), %rdi
testq %rdi, %rdi
je 0x14e4f
cmpq %r14, (%rdi)
je 0x14e3f
movq %rdi, %rax
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x14e4f
cmpq %r14, (%rdi)
jne 0x14e28
addq $0x28, %rax
jmp 0x14e43
addq $0x58, %rax
movq 0x28(%rdi), %rcx
movq %rcx, (%rax)
callq 0x23229
movq (%r13), %r13
jmp 0x14e0b
incq %r12
movslq 0x28(%r14), %rax
cmpq %rax, %r12
jl 0x14df2
movq %r14, %rdi
movl $0x88, %esi
callq 0x2457d
testl %r15d, %r15d
je 0x14eab
movl $0x64cffc7f, 0x5c(%r14) # imm = 0x64CFFC7F
movq %r14, %rdi
callq 0xe727
jmp 0x14ed2
leaq 0x68558(%rip), %rsi     # 0x7d3e4
leaq 0x646a6(%rip), %rcx     # 0x79539
movl $0x15, %ebx
movl $0x15, %edi
movl $0x1c6c8, %edx          # imm = 0x1C6C8
xorl %eax, %eax
callq 0xb8cc
jmp 0x14ed2
movq %r14, %rdi
callq 0x67a76
testl %eax, %eax
je 0x14e73
leaq 0x6818c(%rip), %rdx     # 0x7d04a
movl $0x5, %ebx
movq %r14, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0xc8f4
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq