// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3Close
static int sqlite3Close(sqlite3 *db, int forceZombie){
  if( !db ){
    /* EVIDENCE-OF: R-63257-11740 Calling sqlite3_close() or
    ** sqlite3_close_v2() with a NULL pointer argument is a harmless no-op. */
    return SQLITE_OK;
  }
  if( !sqlite3SafetyCheckSickOrOk(db) ){
    return SQLITE_MISUSE_BKPT;
  }
  sqlite3_mutex_enter(db->mutex);
  if( db->mTrace & SQLITE_TRACE_CLOSE ){
    db->trace.xV2(SQLITE_TRACE_CLOSE, db->pTraceArg, db, 0);
  }

  /* 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) ){
    sqlite3ErrorWithMsg(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
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x28920e
movl %esi, %ebp
movq %rdi, %r14
callq 0x289ec4
testl %eax, %eax
je 0x2891ba
testb $0x8, 0x68(%r14)
je 0x2890eb
movq 0xe8(%r14), %rsi
movl $0x8, %edi
movq %r14, %rdx
xorl %ecx, %ecx
callq *0xe0(%r14)
movslq 0x28(%r14), %rax
testq %rax, %rax
jle 0x289169
movq 0x20(%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
movq 0x8(%rcx,%rsi), %rdi
testq %rdi, %rdi
je 0x289116
movq (%rdi), %r8
movq 0x8(%rdi), %rdi
movq %r8, 0x8(%rdi)
addq $0x20, %rsi
cmpq %rsi, %rdx
jne 0x289101
testl %eax, %eax
jle 0x289169
xorl %r15d, %r15d
movq 0x20(%r14), %rax
movq %r15, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %rax
testq %rax, %rax
je 0x28915d
movq 0x10(%rax), %r12
testq %r12, %r12
je 0x28915d
movq 0x10(%r12), %rsi
cmpl $0x0, 0x54(%rsi)
je 0x289157
movq %r14, %rdi
callq 0x2f9b20
movq (%r12), %r12
jmp 0x28913f
incq %r15
movslq 0x28(%r14), %rax
cmpq %rax, %r15
jl 0x289126
movq 0x1f8(%r14), %r15
testq %r15, %r15
je 0x28918f
movq 0x10(%r15), %rax
movq 0x28(%rax), %rsi
testq %rsi, %rsi
je 0x28918a
movq %r14, %rdi
callq 0x2f9b20
movq (%r15), %r15
jmp 0x289170
movq %r14, %rdi
callq 0x2af7a6
movq %r14, %rdi
movl $0x88, %esi
callq 0x29afd3
testl %ebp, %ebp
je 0x2891e7
movl $0x64cffc7f, 0x70(%r14) # imm = 0x64CFFC7F
movq %r14, %rdi
callq 0x281538
jmp 0x28920e
leaq 0x15615e(%rip), %rsi    # 0x3df31f
leaq 0x15a9d4(%rip), %rdx    # 0x3e3b9c
leaq 0x155fb6(%rip), %r8     # 0x3df185
movl $0x15, %ebx
movl $0x15, %edi
movl $0x27998, %ecx          # imm = 0x27998
xorl %eax, %eax
callq 0x27e637
jmp 0x28920e
movq %r14, %rdi
callq 0x2f9ae4
testl %eax, %eax
je 0x2891a8
leaq 0x15a807(%rip), %rdx    # 0x3e3a01
movl $0x5, %ebx
movq %r14, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0x27fc17
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq