// File: /workspace/github_c_makefile_star2_O0/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
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x11e30
movq -0x98(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x98(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x90(%rbp), %rdi
callq 0x31b90
movl %eax, -0x78(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x74(%rbp)
movl $0x0, -0x70(%rbp)
movl $0x0, -0x6c(%rbp)
movq $0x0, -0x68(%rbp)
movl $0x0, -0x60(%rbp)
movl $0x0, -0x5c(%rbp)
movq $0x0, -0x80(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x90(%rbp), %rdi
addq $0x38, %rdi
leaq -0x100(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
movl $0x64, %ecx
movl $0x3b9aca00, %r8d       # imm = 0x3B9ACA00
callq 0xdfd0
cmpl $0x0, -0x78(%rbp)
jne 0x469a2
jmp 0x46c3d
movl -0x78(%rbp), %eax
shrl $0x3, %eax
addl $0x1, %eax
movl %eax, %eax
movl %eax, %edi
callq 0x114b0
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x469cb
movl $0x1, -0x6c(%rbp)
jmp 0x46c3d
movq -0x98(%rbp), %rax
movl 0x30(%rax), %edi
callq 0x2bfd0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x469f1
movl $0x1, -0x6c(%rbp)
jmp 0x46c3d
movl 0x78f19(%rip), %eax     # 0xbf910
movq -0x98(%rbp), %rcx
xorl %edx, %edx
divl 0x30(%rcx)
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x78(%rbp), %eax
ja 0x46a20
movl -0x24(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x53bd0
leaq 0x5fd80(%rip), %rax     # 0xa67a7
movq %rax, -0x68(%rbp)
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x50(%rax), %rdi
addq $0x20, %rdi
callq 0x26b20
movl %eax, -0x10c(%rbp)
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x50(%rax), %rdi
addq $0x24, %rdi
callq 0x26b20
movl -0x10c(%rbp), %edx
movl %eax, %ecx
leaq -0x90(%rbp), %rdi
movl $0x1, %esi
callq 0x53c10
movq $0x0, -0x68(%rbp)
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x2c(%rax), %ecx
andl $0xefffffff, %ecx       # imm = 0xEFFFFFFF
movl %ecx, 0x2c(%rax)
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x14(%rbp), %ecx
movb %al, -0x10d(%rbp)
jge 0x46abd
cmpl $0x0, -0x74(%rbp)
setne %al
movb %al, -0x10d(%rbp)
movb -0x10d(%rbp), %al
testb $0x1, %al
jne 0x46ac9
jmp 0x46b47
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
cmpl $0x0, (%rax,%rcx,4)
jne 0x46ad8
jmp 0x46b39
movq -0x98(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
je 0x46b12
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
cmpl $0x1, (%rax,%rcx,4)
jle 0x46b12
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %esi
leaq -0x90(%rbp), %rdi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x53e60
movq -0x10(%rbp), %rax
movl -0x24(%rbp), %ecx
movl (%rax,%rcx,4), %esi
leaq -0x90(%rbp), %rdi
leaq -0x108(%rbp), %rdx
movabsq $0x7fffffffffffffff, %rcx # imm = 0x7FFFFFFFFFFFFFFF
callq 0x53f10
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x46aa0
movl -0x9c(%rbp), %ecx
movq -0x98(%rbp), %rax
movq 0x8(%rax), %rax
movl %ecx, 0x2c(%rax)
movl $0x1, -0x24(%rbp)
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x78(%rbp), %ecx
movb %al, -0x10e(%rbp)
ja 0x46b7f
cmpl $0x0, -0x74(%rbp)
setne %al
movb %al, -0x10e(%rbp)
movb -0x10e(%rbp), %al
testb $0x1, %al
jne 0x46b8e
jmp 0x46c3b
movl -0x24(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x54770
cmpl $0x0, %eax
jne 0x46bdb
movq -0x98(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x32d20
cmpl -0x24(%rbp), %eax
jne 0x46bc3
movq -0x98(%rbp), %rax
cmpb $0x0, 0x21(%rax)
jne 0x46bdb
movl -0x24(%rbp), %edx
leaq -0x90(%rbp), %rdi
leaq 0x5fbe3(%rip), %rsi     # 0xa67b7
movb $0x0, %al
callq 0x547b0
movl -0x24(%rbp), %esi
leaq -0x90(%rbp), %rdi
callq 0x54770
cmpl $0x0, %eax
je 0x46c2b
movq -0x98(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x32d20
cmpl -0x24(%rbp), %eax
jne 0x46c2b
movq -0x98(%rbp), %rax
movzbl 0x21(%rax), %eax
cmpl $0x0, %eax
je 0x46c2b
movl -0x24(%rbp), %edx
leaq -0x90(%rbp), %rdi
leaq 0x5fba9(%rip), %rsi     # 0xa67cd
movb $0x0, %al
callq 0x547b0
jmp 0x46c2d
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x46b62
jmp 0x46c3d
movq -0x30(%rbp), %rdi
callq 0x271d0
movq -0x80(%rbp), %rdi
callq 0xb958
cmpl $0x0, -0x6c(%rbp)
je 0x46c6e
leaq -0x90(%rbp), %rdi
addq $0x38, %rdi
callq 0x21db0
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
cmpl $0x0, -0x70(%rbp)
jne 0x46c8d
leaq -0x90(%rbp), %rdi
addq $0x38, %rdi
callq 0x21db0
movq -0x8(%rbp), %rdi
callq 0x13330
leaq -0x90(%rbp), %rdi
addq $0x38, %rdi
callq 0xfdb0
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nop