// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq *%rax
movq -0x20(%rbp), %rax
movzwl 0x14(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jne 0x4017fa
movl $0x0, -0x4(%rbp)
jmp 0x401985
movq -0x18(%rbp), %rax
movq -0x20(%rbp), %rcx
movzwl 0x16(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x10(%rbp), %rcx
cmpq 0x58(%rcx), %rax
jbe 0x401828
movl $0x114e1, %edi          # imm = 0x114E1
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x401985
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movzwl 0x16(%rax), %eax
cltq
addq %rax, %rdi
addq $-0x4, %rdi
callq 0x3db720
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movl 0x38(%rax), %eax
subl $0x4, %eax
movl %eax, -0x38(%rbp)
movq -0x20(%rbp), %rax
movl 0x10(%rax), %eax
movq -0x20(%rbp), %rcx
movzwl 0x14(%rcx), %ecx
subl %ecx, %eax
addl -0x38(%rbp), %eax
subl $0x1, %eax
xorl %edx, %edx
divl -0x38(%rbp)
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x34(%rbp)
cmpl $0x0, %eax
je 0x40197e
movl $0x0, -0x3c(%rbp)
movq $0x0, -0x48(%rbp)
cmpl $0x2, -0x2c(%rbp)
jb 0x4018be
movl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x3e7da0
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jbe 0x4018d0
movl $0x114f2, %edi          # imm = 0x114F2
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x401985
cmpl $0x0, -0x34(%rbp)
je 0x401900
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %esi
leaq -0x48(%rbp), %rdx
leaq -0x3c(%rbp), %rcx
callq 0x3e98f0
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x4018fe
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x401985
jmp 0x401900
cmpq $0x0, -0x48(%rbp)
jne 0x40191d
movq -0x28(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4019d0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
je 0x40193e
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3e4110
cmpl $0x1, %eax
je 0x40193e
movl $0x11506, %edi          # imm = 0x11506
callq 0x3dff80
movl %eax, -0x30(%rbp)
jmp 0x401951
movq -0x28(%rbp), %rdi
movq -0x48(%rbp), %rsi
movl -0x2c(%rbp), %edx
callq 0x401a30
movl %eax, -0x30(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x401965
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c62b0
cmpl $0x0, -0x30(%rbp)
je 0x401973
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x401985
movl -0x3c(%rbp), %eax
movl %eax, -0x2c(%rbp)
jmp 0x40187d
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop