// File: /workspace/github_c_makefile_star2_O3/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 0x27f651
movl %esi, %ebp
movq %rdi, %r14
movl 0x70(%rdi), %eax
cmpl $0xa029a697, %eax       # imm = 0xA029A697
je 0x27f4f3
cmpl $0xf03b7906, %eax       # imm = 0xF03B7906
je 0x27f4f3
cmpl $0x4b771290, %eax       # imm = 0x4B771290
jne 0x27f60c
testb $0x8, 0x68(%r14)
je 0x27f512
movq 0xe8(%r14), %rsi
movl $0x8, %edi
movq %r14, %rdx
xorl %ecx, %ecx
callq *0xe0(%r14)
movslq 0x28(%r14), %rax
testq %rax, %rax
jle 0x27f592
movq 0x20(%r14), %rcx
movq %rax, %rdx
shlq $0x5, %rdx
xorl %esi, %esi
movq 0x8(%rcx,%rsi), %rdi
testq %rdi, %rdi
je 0x27f53d
movq (%rdi), %r8
movq 0x8(%rdi), %rdi
movq %r8, 0x8(%rdi)
addq $0x20, %rsi
cmpq %rsi, %rdx
jne 0x27f528
xorl %r15d, %r15d
movq 0x20(%r14), %rcx
movq %r15, %rdx
shlq $0x5, %rdx
movq 0x18(%rcx,%rdx), %rcx
testq %rcx, %rcx
je 0x27f587
movq 0x10(%rcx), %r12
testq %r12, %r12
je 0x27f587
movq 0x10(%r12), %rsi
cmpl $0x0, 0x54(%rsi)
je 0x27f57a
movq %r14, %rdi
callq 0x2f0792
movq (%r12), %r12
testq %r12, %r12
jne 0x27f567
movl 0x28(%r14), %eax
incq %r15
movslq %eax, %rcx
cmpq %rcx, %r15
jl 0x27f549
movq 0x1f8(%r14), %r15
testq %r15, %r15
je 0x27f5b8
movq 0x10(%r15), %rax
movq 0x28(%rax), %rsi
testq %rsi, %rsi
je 0x27f5b3
movq %r14, %rdi
callq 0x2f0792
movq (%r15), %r15
jmp 0x27f599
movq %r14, %rdi
callq 0x2a5baa
movq %r14, %rdi
movl $0x88, %esi
callq 0x2912d2
testl %ebp, %ebp
je 0x27f5e3
movl $0x64cffc7f, 0x70(%r14) # imm = 0x64CFFC7F
movq %r14, %rdi
callq 0x277b9c
jmp 0x27f651
movq %r14, %rdi
callq 0x2f0756
testl %eax, %eax
je 0x27f5d1
leaq 0x15acb6(%rip), %rdx    # 0x3da2ac
movl $0x5, %ebx
movq %r14, %rdi
movl $0x5, %esi
xorl %eax, %eax
callq 0x2762da
jmp 0x27f651
leaq 0x157ca8(%rip), %rsi    # 0x3d72bb
leaq 0xd3d74(%rip), %rdx     # 0x35338e
movl $0x15, %ebx
movl $0x15, %edi
xorl %eax, %eax
callq 0x274d08
leaq 0x156599(%rip), %rsi    # 0x3d5bcb
leaq 0x15ae0e(%rip), %rdx    # 0x3da447
leaq 0x1563f1(%rip), %r8     # 0x3d5a31
movl $0x15, %edi
movl $0x27998, %ecx          # imm = 0x27998
xorl %eax, %eax
callq 0x274d08
movl %ebx, %eax
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq