// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3BtreeIntegrityCheck
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(
  Btree *p,     /* The btree to be checked */
  int *aRoot,   /* An array of root pages numbers for individual trees */
  int nRoot,    /* Number of entries in aRoot[] */
  int mxErr,    /* Stop reporting errors after this many */
  int *pnErr    /* Write number of errors seen to this variable */
){
  Pgno i;
  IntegrityCk sCheck;
  BtShared *pBt = p->pBt;
  int savedDbFlags = pBt->db->flags;
  char zErr[100];
  VVA_ONLY( int nRef );

  sqlite3BtreeEnter(p);
  assert( p->inTrans>TRANS_NONE && pBt->inTransaction>TRANS_NONE );
  assert( (nRef = sqlite3PagerRefcount(pBt->pPager))>=0 );
  sCheck.pBt = pBt;
  sCheck.pPager = pBt->pPager;
  sCheck.nPage = btreePagecount(sCheck.pBt);
  sCheck.mxErr = mxErr;
  sCheck.nErr = 0;
  sCheck.mallocFailed = 0;
  sCheck.zPfx = 0;
  sCheck.v1 = 0;
  sCheck.v2 = 0;
  sCheck.aPgRef = 0;
  sCheck.heap = 0;
  sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
  if( sCheck.nPage==0 ){
    goto integrity_ck_cleanup;
  }

  sCheck.aPgRef = sqlite3MallocZero((sCheck.nPage / 8)+ 1);
  if( !sCheck.aPgRef ){
    sCheck.mallocFailed = 1;
    goto integrity_ck_cleanup;
  }
  sCheck.heap = (u32*)sqlite3PageMalloc( pBt->pageSize );
  if( sCheck.heap==0 ){
    sCheck.mallocFailed = 1;
    goto integrity_ck_cleanup;
  }

  i = PENDING_BYTE_PAGE(pBt);
  if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);

  /* Check the integrity of the freelist
  */
  sCheck.zPfx = "Main freelist: ";
  checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
            get4byte(&pBt->pPage1->aData[36]));
  sCheck.zPfx = 0;

  /* Check all the tables.
  */
  testcase( pBt->db->flags & SQLITE_CellSizeCk );
  pBt->db->flags &= ~SQLITE_CellSizeCk;
  for(i=0; (int)i<nRoot && sCheck.mxErr; i++){
    i64 notUsed;
    if( aRoot[i]==0 ) continue;
#ifndef SQLITE_OMIT_AUTOVACUUM
    if( pBt->autoVacuum && aRoot[i]>1 ){
      checkPtrmap(&sCheck, aRoot[i], PTRMAP_ROOTPAGE, 0);
    }
#endif
    checkTreePage(&sCheck, aRoot[i], &notUsed, LARGEST_INT64);
  }
  pBt->db->flags = savedDbFlags;

  /* Make sure every page in the file is referenced
  */
  for(i=1; i<=sCheck.nPage && sCheck.mxErr; i++){
#ifdef SQLITE_OMIT_AUTOVACUUM
    if( getPageReferenced(&sCheck, i)==0 ){
      checkAppendMsg(&sCheck, "Page %d is never used", i);
    }
#else
    /* If the database supports auto-vacuum, make sure no tables contain
    ** references to pointer-map pages.
    */
    if( getPageReferenced(&sCheck, i)==0 && 
       (PTRMAP_PAGENO(pBt, i)!=i || !pBt->autoVacuum) ){
      checkAppendMsg(&sCheck, "Page %d is never used", i);
    }
    if( getPageReferenced(&sCheck, i)!=0 && 
       (PTRMAP_PAGENO(pBt, i)==i && pBt->autoVacuum) ){
      checkAppendMsg(&sCheck, "Pointer map page %d is referenced", i);
    }
#endif
  }

  /* Clean  up and report errors.
  */
