// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3_db_status
SQLITE_STDCALL 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 = db->lookaside.nOut;
      *pHighwater = db->lookaside.mxOut;
      if( resetFlag ){
        db->lookaside.mxOut = db->lookaside.nOut;
      }
      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: {
      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);
          totalUsed += sqlite3PagerMemUsed(pPager);
        }
      }
      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_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 $0x90, %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)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xb550
movl -0xc(%rbp), %eax
movq %rax, -0x80(%rbp)
subq $0xa, %rax
ja 0xcdbd
movq -0x80(%rbp), %rax
leaq 0x94862(%rip), %rcx     # 0xa1220
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rax
movl 0x154(%rax), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl 0x158(%rax), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x24(%rbp)
je 0xca01
movq -0x8(%rbp), %rax
movl 0x154(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x158(%rax)
jmp 0xcdc4
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x4, %ecx
movslq %ecx, %rcx
movl 0x15c(%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x24(%rbp)
je 0xca48
movq -0x8(%rbp), %rax
movl -0xc(%rbp), %ecx
subl $0x4, %ecx
movslq %ecx, %rcx
movl $0x0, 0x15c(%rax,%rcx,4)
jmp 0xcdc4
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
callq 0xcde0
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xcabb
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x30(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xcaae
movq -0x38(%rbp), %rdi
callq 0xce40
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0xce60
addl -0x2c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0xcab0
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xca64
movq -0x8(%rbp), %rdi
callq 0xcee0
movl -0x2c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
jmp 0xcdc4
movl $0x0, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0xcde0
movq -0x8(%rbp), %rax
leaq -0x48(%rbp), %rcx
movq %rcx, 0x328(%rax)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xcc44
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x44(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0xcc34
movl $0x20, %edi
callq *0xb29c5(%rip)          # 0xbf508
movq -0x50(%rbp), %rcx
movl 0xc(%rcx), %ecx
movq -0x50(%rbp), %rdx
addl 0x3c(%rdx), %ecx
movq -0x50(%rbp), %rdx
addl 0x24(%rdx), %ecx
movq -0x50(%rbp), %rdx
addl 0x54(%rdx), %ecx
imull %ecx, %eax
addl -0x48(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xb690
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rdi
callq 0xb690
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xb690
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x60(%rax), %rdi
callq 0xb690
movq %rax, %rcx
movslq -0x48(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x48(%rbp)
movq -0x50(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xcc01
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0xcf80
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xcbdc
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xcc32
movq -0x8(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0xd000
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
jmp 0xcc0d
jmp 0xcc34
jmp 0xcc36
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0xcb02
movq -0x8(%rbp), %rax
movq $0x0, 0x328(%rax)
movq -0x8(%rbp), %rdi
callq 0xcee0
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x48(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xcdc4
movl $0x0, -0x64(%rbp)
movq -0x8(%rbp), %rax
leaq -0x64(%rbp), %rcx
movq %rcx, 0x328(%rax)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0xccc5
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0xd140
movq -0x8(%rbp), %rdi
movq -0x60(%rbp), %rsi
callq 0xd260
movq -0x60(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x60(%rbp)
jmp 0xcc96
movq -0x8(%rbp), %rax
movq $0x0, 0x328(%rax)
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x64(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xcdc4
movl $0x0, -0x6c(%rbp)
movl $0x0, -0x68(%rbp)
movl -0x68(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0xcd60
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x68(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpq $0x0, 0x8(%rax)
je 0xcd53
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x68(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdi
callq 0xce40
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x24(%rbp), %edx
leaq -0x6c(%rbp), %rcx
callq 0xd300
jmp 0xcd55
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0xccfa
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movl -0x6c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xcdc4
movq -0x20(%rbp), %rax
movl $0x0, (%rax)
movq -0x8(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x320(%rcx)
movb %al, -0x81(%rbp)
jg 0xcdaa
movq -0x8(%rbp), %rax
cmpq $0x0, 0x318(%rax)
setg %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
jmp 0xcdc4
movl $0x1, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xb4f0
movl -0x28(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax)