// File: /workspace/github_c_makefile_star2_O1/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 %edx, %r12d
movl %esi, 0x4(%rsp)
movq %rdi, %r14
movl 0x20(%rdi), %eax
movl %eax, 0x1c(%rsp)
leaq 0x8(%rsp), %r15
movl %ecx, 0x18(%rsp)
movl %ecx, %ebx
testl %r12d, %r12d
je 0x2b039d
cmpl $0x0, 0x1c(%r14)
je 0x2b039d
movq %r14, %rdi
movl %r12d, %esi
callq 0x2b0d96
testl %eax, %eax
je 0x2b022d
xorl %ebp, %ebp
jmp 0x2b0394
leal -0x1(%rbx), %r13d
movq 0x8(%r14), %rdi
movl %r12d, %esi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x108(%rdi)
testl %eax, %eax
je 0x2b0265
xorl %ebp, %ebp
movq %r14, %rdi
leaq 0x12fd5b(%rip), %rsi    # 0x3dffae
movl %r12d, %edx
xorl %eax, %eax
callq 0x2b03ec
movl %r13d, %ebx
jmp 0x2b0394
movl %r13d, (%rsp)
movq 0x8(%rsp), %rax
movq 0x8(%rax), %r15
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x2b0302
movzbl 0x4(%r15), %ecx
movzbl 0x5(%r15), %esi
movzbl 0x6(%r15), %ebp
movzbl 0x7(%r15), %edx
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2b02c5
movq %r14, %rdi
movq %rsi, 0x20(%rsp)
movl %r12d, %esi
movl %edx, 0x14(%rsp)
movl $0x2, %edx
movq %rcx, %r13
xorl %ecx, %ecx
callq 0x2b04fc
movq 0x20(%rsp), %rsi
movl 0x14(%rsp), %edx
movq %r13, %rcx
shll $0x18, %ecx
shll $0x10, %esi
leal (%rsi,%rcx), %r13d
shll $0x8, %ebp
orl %ebp, %r13d
orl %edx, %r13d
movq (%r14), %rax
movl 0x38(%rax), %eax
shrl $0x2, %eax
addl $-0x2, %eax
cmpl %eax, %r13d
jbe 0x2b0329
movq %r14, %rdi
leaq 0x12fcd1(%rip), %rsi    # 0x3dffc4
movl %r12d, %edx
xorl %eax, %eax
callq 0x2b03ec
addl $-0x2, %ebx
jmp 0x2b0377
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2b0374
movl (%rsp), %ebx
testl %ebx, %ebx
je 0x2b0377
movl (%r15), %esi
bswapl %esi
movq %r14, %rdi
movl $0x4, %edx
movl %r12d, %ecx
callq 0x2b04fc
jmp 0x2b0377
testl %r13d, %r13d
jle 0x2b036c
addl %esi, %ecx
addl %edx, %ebp
addl %ecx, %ebp
xorl %ebx, %ebx
movl 0x8(%r15,%rbx,4), %r12d
bswapl %r12d
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x2b0359
movq %r14, %rdi
movl %r12d, %esi
movl $0x2, %edx
xorl %ecx, %ecx
callq 0x2b04fc
movq %r14, %rdi
movl %r12d, %esi
callq 0x2b0d96
incq %rbx
cmpq %rbx, %rbp
jne 0x2b0336
movl (%rsp), %ebx
subl %r13d, %ebx
jmp 0x2b0377
movl (%rsp), %ebx
movl (%r15), %r12d
bswapl %r12d
movq 0x8(%rsp), %rdi
movb $0x1, %bpl
testq %rdi, %rdi
je 0x2b038f
callq 0x2949b7
leaq 0x8(%rsp), %r15
testb %bpl, %bpl
jne 0x2b0203
testl %ebx, %ebx
je 0x2b03dd
movl 0x1c(%rsp), %eax
cmpl 0x20(%r14), %eax
jne 0x2b03dd
cmpl $0x0, 0x4(%rsp)
leaq 0x12fc4e(%rip), %rax    # 0x3e0005
leaq 0xbc60f(%rip), %rdx     # 0x36c9cd
cmoveq %rax, %rdx
movl 0x18(%rsp), %r8d
movl %r8d, %ecx
subl %ebx, %ecx
leaq 0x12fc18(%rip), %rsi    # 0x3dffeb
movq %r14, %rdi
xorl %eax, %eax
callq 0x2b03ec
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq