// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: clearCell
static int clearCell(
  MemPage *pPage,          /* The page that contains the Cell */
  unsigned char *pCell,    /* First byte of the Cell */
  CellInfo *pInfo          /* Size information about the cell */
){
  BtShared *pBt;
  Pgno ovflPgno;
  int rc;
  int nOvfl;
  u32 ovflPageSize;

  assert( sqlite3_mutex_held(pPage->pBt->mutex) );
  pPage->xParseCell(pPage, pCell, pInfo);
  if( pInfo->nLocal==pInfo->nPayload ){
    return SQLITE_OK;  /* No overflow pages. Return without doing anything */
  }
  testcase( pCell + pInfo->nSize == pPage->aDataEnd );
  testcase( pCell + (pInfo->nSize-1) == pPage->aDataEnd );
  if( pCell + pInfo->nSize > pPage->aDataEnd ){
    /* Cell extends past end of page */
    return SQLITE_CORRUPT_PAGE(pPage);
  }
  ovflPgno = get4byte(pCell + pInfo->nSize - 4);
  pBt = pPage->pBt;
  assert( pBt->usableSize > 4 );
  ovflPageSize = pBt->usableSize - 4;
  nOvfl = (pInfo->nPayload - pInfo->nLocal + ovflPageSize - 1)/ovflPageSize;
  assert( nOvfl>0 ||
    (CORRUPT_DB && (pInfo->nPayload + ovflPageSize)<ovflPageSize)
  );
  while( nOvfl-- ){
    Pgno iNext = 0;
    MemPage *pOvfl = 0;
    if( ovflPgno<2 || ovflPgno>btreePagecount(pBt) ){
      /* 0 is not a legal page number and page 1 cannot be an
      ** overflow page. Therefore if ovflPgno<2 or past the end of the
      ** file the database must be corrupt. */
      return SQLITE_CORRUPT_BKPT;
    }
    if( nOvfl ){
      rc = getOverflowPage(pBt, ovflPgno, &pOvfl, &iNext);
      if( rc ) return rc;
    }

    if( ( pOvfl || ((pOvfl = btreePageLookup(pBt, ovflPgno))!=0) )
     && sqlite3PagerPageRefcount(pOvfl->pDbPage)!=1
    ){
      /* There is no reason any cursor should have an outstanding reference
      ** to an overflow page belonging to a cell that is being deleted/updated.
      ** So if there exists more than one reference to this page, then it
      ** must not really be an overflow page and the database must be corrupt.
      ** It is helpful to detect this before calling freePage2(), as
      ** freePage2() may zero the page contents if secure-delete mode is
      ** enabled. If this 'overflow' page happens to be a page that the
      ** caller is iterating through or using in some other way, this
      ** can be problematic.
      */
      rc = SQLITE_CORRUPT_BKPT;
    }else{
      rc = freePage2(pBt, pOvfl, ovflPgno);
    }

    if( pOvfl ){
      sqlite3PagerUnref(pOvfl->pDbPage);
    }
    if( rc ) return rc;
    ovflPgno = iNext;
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
callq *0x80(%rdi)
movzwl 0x14(%r12), %ecx
movl 0x10(%r12), %eax
xorl %r15d, %r15d
cmpl %ecx, %eax
je 0x2a91ef
movzwl 0x16(%r12), %edx
addq %rdx, %rbx
cmpq 0x58(%r14), %rbx
jbe 0x2a90a8
leaq 0x1362a1(%rip), %rsi    # 0x3df31f
leaq 0x1363ab(%rip), %rdx    # 0x3df430
leaq 0x1360f9(%rip), %r8     # 0x3df185
movl $0xb, %r15d
movl $0xb, %edi
movl $0x114e1, %ecx          # imm = 0x114E1
xorl %eax, %eax
callq 0x27e637
jmp 0x2a91ef
movl -0x4(%rbx), %ebx
bswapl %ebx
movq 0x48(%r14), %r14
movl 0x38(%r14), %edx
notl %ecx
addl %ecx, %eax
addl %edx, %eax
addl $-0x4, %eax
movl %edx, %ecx
addl $-0x4, %ecx
xorl %edx, %edx
divl %ecx
movl %eax, %ebp
subl $0x1, %ebp
jb 0x2a91ec
movl $0x0, 0x14(%rsp)
movq $0x0, 0x8(%rsp)
cmpl $0x2, %ebx
jb 0x2a90ee
cmpl 0x40(%r14), %ebx
jbe 0x2a9122
xorl %r13d, %r13d
movl $0xb, %r15d
movl $0xb, %edi
leaq 0x13621c(%rip), %rsi    # 0x3df31f
leaq 0x136326(%rip), %rdx    # 0x3df430
movl $0x114f2, %ecx          # imm = 0x114F2
leaq 0x13606f(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
jmp 0x2a91de
testl %ebp, %ebp
je 0x2a9146
movq %r14, %rdi
movl %ebx, %esi
leaq 0x8(%rsp), %rdx
leaq 0x14(%rsp), %rcx
callq 0x2981b3
testl %eax, %eax
je 0x2a9146
movl %eax, %r15d
jmp 0x2a91cf
cmpq $0x0, 0x8(%rsp)
jne 0x2a9162
movq %r14, %rdi
movl %ebx, %esi
callq 0x2a9201
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x2a9172
movq 0x8(%rsp), %rax
movq 0x70(%rax), %rax
cmpw $0x1, 0x36(%rax)
jne 0x2a9186
movq 0x8(%rsp), %rsi
movq %r14, %rdi
movl %ebx, %edx
callq 0x2a9252
movl %eax, %r15d
jmp 0x2a91b2
movl $0xb, %r15d
movl $0xb, %edi
leaq 0x136187(%rip), %rsi    # 0x3df31f
leaq 0x136291(%rip), %rdx    # 0x3df430
movl $0x11506, %ecx          # imm = 0x11506
leaq 0x135fda(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
movq 0x8(%rsp), %rax
testq %rax, %rax
je 0x2a91ca
movq 0x70(%rax), %rdi
testq %rdi, %rdi
je 0x2a91ca
callq 0x2949b7
testl %r15d, %r15d
je 0x2a91d4
xorl %r13d, %r13d
jmp 0x2a91de
movb $0x1, %r13b
movl 0x14(%rsp), %ebx
movl %r12d, %r15d
movl %r15d, %r12d
testb %r13b, %r13b
jne 0x2a90c9
jmp 0x2a91ef
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq