// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: checkList
static void checkList(
  IntegrityCk *pCheck,  /* Integrity checking context */
  int isFreeList,       /* True for a freelist.  False for overflow page list */
  Pgno iPage,           /* Page number for first page in the list */
  u32 N                 /* Expected number of pages in the list */
){
  int i;
  u32 expected = N;
  int nErrAtStart = pCheck->nErr;
  while( iPage!=0 && pCheck->mxErr ){
    DbPage *pOvflPage;
    unsigned char *pOvflData;
    if( checkRef(pCheck, iPage) ) break;
    N--;
    if( sqlite3PagerGet(pCheck->pPager, (Pgno)iPage, &pOvflPage, 0) ){
      checkAppendMsg(pCheck, "failed to get page %d", iPage);
      break;
    }
    pOvflData = (unsigned char *)sqlite3PagerGetData(pOvflPage);
    if( isFreeList ){
      u32 n = (u32)get4byte(&pOvflData[4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
      if( pCheck->pBt->autoVacuum ){
        checkPtrmap(pCheck, iPage, PTRMAP_FREEPAGE, 0);
      }
#endif
      if( n>pCheck->pBt->usableSize/4-2 ){
        checkAppendMsg(pCheck,
           "freelist leaf count too big on page %d", iPage);
        N--;
      }else{
        for(i=0; i<(int)n; i++){
          Pgno iFreePage = get4byte(&pOvflData[8+i*4]);
#ifndef SQLITE_OMIT_AUTOVACUUM
          if( pCheck->pBt->autoVacuum ){
            checkPtrmap(pCheck, iFreePage, PTRMAP_FREEPAGE, 0);
          }
#endif
          checkRef(pCheck, iFreePage);
        }
        N -= n;
      }
    }
#ifndef SQLITE_OMIT_AUTOVACUUM
    else{
      /* If this database supports auto-vacuum and iPage is not the last
      ** page in this overflow list, check that the pointer-map entry for
      ** the following page matches iPage.
      */
      if( pCheck->pBt->autoVacuum && N>0 ){
        i = get4byte(pOvflData);
        checkPtrmap(pCheck, i, PTRMAP_OVERFLOW2, iPage);
      }
    }
#endif
    iPage = get4byte(pOvflData);
    sqlite3PagerUnref(pOvflPage);
  }
  if( N && nErrAtStart==pCheck->nErr ){
    checkAppendMsg(pCheck,
      "%s is %d but should be %d",
      isFreeList ? "size" : "overflow list length",
      expected-N, expected);
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %esi, %ebx
movq %rdi, %r14
movl 0x20(%rdi), %eax
movl %eax, 0x8(%rsp)
movl %ecx, (%rsp)
movl %ecx, %r12d
testl %edx, %edx
je 0x2a67ba
movl %edx, %r13d
movl (%rsp), %eax
movl %eax, %r12d
movl %ebx, 0x4(%rsp)
cmpl $0x0, 0x1c(%r14)
je 0x2a67ba
movq %r14, %rdi
movl %r13d, %esi
callq 0x2a71af
testl %eax, %eax
jne 0x2a679e
leal -0x1(%r12), %ebp
movq 0x8(%r14), %rdi
movl %r13d, %esi
leaq 0x10(%rsp), %rdx
xorl %ecx, %ecx
callq *0x108(%rdi)
testl %eax, %eax
jne 0x2a67a3
movq 0x10(%rsp), %rax
movq 0x8(%rax), %r15
testl %ebx, %ebx
je 0x2a6705
movq %r12, 0x20(%rsp)
movl %ebp, 0xc(%rsp)
movzbl 0x4(%r15), %r12d
movzbl 0x5(%r15), %edx
movzbl 0x6(%r15), %ebp
movzbl 0x7(%r15), %ecx
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2a66c7
movq %r14, %rdi
movl %r13d, %esi
movq %rdx, 0x18(%rsp)
movl $0x2, %edx
movl %ecx, %ebx
xorl %ecx, %ecx
callq 0x2a6916
movq 0x18(%rsp), %rdx
movl %ebx, %ecx
movq (%r14), %rax
shll $0x18, %r12d
shll $0x10, %edx
leal (%rdx,%r12), %ebx
shll $0x8, %ebp
orl %ebp, %ebx
orl %ecx, %ebx
movl 0x38(%rax), %eax
shrl $0x2, %eax
addl $-0x2, %eax
cmpl %eax, %ebx
jbe 0x2a672c
movq %r14, %rdi
leaq 0x130187(%rip), %rsi    # 0x3d6877
movl %r13d, %edx
xorl %eax, %eax
callq 0x2a6807
movq 0x20(%rsp), %r12
addl $-0x2, %r12d
jmp 0x2a677a
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2a6727
testl %ebp, %ebp
je 0x2a6727
movl (%r15), %esi
bswapl %esi
movq %r14, %rdi
movl $0x4, %edx
movl %r13d, %ecx
callq 0x2a6916
movl %ebp, %r12d
jmp 0x2a677e
testl %ebx, %ebx
jle 0x2a6771
addl %edx, %r12d
addl %ecx, %ebp
addl %r12d, %ebp
xorl %r12d, %r12d
movl 0x8(%r15,%r12,4), %r13d
bswapl %r13d
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2a675e
movq %r14, %rdi
movl %r13d, %esi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x2a6916
movq %r14, %rdi
movl %r13d, %esi
callq 0x2a71af
incq %r12
cmpq %r12, %rbp
jne 0x2a673b
movl 0xc(%rsp), %eax
subl %ebx, %eax
movl %eax, %r12d
movl 0x4(%rsp), %ebx
movl (%r15), %r13d
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2a6790
callq 0x28ab87
bswapl %r13d
testl %r13d, %r13d
jne 0x2a662e
jmp 0x2a67ba
movl %r12d, %ebp
jmp 0x2a67b7
leaq 0x1300b7(%rip), %rsi    # 0x3d6861
movq %r14, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0x2a6807
movl %ebp, %r12d
testl %r12d, %r12d
je 0x2a67f8
movl 0x8(%rsp), %eax
cmpl 0x20(%r14), %eax
jne 0x2a67f8
testl %ebx, %ebx
leaq 0x1300e6(%rip), %rax    # 0x3d68b8
leaq 0xbd0e4(%rip), %rdx     # 0x3638bd
cmoveq %rax, %rdx
movl (%rsp), %r8d
movl %r8d, %ecx
subl %r12d, %ecx
leaq 0x1300b0(%rip), %rsi    # 0x3d689e
movq %r14, %rdi
xorl %eax, %eax
callq 0x2a6807
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq