// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r13d
movq %rcx, %r12
movq %rdx, %r15
movl %esi, %r14d
movq %rdi, %rbx
movq 0x18(%rdi), %rdi
testq %rdi, %rdi
je 0xb03b
callq *0x8836d(%rip)          # 0x933a8
cmpl $0xa, %r14d
ja 0xb39a
movl %r14d, %eax
leaq 0x6e1d1(%rip), %rcx     # 0x79220
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x0, (%r15)
movslq %r14d, %rax
movl 0x14c(%rbx,%rax,4), %ecx
movl %ecx, (%r12)
xorl %r14d, %r14d
testl %r13d, %r13d
je 0xb379
addq $-0x4, %rax
movl $0x0, 0x15c(%rbx,%rax,4)
jmp 0xb379
cmpl $0x0, 0x28(%rbx)
movl $0x0, %edx
jle 0xb0e1
movq 0x20(%rbx), %rax
addl $-0x7, %r14d
movslq %r14d, %rcx
addq $0x8, %rax
xorl %esi, %esi
xorl %edx, %edx
movq (%rax), %rdi
testq %rdi, %rdi
je 0xb0d1
movq 0x8(%rdi), %rdi
movq (%rdi), %rdi
addl 0xf0(%rdi,%rcx,4), %edx
testl %r13d, %r13d
je 0xb0d1
movl $0x0, 0xf0(%rdi,%rcx,4)
incq %rsi
movslq 0x28(%rbx), %rdi
addq $0x20, %rax
cmpq %rdi, %rsi
jl 0xb0ab
movl $0x0, (%r12)
movl %edx, (%r15)
jmp 0xb376
movq %r12, -0x38(%rbp)
leaq -0x2c(%rbp), %r14
movl $0x0, (%r14)
movq %rbx, %rdi
callq 0xb3a2
movq %r14, 0x328(%rbx)
cmpl $0x0, 0x28(%rbx)
jle 0xb1fa
xorl %r12d, %r12d
movq 0x20(%rbx), %rax
movq %r12, %rcx
shlq $0x5, %rcx
movq 0x18(%rax,%rcx), %r13
testq %r13, %r13
je 0xb1ea
movl $0x20, %edi
callq *0x88228(%rip)          # 0x93368
movl 0x3c(%r13), %ecx
addl 0xc(%r13), %ecx
addl 0x24(%r13), %ecx
addl 0x54(%r13), %ecx
imull %eax, %ecx
addl %ecx, -0x2c(%rbp)
movq 0x18(%r13), %rdi
xorl %r14d, %r14d
movl $0x0, %eax
testq %rdi, %rdi
je 0xb16d
callq *0x881f3(%rip)          # 0x93360
addl %eax, -0x2c(%rbp)
movq 0x48(%r13), %rdi
testq %rdi, %rdi
je 0xb182
callq *0x881e1(%rip)          # 0x93360
movl %eax, %r14d
addl %r14d, -0x2c(%rbp)
movq 0x30(%r13), %rdi
xorl %r14d, %r14d
movl $0x0, %eax
testq %rdi, %rdi
je 0xb19d
callq *0x881c3(%rip)          # 0x93360
addl %eax, -0x2c(%rbp)
movq 0x60(%r13), %rdi
testq %rdi, %rdi
je 0xb1b2
callq *0x881b1(%rip)          # 0x93360
movl %eax, %r14d
addl %r14d, -0x2c(%rbp)
movq 0x40(%r13), %r14
testq %r14, %r14
je 0xb1d0
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0xb464
movq (%r14), %r14
jmp 0xb1ba
movq 0x10(%r13), %r14
testq %r14, %r14
je 0xb1ea
movq 0x10(%r14), %rsi
movq %rbx, %rdi
callq 0xb4be
movq (%r14), %r14
jmp 0xb1d4
incq %r12
movslq 0x28(%rbx), %rax
cmpq %rax, %r12
jl 0xb11c
movq $0x0, 0x328(%rbx)
movq %rbx, %rdi
callq 0xb3fa
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movl -0x2c(%rbp), %eax
jmp 0xb28e
movl $0x0, (%r12)
movl $0x1, %eax
cmpq $0x0, 0x320(%rbx)
jg 0xb28e
xorl %eax, %eax
cmpq $0x0, 0x318(%rbx)
setg %al
jmp 0xb28e
leaq -0x44(%rbp), %rax
movl $0x0, (%rax)
movq %rax, 0x328(%rbx)
movq 0x8(%rbx), %r14
testq %r14, %r14
je 0xb278
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb616
movq %rbx, %rdi
movq %r14, %rsi
callq 0xb6df
movq 0x58(%r14), %r14
jmp 0xb257
movq $0x0, 0x328(%rbx)
movl $0x0, (%r12)
movl -0x44(%rbp), %eax
movl %eax, (%r15)
jmp 0xb376
movl 0x154(%rbx), %eax
movl %eax, (%r15)
movl 0x158(%rbx), %eax
movl %eax, (%r12)
xorl %r14d, %r14d
testl %r13d, %r13d
je 0xb379
movl 0x154(%rbx), %eax
movl %eax, 0x158(%rbx)
jmp 0xb379
movq %r12, -0x38(%rbp)
movq %r15, -0x50(%rbp)
movq %rbx, %rdi
callq 0xb3a2
cmpl $0x0, 0x28(%rbx)
movl $0x0, %ecx
jle 0xb35a
xorl %r12d, %r12d
movl $0x8, %r15d
xorl %ecx, %ecx
movq 0x20(%rbx), %rax
movq (%rax,%r15), %rax
testq %rax, %rax
je 0xb34a
movq 0x8(%rax), %rax
movq (%rax), %r14
movl 0xbc(%r14), %eax
movl %ecx, -0x40(%rbp)
movzwl 0xb0(%r14), %ecx
leal 0x70(%rax,%rcx), %eax
movl %eax, -0x3c(%rbp)
movq 0x110(%r14), %rax
movq 0x40(%rax), %rdi
callq *0x880d6(%rip)          # 0x93400
movl %eax, %r13d
imull -0x3c(%rbp), %r13d
movq %r14, %rdi
callq *0x88025(%rip)          # 0x93360
movl -0x40(%rbp), %ecx
addl %eax, %ecx
addl %r13d, %ecx
addl 0xbc(%r14), %ecx
incq %r12
movslq 0x28(%rbx), %rax
addq $0x20, %r15
cmpq %rax, %r12
jl 0xb2ec
movq %rbx, %rdi
movl %ecx, %r14d
callq 0xb3fa
movq -0x50(%rbp), %rax
movl %r14d, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
xorl %r14d, %r14d
movq 0x18(%rbx), %rdi
testq %rdi, %rdi
je 0xb388
callq *0x88030(%rip)          # 0x933b8
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r14d
jmp 0xb379