// File: /workspace/github_c_makefile_star2_O0/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:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl %r8d, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl -0xc(%rbp), %eax
movq %rax, -0x90(%rbp)
subq $0xc, %rax
ja 0x3bfc83
movq -0x90(%rbp), %rax
leaq 0x1e4e79(%rip), %rcx    # 0x5a4620
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x3bfca0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x24(%rbp)
je 0x3bf89d
movq -0x8(%rbp), %rax
movq 0x198(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3bf835
jmp 0x3bf7e7
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3bf7fe
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x3bf7e7
movq -0x8(%rbp), %rax
movq 0x190(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x198(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x190(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x198(%rax)
movq -0x8(%rbp), %rax
movq 0x1a8(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x3bf89b
jmp 0x3bf84d
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x3bf864
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0x3bf84d
movq -0x8(%rbp), %rax
movq 0x1a0(%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rax
movq 0x1a8(%rax), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x1a0(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0x1a8(%rax)
jmp 0x3bf89d
jmp 0x3bfc8a
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x4, %ecx
movslq %ecx, %rcx
movl 0x180(%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x24(%rbp)
je 0x3bf8e4
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x4, %ecx
movslq %ecx, %rcx
movl $0x0, 0x180(%rax,%rcx,4)
jmp 0x3bfc8a
movl $0x0, -0x34(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3bfd40
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x3bf986
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x38(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x3bf976
movq -0x40(%rbp), %rdi
callq 0x3bfda0
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0x3bfdc0
movl %eax, -0x4c(%rbp)
cmpl $0xb, -0xc(%rbp)
jne 0x3bf96d
movl -0x4c(%rbp), %eax
movl %eax, -0x94(%rbp)
movq -0x40(%rbp), %rdi
callq 0x3bfe40
movl %eax, %ecx
movl -0x94(%rbp), %eax
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
jmp 0x3bf978
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x3bf900
movl -0x34(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0x3bfc8a
movl $0x0, -0x54(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3bfd40
movq -0x8(%rbp), %rax
leaq -0x54(%rbp), %rcx
movq %rcx, 0x2d0(%rax)
movl $0x0, -0x50(%rbp)
movl -0x50(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x3bfb06
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x50(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x3bfaf6
movl $0x20, %edi
callq *0x27fe8b(%rip)         # 0x63f890
movq -0x60(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0x60(%rbp), %rdx
addl 0x3c(%rdx), %ecx
movq -0x60(%rbp), %rdx
addl 0x24(%rdx), %ecx
movq -0x60(%rbp), %rdx
addl 0x54(%rdx), %ecx
imull %ecx, %eax
addl -0x54(%rbp), %eax
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x3bfe60
movq %rax, %rcx
movslq -0x54(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0x3bfe60
movq %rax, %rcx
movslq -0x54(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x3bfe60
movq %rax, %rcx
movslq -0x54(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0x3bfe60
movq %rax, %rcx
movslq -0x54(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x54(%rbp)
movq -0x60(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x3bfac3
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x3bfea0
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x3bfa9e
movq -0x60(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x3bfaf4
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x3bff20
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x3bfacf
jmp 0x3bfaf6
jmp 0x3bfaf8
movl -0x50(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
jmp 0x3bf9c4
movq -0x8(%rbp), %rax
movq $0x0, 0x2d0(%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x54(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x3bfc8a
movl $0x0, -0x74(%rbp)
movq -0x8(%rbp), %rax
leaq -0x74(%rbp), %rcx
movq %rcx, 0x2d0(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
je 0x3bfb7e
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x3bff80
movq -0x8(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x3c00a0
movq -0x70(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x70(%rbp)
jmp 0x3bfb4f
movq -0x8(%rbp), %rax
movq $0x0, 0x2d0(%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x74(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x3bfc8a
movl $0xa, -0xc(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x3bfc26
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0x3bfc19
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x78(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0x3bfda0
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x24(%rbp), %edx
leaq -0x7c(%rbp), %rcx
callq 0x3c00d0
jmp 0x3bfc1b
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x3bfbba
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x7c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x3bfc8a
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x2c8(%rcx)
movb %al, -0x95(%rbp)
jg 0x3bfc70
movq -0x8(%rbp), %rax
cmpq $0x0, 0x2c0(%rax)
setg %al
movb %al, -0x95(%rbp)
movb -0x95(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0x3bfc8a
movl $0x1, -0x28(%rbp)
movl -0x28(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)