integrity_ck_cleanup:
  sqlite3PageFree(sCheck.heap);
  sqlite3_free(sCheck.aPgRef);
  if( sCheck.mallocFailed ){
    sqlite3StrAccumReset(&sCheck.errMsg);
    sCheck.nErr++;
  }
  *pnErr = sCheck.nErr;
  if( sCheck.nErr==0 ) sqlite3StrAccumReset(&sCheck.errMsg);
  /* Make sure this analysis did not leave any unref() pages. */
  assert( nRef==sqlite3PagerRefcount(pBt->pPager) );
  sqlite3BtreeLeave(p);
  return sqlite3StrAccumFinish(&sCheck.errMsg);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %r8, -0xa8(%rbp)
movl %ecx, %r13d
movl %edx, %r12d
movq %rsi, %r15
movq 0x8(%rdi), %rbx
movq 0x8(%rbx), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x2c(%rbp)
cmpb $0x0, 0x11(%rdi)
movq %rdi, -0xa0(%rbp)
je 0x34ac4
incl 0x14(%rdi)
cmpb $0x0, 0x12(%rdi)
jne 0x34ac4
callq 0x2520c
movq %rbx, -0x98(%rbp)
movq (%rbx), %rax
movq %rax, -0x90(%rbp)
movl 0x3c(%rbx), %r14d
xorl %eax, %eax
movl %r14d, -0x80(%rbp)
movl %r13d, -0x7c(%rbp)
movq %rax, -0x88(%rbp)
movq %rax, -0x38(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0x78(%rbp)
movups %xmm0, -0x68(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %rax, -0x50(%rbp)
movabsq $0x6400000000, %rax     # imm = 0x6400000000
movq %rax, -0x48(%rbp)
movl $0x3b9aca00, -0x40(%rbp) # imm = 0x3B9ACA00
movw $0x0, -0x3c(%rbp)
testq %r14, %r14
je 0x34db2
shrl $0x3, %r14d
incq %r14
movq %r14, %rdi
callq 0xc0e2
testq %rax, %rax
je 0x34da0
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xa220
movq %r13, -0x88(%rbp)
movl 0x30(%rbx), %edi
callq 0x224c8
movq %rax, -0x38(%rbp)
testq %rax, %rax
je 0x34dab
movl 0x5cc0a(%rip), %eax     # 0x91780
xorl %edx, %edx
divl 0x30(%rbx)
incl %eax
cmpl -0x80(%rbp), %eax
ja 0x34b9c
movq -0x88(%rbp), %rdx
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %esi
shll %cl, %esi
shrl $0x3, %eax
orb %sil, (%rdx,%rax)
leaq 0x472cf(%rip), %rax     # 0x7be72
leaq -0x98(%rbp), %r14
movq %rax, 0x28(%r14)
movq 0x18(%rbx), %rax
movq 0x50(%rax), %rax
movl 0x20(%rax), %edx
movl 0x24(%rax), %ecx
bswapl %edx
bswapl %ecx
movq %r14, %rdi
movl $0x1, %esi
callq 0x3cc44
movq $0x0, 0x28(%r14)
movq 0x8(%rbx), %rcx
andl $0xefffffff, 0x2c(%rcx) # imm = 0xEFFFFFFF
testl %r12d, %r12d
setg %dl
movl 0x1c(%r14), %eax
testl %eax, %eax
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x34c5d
movl %r12d, %r13d
movl $0x1, %r14d
leaq -0x98(%rbp), %r12
movl -0x4(%r15,%r14,4), %esi
testl %esi, %esi
je 0x34c4d
cmpl $0x2, %esi
jl 0x34c31
cmpb $0x0, 0x21(%rbx)
je 0x34c31
movq %r12, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x3ce84
movl -0x4(%r15,%r14,4), %esi
movq %r12, %rdi
leaq -0xb0(%rbp), %rdx
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x3cf1d
movl -0x7c(%rbp), %eax
cmpq %r13, %r14
jae 0x34c59
incq %r14
testl %eax, %eax
jne 0x34c09
movq 0x8(%rbx), %rcx
movl -0x2c(%rbp), %edx
movl %edx, 0x2c(%rcx)
cmpl $0x0, -0x80(%rbp)
je 0x34db2
testl %eax, %eax
je 0x34db2
movl $0x2, %r14d
leal -0x1(%r14), %r13d
movq -0x88(%rbp), %rax
movl %r13d, %r12d
shrl $0x3, %r12d
movl %r13d, %ecx
andb $0x7, %cl
movl $0x1, %r15d
shll %cl, %r15d
movzbl (%rax,%r12), %eax
movl %r13d, %ecx
andl $0x7, %ecx
btl %ecx, %eax
jb 0x34d26
xorl %eax, %eax
cmpl $0x2, %r13d
jb 0x34cee
movl 0x34(%rbx), %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x22, %rsi
incl %esi
leal -0x3(%r14), %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %esi
subl %edx, %ecx
movl 0x5caa8(%rip), %eax     # 0x91780
xorl %edx, %edx
divl 0x30(%rbx)
leal 0x1(%rcx), %edx
xorl %esi, %esi
cmpl %eax, %edx
sete %sil
leal (%rcx,%rsi), %eax
addl $0x2, %eax
cmpl %eax, %r13d
jne 0x34cfd
cmpb $0x0, 0x21(%rbx)
jne 0x34d8b
leaq -0x98(%rbp), %rdi
leaq 0x47177(%rip), %rsi     # 0x7be82
movl %r13d, %edx
xorl %eax, %eax
callq 0x3d6d2
movq -0x88(%rbp), %rax
movzbl (%rax,%r12), %eax
testl %eax, %r15d
je 0x34d8b
xorl %eax, %eax
cmpl $0x2, %r13d
jb 0x34d68
movl 0x34(%rbx), %esi
movl $0xcccccccd, %eax       # imm = 0xCCCCCCCD
imulq %rax, %rsi
shrq $0x22, %rsi
incl %esi
leal -0x3(%r14), %ecx
movl %ecx, %eax
xorl %edx, %edx
divl %esi
subl %edx, %ecx
movl 0x5ca2e(%rip), %eax     # 0x91780
xorl %edx, %edx
divl 0x30(%rbx)
leal 0x1(%rcx), %edx
xorl %esi, %esi
cmpl %eax, %edx
sete %sil
leal (%rcx,%rsi), %eax
addl $0x2, %eax
cmpl %eax, %r13d
jne 0x34d8b
cmpb $0x0, 0x21(%rbx)
je 0x34d8b
leaq -0x98(%rbp), %rdi
leaq 0x47117(%rip), %rsi     # 0x7be98
movl %r13d, %edx
xorl %eax, %eax
callq 0x3d6d2
cmpl -0x80(%rbp), %r14d
ja 0x34db2
incl %r14d
cmpl $0x0, -0x7c(%rbp)
jne 0x34c7b
jmp 0x34db2
movq $0x0, -0x88(%rbp)
movl $0x1, -0x74(%rbp)
movq -0x38(%rbp), %rdi
callq 0x21bb2
movq -0x88(%rbp), %rdi
callq 0xa630
cmpl $0x0, -0x74(%rbp)
je 0x34df6
cmpb $0x0, -0x3b(%rbp)
je 0x34de4
movq -0x60(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xb752
movb $0x0, -0x3b(%rbp)
movq $0x0, -0x50(%rbp)
movl -0x78(%rbp), %eax
incl %eax
movl %eax, -0x78(%rbp)
jmp 0x34df9
movl -0x78(%rbp), %eax
movq -0xa8(%rbp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
movq -0xa0(%rbp), %rdi
jne 0x34e33
cmpb $0x0, -0x3b(%rbp)
je 0x34e2b
movq -0x60(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0xb752
movq -0xa0(%rbp), %rdi
movb $0x0, -0x3b(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x60(%rbp), %r14
cmpb $0x0, 0x11(%rdi)
je 0x34e47
decl 0x14(%rdi)
jne 0x34e47
callq 0x25292
movq %r14, %rdi
callq 0xdbce
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq