// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3_db_status
SQLITE_API int sqlite3_db_status(
  sqlite3 *db,          /* The database connection whose status is desired */
  int op,               /* Status verb */
  int *pCurrent,        /* Write current value here */
  int *pHighwater,      /* Write high-water mark here */
  int resetFlag         /* Reset high-water mark if true */
){
  int rc = SQLITE_OK;   /* Return code */
#ifdef SQLITE_ENABLE_API_ARMOR
  if( !sqlite3SafetyCheckOk(db) || pCurrent==0|| pHighwater==0 ){
    return SQLITE_MISUSE_BKPT;
  }
#endif
  sqlite3_mutex_enter(db->mutex);
  switch( op ){
    case SQLITE_DBSTATUS_LOOKASIDE_USED: {
      *pCurrent = sqlite3LookasideUsed(db, pHighwater);
      if( resetFlag ){
        LookasideSlot *p = db->lookaside.pFree;
        if( p ){
          while( p->pNext ) p = p->pNext;
          p->pNext = db->lookaside.pInit;
          db->lookaside.pInit = db->lookaside.pFree;
          db->lookaside.pFree = 0;
        }
#ifndef SQLITE_OMIT_TWOSIZE_LOOKASIDE
        p = db->lookaside.pSmallFree;
        if( p ){
          while( p->pNext ) p = p->pNext;
          p->pNext = db->lookaside.pSmallInit;
          db->lookaside.pSmallInit = db->lookaside.pSmallFree;
          db->lookaside.pSmallFree = 0;
        }
#endif
      }
      break;
    }

    case SQLITE_DBSTATUS_LOOKASIDE_HIT:
    case SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE:
    case SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL: {
      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_HIT );
      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE );
      testcase( op==SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL );
      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)>=0 );
      assert( (op-SQLITE_DBSTATUS_LOOKASIDE_HIT)<3 );
      *pCurrent = 0;
      *pHighwater = db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT];
      if( resetFlag ){
        db->lookaside.anStat[op - SQLITE_DBSTATUS_LOOKASIDE_HIT] = 0;
      }
      break;
    }

    /*
    ** Return an approximation for the amount of memory currently used
    ** by all pagers associated with the given database connection.  The
    ** highwater mark is meaningless and is returned as zero.
    */
    case SQLITE_DBSTATUS_CACHE_USED_SHARED:
    case SQLITE_DBSTATUS_CACHE_USED: {
      int totalUsed = 0;
      int i;
      sqlite3BtreeEnterAll(db);
      for(i=0; i<db->nDb; i++){
        Btree *pBt = db->aDb[i].pBt;
        if( pBt ){
          Pager *pPager = sqlite3BtreePager(pBt);
          int nByte = sqlite3PagerMemUsed(pPager);
          if( op==SQLITE_DBSTATUS_CACHE_USED_SHARED ){
            nByte = nByte / sqlite3BtreeConnectionCount(pBt);
          }
          totalUsed += nByte;
        }
      }
      sqlite3BtreeLeaveAll(db);
      *pCurrent = totalUsed;
      *pHighwater = 0;
      break;
    }

    /*
    ** *pCurrent gets an accurate estimate of the amount of memory used
    ** to store the schema for all databases (main, temp, and any ATTACHed
    ** databases.  *pHighwater is set to zero.
    */
    case SQLITE_DBSTATUS_SCHEMA_USED: {
      int i;                      /* Used to iterate through schemas */
      int nByte = 0;              /* Used to accumulate return value */

      sqlite3BtreeEnterAll(db);
      db->pnBytesFreed = &nByte;
      for(i=0; i<db->nDb; i++){
        Schema *pSchema = db->aDb[i].pSchema;
        if( ALWAYS(pSchema!=0) ){
          HashElem *p;

          nByte += sqlite3GlobalConfig.m.xRoundup(sizeof(HashElem)) * (
              pSchema->tblHash.count
            + pSchema->trigHash.count
            + pSchema->idxHash.count
            + pSchema->fkeyHash.count
          );
          nByte += sqlite3_msize(pSchema->tblHash.ht);
          nByte += sqlite3_msize(pSchema->trigHash.ht);
          nByte += sqlite3_msize(pSchema->idxHash.ht);
          nByte += sqlite3_msize(pSchema->fkeyHash.ht);

          for(p=sqliteHashFirst(&pSchema->trigHash); p; p=sqliteHashNext(p)){
            sqlite3DeleteTrigger(db, (Trigger*)sqliteHashData(p));
          }
          for(p=sqliteHashFirst(&pSchema->tblHash); p; p=sqliteHashNext(p)){
            sqlite3DeleteTable(db, (Table *)sqliteHashData(p));
          }
        }
      }
      db->pnBytesFreed = 0;
      sqlite3BtreeLeaveAll(db);

      *pHighwater = 0;
      *pCurrent = nByte;
      break;
    }

    /*
    ** *pCurrent gets an accurate estimate of the amount of memory used
    ** to store all prepared statements.
    ** *pHighwater is set to zero.
    */
    case SQLITE_DBSTATUS_STMT_USED: {
      struct Vdbe *pVdbe;         /* Used to iterate through VMs */
      int nByte = 0;              /* Used to accumulate return value */

      db->pnBytesFreed = &nByte;
      for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){
        sqlite3VdbeClearObject(db, pVdbe);
        sqlite3DbFree(db, pVdbe);
      }
      db->pnBytesFreed = 0;

      *pHighwater = 0;  /* IMP: R-64479-57858 */
      *pCurrent = nByte;

      break;
    }

    /*
    ** Set *pCurrent to the total cache hits or misses encountered by all
    ** pagers the database handle is connected to. *pHighwater is always set
    ** to zero.
    */
    case SQLITE_DBSTATUS_CACHE_SPILL:
      op = SQLITE_DBSTATUS_CACHE_WRITE+1;
      /* no break */ deliberate_fall_through
    case SQLITE_DBSTATUS_CACHE_HIT:
    case SQLITE_DBSTATUS_CACHE_MISS:
    case SQLITE_DBSTATUS_CACHE_WRITE:{
      int i;
      int nRet = 0;
      assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
      assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );

      for(i=0; i<db->nDb; i++){
        if( db->aDb[i].pBt ){
          Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
          sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
        }
      }
      *pHighwater = 0; /* IMP: R-42420-56072 */
                       /* IMP: R-54100-20147 */
                       /* IMP: R-29431-39229 */
      *pCurrent = nRet;
      break;
    }

    /* Set *pCurrent to non-zero if there are unresolved deferred foreign
    ** key constraints.  Set *pCurrent to zero if all foreign key constraints
    ** have been satisfied.  The *pHighwater is always set to zero.
    */
    case SQLITE_DBSTATUS_DEFERRED_FKS: {
      *pHighwater = 0;  /* IMP: R-11967-56545 */
      *pCurrent = db->nDeferredImmCons>0 || db->nDeferredCons>0;
      break;
    }

    default: {
      rc = SQLITE_ERROR;
    }
  }
  sqlite3_mutex_leave(db->mutex);
  return rc;
}

// Assembly:
cmpl $0xc, %esi
ja 0x27bc71
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r13d
movq %rcx, %r15
movq %rdx, %r14
movq %rdi, %rbx
movl %esi, %eax
leaq 0x15dee2(%rip), %rcx    # 0x3d9740
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, (%r14)
movslq %esi, %rdx
movl 0x170(%rbx,%rdx,4), %ecx
movl %ecx, (%r15)
xorl %eax, %eax
testl %r13d, %r13d
je 0x27bc62
addq $-0x4, %rdx
movl $0x0, 0x180(%rbx,%rdx,4)
jmp 0x27bc62
movq %r15, 0x20(%rsp)
movq %r14, 0x8(%rsp)
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x27b8d5
movq 0x20(%rbx), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movq 0x8(%rcx,%rdx), %r8
testq %r8, %r8
je 0x27b8cc
movq (%r8), %rdi
movq 0x8(%r8), %r8
movq %rdi, 0x8(%r8)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x27b8b7
cmpl $0x0, 0x28(%rbx)
movl $0x0, %ecx
jle 0x27b97a
xorl %r15d, %r15d
movl $0x8, %r12d
xorl %ecx, %ecx
movl %esi, 0x14(%rsp)
movq 0x20(%rbx), %rax
movq (%rax,%r12), %rbp
testq %rbp, %rbp
je 0x27b966
movl %ecx, 0x4(%rsp)
movq 0x8(%rbp), %rax
movq (%rax), %r13
movl 0xbc(%r13), %eax
movzwl 0xb0(%r13), %ecx
leal 0x70(%rax,%rcx), %eax
movl %eax, 0x18(%rsp)
movq 0x118(%r13), %rax
movq 0x40(%rax), %rdi
callq *0x24ae05(%rip)         # 0x4c6738
movl %eax, %r14d
imull 0x18(%rsp), %r14d
movq %r13, %rdi
callq *0x24ad53(%rip)         # 0x4c6698
movl 0x14(%rsp), %esi
addl %r14d, %eax
addl 0xbc(%r13), %eax
cmpl $0xb, %esi
jne 0x27b960
movq 0x8(%rbp), %rcx
cltd
idivl 0x68(%rcx)
movl 0x4(%rsp), %ecx
addl %eax, %ecx
incq %r15
movslq 0x28(%rbx), %rax
addq $0x20, %r12
cmpq %rax, %r15
jl 0x27b8f3
movq 0x8(%rsp), %rax
movl %ecx, (%rax)
movq 0x20(%rsp), %rax
movl $0x0, (%rax)
jmp 0x27bc60
movl $0x0, (%r15)
movl $0x1, %eax
cmpq $0x0, 0x2c8(%rbx)
jg 0x27ba74
xorl %eax, %eax
cmpq $0x0, 0x2c0(%rbx)
setg %al
jmp 0x27ba74
movl $0xa, %esi
xorl %eax, %eax
cmpl $0x0, 0x28(%rbx)
movl $0x0, %edx
jle 0x27ba17
movq 0x20(%rbx), %r8
addl $-0x7, %esi
movslq %esi, %rcx
addq $0x8, %r8
xorl %esi, %esi
xorl %edx, %edx
movq (%r8), %rdi
testq %rdi, %rdi
je 0x27ba07
movq 0x8(%rdi), %rdi
movq (%rdi), %rdi
addl 0xf0(%rdi,%rcx,4), %edx
testl %r13d, %r13d
je 0x27ba07
movl $0x0, 0xf0(%rdi,%rcx,4)
incq %rsi
movslq 0x28(%rbx), %rdi
addq $0x20, %r8
cmpq %rdi, %rsi
jl 0x27b9e1
movl $0x0, (%r15)
movl %edx, (%r14)
jmp 0x27bc62
leaq 0x1c(%rsp), %rax
movl $0x0, (%rax)
movq %rax, 0x2d0(%rbx)
movq 0x8(%rbx), %r12
testq %r12, %r12
je 0x27ba5e
movq %rbx, %rdi
movq %r12, %rsi
callq 0x27bd96
movq %rbx, %rdi
movq %r12, %rsi
callq 0x28c3e7
movq 0x10(%r12), %r12
jmp 0x27ba3c
movq $0x0, 0x2d0(%rbx)
movl $0x0, (%r15)
movl 0x1c(%rsp), %eax
movl %eax, (%r14)
jmp 0x27bc60
movq %rbx, %rdi
movq %r15, %rsi
callq 0x27bc77
movl %eax, (%r14)
xorl %eax, %eax
testl %r13d, %r13d
je 0x27bc62
movq 0x198(%rbx), %rsi
testq %rsi, %rsi
je 0x27bacb
movq %rsi, %rdx
movq %rdx, %rcx
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x27baa4
movq 0x190(%rbx), %rdx
movq %rdx, (%rcx)
movq %rsi, 0x190(%rbx)
movq $0x0, 0x198(%rbx)
movq 0x1a8(%rbx), %rsi
testq %rsi, %rsi
je 0x27bc62
movq %rsi, %rdx
movq %rdx, %rcx
movq (%rdx), %rdx
testq %rdx, %rdx
jne 0x27bade
movq 0x1a0(%rbx), %rdx
movq %rdx, (%rcx)
movq %rsi, 0x1a0(%rbx)
movq $0x0, 0x1a8(%rbx)
jmp 0x27bc62
movl $0x0, (%rsp)
movslq 0x28(%rbx), %rax
testq %rax, %rax
jle 0x27bb42
movq 0x20(%rbx), %rcx
shlq $0x5, %rax
xorl %edx, %edx
movq 0x8(%rcx,%rdx), %rsi
testq %rsi, %rsi
je 0x27bb39
movq (%rsi), %rdi
movq 0x8(%rsi), %rsi
movq %rdi, 0x8(%rsi)
addq $0x20, %rdx
cmpq %rdx, %rax
jne 0x27bb24
movq %r15, %r13
movq %r14, 0x8(%rsp)
movq %rsp, %rax
movq %rax, 0x2d0(%rbx)
cmpl $0x0, 0x28(%rbx)
jle 0x27bc43
xorl %r14d, %r14d
movq 0x20(%rbx), %rax
movq %r14, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %r12
testq %r12, %r12
je 0x27bc33
movl $0x20, %edi
callq *0x24ab1b(%rip)         # 0x4c66a0
movl 0x3c(%r12), %ecx
addl 0xc(%r12), %ecx
addl 0x24(%r12), %ecx
addl 0x54(%r12), %ecx
imull %eax, %ecx
addl %ecx, (%rsp)
movq 0x18(%r12), %rdi
xorl %ebp, %ebp
movl $0x0, %eax
testq %rdi, %rdi
je 0x27bbb6
callq *0x24aae2(%rip)         # 0x4c6698
addl %eax, (%rsp)
movq 0x48(%r12), %rdi
testq %rdi, %rdi
je 0x27bbcb
callq *0x24aacf(%rip)         # 0x4c6698
movl %eax, %ebp
addl %ebp, (%rsp)
movq 0x30(%r12), %rdi
xorl %ebp, %ebp
movl $0x0, %eax
testq %rdi, %rdi
je 0x27bbe5
callq *0x24aab3(%rip)         # 0x4c6698
addl %eax, (%rsp)
movq 0x60(%r12), %rdi
testq %rdi, %rdi
je 0x27bbfa
callq *0x24aaa0(%rip)         # 0x4c6698
movl %eax, %ebp
addl %ebp, (%rsp)
movq 0x40(%r12), %r15
testq %r15, %r15
je 0x27bc18
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x27bd0b
movq (%r15), %r15
jmp 0x27bc02
movq 0x10(%r12), %r15
testq %r15, %r15
je 0x27bc33
movq 0x10(%r15), %rsi
movq %rbx, %rdi
callq 0x27bd74
movq (%r15), %r15
jmp 0x27bc1d
incq %r14
movslq 0x28(%rbx), %rax
cmpq %rax, %r14
jl 0x27bb61
movq $0x0, 0x2d0(%rbx)
movl $0x0, (%r13)
movl (%rsp), %eax
movq 0x8(%rsp), %rcx
movl %eax, (%rcx)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %eax
retq