// File: /workspace/github_c_makefile_star2_O2/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, %ebx
movl %esi, %r13d
movq %rdi, %r14
movl 0x20(%rdi), %eax
movl %eax, 0x18(%rsp)
movl %ecx, 0x14(%rsp)
movl %ecx, %ebp
movl %esi, 0x1c(%rsp)
testl %ebx, %ebx
je 0x24bbdf
cmpl $0x0, 0x1c(%r14)
je 0x24bbdf
movq %r14, %rdi
movl %ebx, %esi
callq 0x24c475
testl %eax, %eax
jne 0x24bbc4
leal -0x1(%rbp), %r12d
movq 0x8(%r14), %rdi
movl %ebx, %esi
leaq 0x20(%rsp), %rdx
xorl %ecx, %ecx
callq *0x108(%rdi)
testl %eax, %eax
jne 0x24bbc9
movq 0x20(%rsp), %rax
movq 0x8(%rax), %r15
testl %r13d, %r13d
je 0x24bb26
movq %r15, 0x8(%rsp)
leaq 0x4(%r15), %rdi
callq 0x22fc59
movl %eax, %r15d
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x24bafd
movq %r14, %rdi
movl %ebx, %esi
pushq $0x2
popq %rdx
xorl %ecx, %ecx
callq 0x24bd22
movq (%r14), %rax
movl 0x38(%rax), %eax
shrl $0x2, %eax
addl $-0x2, %eax
cmpl %eax, %r15d
jbe 0x24bb4d
movq %r14, %rdi
leaq 0x12b182(%rip), %rsi    # 0x376c97
movl %ebx, %edx
xorl %eax, %eax
callq 0x24bc2c
addl $-0x2, %ebp
movl %ebp, %r12d
jmp 0x24bba3
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x24bba8
testl %r12d, %r12d
je 0x24bba8
movq %r15, %rdi
callq 0x22fc59
movq %r14, %rdi
movl %eax, %esi
pushq $0x4
popq %rdx
movl %ebx, %ecx
callq 0x24bd22
jmp 0x24bba8
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rbx
testl %r15d, %r15d
movl $0x0, %r13d
cmovgl %r15d, %r13d
subq $0x1, %r13
jb 0x24bb9b
movq %rbx, %rdi
callq 0x22fc59
movl %eax, %ebp
movq (%r14), %rax
cmpb $0x0, 0x21(%rax)
je 0x24bb8b
movq %r14, %rdi
movl %ebp, %esi
pushq $0x2
popq %rdx
xorl %ecx, %ecx
callq 0x24bd22
movq %r14, %rdi
movl %ebp, %esi
callq 0x24c475
addq $0x4, %rbx
jmp 0x24bb63
subl %r15d, %r12d
movl 0x1c(%rsp), %r13d
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x22fc59
movl %eax, %ebx
movq 0x20(%rsp), %rdi
callq 0x2235a4
movl %r12d, %ebp
jmp 0x24ba7f
movl %ebp, %r12d
jmp 0x24bbdc
leaq 0x12b0b1(%rip), %rsi    # 0x376c81
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x24bc2c
movl %r12d, %ebp
testl %ebp, %ebp
je 0x24bc1d
movl 0x18(%rsp), %eax
cmpl 0x20(%r14), %eax
jne 0x24bc1d
testl %r13d, %r13d
leaq 0x12b0e1(%rip), %rax    # 0x376cd8
leaq 0xb7bef(%rip), %rdx     # 0x3037ed
cmoveq %rax, %rdx
movl 0x14(%rsp), %r8d
movl %r8d, %ecx
subl %ebp, %ecx
leaq 0x12b0ab(%rip), %rsi    # 0x376cbe
movq %r14, %rdi
xorl %eax, %eax
callq 0x24bc2c
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq