// File: /workspace/github_c_makefile_star2_O1/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, -0x34(%rbp)
cmpb $0x0, 0x11(%rdi)
movq %rdi, -0x30(%rbp)
je 0x356fe
incl 0x14(%rdi)
cmpb $0x0, 0x12(%rdi)
jne 0x356fe
callq 0x25420
movq %rbx, -0xa0(%rbp)
movq (%rbx), %rax
movq %rax, -0x98(%rbp)
movl 0x3c(%rbx), %r14d
xorl %eax, %eax
movl %r14d, -0x88(%rbp)
movl %r13d, -0x84(%rbp)
movq %rax, -0x90(%rbp)
movq %rax, -0x40(%rbp)
xorps %xmm0, %xmm0
movups %xmm0, -0x80(%rbp)
movups %xmm0, -0x70(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x60(%rbp)
movq %rax, -0x58(%rbp)
movabsq $0x6400000000, %rax     # imm = 0x6400000000
movq %rax, -0x50(%rbp)
movl $0x3b9aca00, -0x48(%rbp) # imm = 0x3B9ACA00
movw $0x0, -0x44(%rbp)
testq %r14, %r14
je 0x359f1
shrl $0x3, %r14d
incq %r14
movq %r14, %rdi
callq 0xbf9b
movq %rax, %r13
testq %rax, %rax
je 0x359e3
movq %r13, %rdi
xorl %esi, %esi
movq %r14, %rdx
callq 0xa210
movq %r13, -0x90(%rbp)
movl 0x30(%rbx), %edi
callq 0x22616
movq %rax, -0x40(%rbp)
testq %rax, %rax
je 0x359ea
movl 0x5dfba(%rip), %eax     # 0x93770
xorl %edx, %edx
divl 0x30(%rbx)
incl %eax
cmpl -0x88(%rbp), %eax
ja 0x357de
movl %eax, %ecx
andb $0x7, %cl
movl $0x1, %edx
shll %cl, %edx
movq -0x90(%rbp), %rcx
shrl $0x3, %eax
orb %dl, (%rcx,%rax)
leaq 0x4867d(%rip), %rax     # 0x7de62
leaq -0xa0(%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 0x3dc32
movq $0x0, 0x28(%r14)
movq 0x8(%rbx), %rax
andl $0xefffffff, 0x2c(%rax) # imm = 0xEFFFFFFF
testl %r12d, %r12d
jle 0x35892
cmpl $0x0, -0x84(%rbp)
je 0x35892
movl %r12d, %r13d
movl $0x1, %r14d
leaq -0xa0(%rbp), %r12
movl -0x4(%r15,%r14,4), %esi
testl %esi, %esi
je 0x35881
cmpl $0x2, %esi
jl 0x35863
cmpb $0x0, 0x21(%rbx)
je 0x35863
movq %r12, %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x3de62
movl -0x4(%r15,%r14,4), %esi
movq %r12, %rdi
leaq -0xb0(%rbp), %rdx
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x3defb
cmpq %r13, %r14
jae 0x35892
incq %r14
cmpl $0x0, -0x84(%rbp)
jne 0x35840
movq 0x8(%rbx), %rax
movl -0x34(%rbp), %ecx
movl %ecx, 0x2c(%rax)
cmpl $0x0, -0x88(%rbp)
je 0x359f1
cmpl $0x0, -0x84(%rbp)
je 0x359f1
movl $0x2, %r14d
leal -0x1(%r14), %r13d
movq -0x90(%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 0x35952
xorl %eax, %eax
cmpl $0x2, %r13d
jb 0x3592f
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 0x5de57(%rip), %eax     # 0x93770
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 0x3593a
cmpb $0x0, 0x21(%rbx)
jne 0x35952
leaq -0xa0(%rbp), %rdi
leaq 0x4852a(%rip), %rsi     # 0x7de72
movl %r13d, %edx
xorl %eax, %eax
callq 0x3e6b7
movq -0x90(%rbp), %rax
movzbl (%rax,%r12), %eax
testl %eax, %r15d
je 0x359c8
xorl %eax, %eax
cmpl $0x2, %r13d
jb 0x359a5
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 0x5dde1(%rip), %eax     # 0x93770
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 0x359c8
cmpb $0x0, 0x21(%rbx)
je 0x359c8
leaq -0xa0(%rbp), %rdi
leaq 0x484ca(%rip), %rsi     # 0x7de88
movl %r13d, %edx
xorl %eax, %eax
callq 0x3e6b7
cmpl -0x88(%rbp), %r14d
ja 0x359f1
incl %r14d
cmpl $0x0, -0x84(%rbp)
jne 0x358bc
jmp 0x359f1
movq %r13, -0x90(%rbp)
movl $0x1, -0x7c(%rbp)
movq -0x40(%rbp), %rdi
callq 0x21d0f
movq -0x90(%rbp), %rdi
callq 0xa620
cmpl $0x0, -0x7c(%rbp)
movq -0x30(%rbp), %rdi
je 0x35a36
cmpb $0x0, -0x43(%rbp)
je 0x35a2b
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xb6df
movq -0x30(%rbp), %rdi
movb $0x0, -0x43(%rbp)
movq $0x0, -0x58(%rbp)
incl -0x80(%rbp)
movl -0x80(%rbp), %eax
movq -0xa8(%rbp), %rcx
movl %eax, (%rcx)
testl %eax, %eax
jne 0x35a69
cmpb $0x0, -0x43(%rbp)
je 0x35a61
movq -0x68(%rbp), %rdi
movq -0x58(%rbp), %rsi
callq 0xb6df
movq -0x30(%rbp), %rdi
movb $0x0, -0x43(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x68(%rbp), %r14
cmpb $0x0, 0x11(%rdi)
je 0x35a7d
decl 0x14(%rdi)
jne 0x35a7d
callq 0x254a6
movq %r14, %rdi
callq 0xda95
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq