// File: /workspace/github_c_makefile_star2_O3/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 0x14ec4
movl %esi, %r15d
movq %rdi, %r14
movl 0x5c(%rdi), %eax
cmpl $0xa029a697, %eax       # imm = 0xA029A697
je 0x14d89
cmpl $0xf03b7906, %eax       # imm = 0xF03B7906
je 0x14d89
cmpl $0x4b771290, %eax       # imm = 0x4B771290
jne 0x14e86
movslq 0x28(%r14), %rax
testq %rax, %rax
jle 0x14e39
movq 0x20(%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
movq 0x8(%rcx,%rsi), %rdi
testq %rdi, %rdi
je 0x14db8
movq (%rdi), %r8
movq 0x8(%rdi), %rdi
movq %r8, 0x8(%rdi)
addq $0x20, %rsi
cmpq %rsi, %rdx
jne 0x14da3
xorl %r12d, %r12d
movq 0x20(%r14), %rcx
movq %r12, %rdx
shlq $0x5, %rdx
movq 0x18(%rcx,%rdx), %rcx
testq %rcx, %rcx
je 0x14e2e
movq 0x10(%rcx), %r13
testq %r13, %r13
je 0x14e2e
movq 0x10(%r13), %rax
testb $0x10, 0x46(%rax)
je 0x14e21
movq 0x58(%rax), %rdi
testq %rdi, %rdi
je 0x14e21
cmpq %r14, (%rdi)
je 0x14e11
movq %rdi, %rax
movq 0x28(%rdi), %rdi
testq %rdi, %rdi
je 0x14e21
cmpq %r14, (%rdi)
jne 0x14dfa
addq $0x28, %rax
jmp 0x14e15
addq $0x58, %rax
movq 0x28(%rdi), %rcx
movq %rcx, (%rax)
callq 0x22dc8
movq (%r13), %r13
testq %r13, %r13
jne 0x14de2
movl 0x28(%r14), %eax
incq %r12
movslq %eax, %rcx
cmpq %rcx, %r12
jl 0x14dc4
movq %r14, %rdi
movl $0x88, %esi
callq 0x2408c
testl %r15d, %r15d
je 0x14e5d
movl $0x64cffc7f, 0x5c(%r14) # imm = 0x64CFFC7F
movq %r14, %rdi
callq 0xe803
jmp 0x14ec4
movq %r14, %rdi
callq 0x6787a
testl %eax, %eax
je 0x14e4b
leaq 0x681da(%rip), %rdx     # 0x7d04a
movl $0x5, %ebx
movq %r14, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0xca2d
jmp 0x14ec4
leaq 0x65c2a(%rip), %rsi     # 0x7aab7
leaq 0x684cc(%rip), %rdx     # 0x7d360
movl $0x15, %ebx
movl $0x15, %edi
xorl %eax, %eax
callq 0xb9c7
leaq 0x68538(%rip), %rsi     # 0x7d3e4
leaq 0x64686(%rip), %rcx     # 0x79539
movl $0x15, %edi
movl $0x1c6c8, %edx          # imm = 0x1C6C8
xorl %eax, %eax
callq 0xb9c7
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq