// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: clearDatabasePage
static int clearDatabasePage(
  BtShared *pBt,           /* The BTree that contains the table */
  Pgno pgno,               /* Page number to clear */
  int freePageFlag,        /* Deallocate page if true */
  int *pnChange            /* Add number of Cells freed to this counter */
){
  MemPage *pPage;
  int rc;
  unsigned char *pCell;
  int i;
  int hdr;
  CellInfo info;

  assert( sqlite3_mutex_held(pBt->mutex) );
  if( pgno>btreePagecount(pBt) ){
    return SQLITE_CORRUPT_BKPT;
  }
  rc = getAndInitPage(pBt, pgno, &pPage, 0, 0);
  if( rc ) return rc;
  if( pPage->bBusy ){
    rc = SQLITE_CORRUPT_BKPT;
    goto cleardatabasepage_out;
  }
  pPage->bBusy = 1;
  hdr = pPage->hdrOffset;
  for(i=0; i<pPage->nCell; i++){
    pCell = findCell(pPage, i);
    if( !pPage->leaf ){
      rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
      if( rc ) goto cleardatabasepage_out;
    }
    rc = clearCell(pPage, pCell, &info);
    if( rc ) goto cleardatabasepage_out;
  }
  if( !pPage->leaf ){
    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
    if( rc ) goto cleardatabasepage_out;
  }else if( pnChange ){
    assert( pPage->intKey || CORRUPT_DB );
    testcase( !pPage->intKey );
    *pnChange += pPage->nCell;
  }
  if( freePageFlag ){
    freePage(pPage, &rc);
  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
    zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);
  }

cleardatabasepage_out:
  pPage->bBusy = 0;
  releasePage(pPage);
  return rc;
}

// Assembly:
cmpl %esi, 0x40(%rdi)
jae 0x245819
movl $0x1201c, %edi          # imm = 0x1201C
jmp 0x232547
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %r15
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x24561b
movl %eax, %r12d
testl %eax, %eax
jne 0x245869
movq 0x18(%rsp), %rbx
cmpb $0x0, 0x1(%rbx)
je 0x24587b
movl $0x12021, %edi          # imm = 0x12021
callq 0x232547
movl %eax, %r12d
movb $0x0, 0x1(%rbx)
movq %rbx, %rdi
callq 0x2376c6
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, 0x8(%rsp)
movb $0x1, 0x1(%rbx)
movzbl 0x9(%rbx), %eax
movq %rax, 0x10(%rsp)
xorl %ebp, %ebp
movzwl 0x18(%rbx), %eax
cmpq %rax, %rbp
jae 0x2458f4
movzwl 0x1a(%rbx), %eax
movq 0x60(%rbx), %rcx
movzbl (%rcx,%rbp,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%rbp,2), %r13d
orl %edx, %r13d
andl %eax, %r13d
addq 0x50(%rbx), %r13
cmpb $0x0, 0x8(%rbx)
jne 0x2458d8
movq %r13, %rdi
callq 0x22fc59
movq %r15, %rdi
movl %eax, %esi
pushq $0x1
popq %rdx
movq %r14, %rcx
callq 0x24580a
testl %eax, %eax
jne 0x24585a
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x245990
incq %rbp
testl %eax, %eax
je 0x24588e
jmp 0x24585a
andl $0x0, 0xc(%rsp)
cmpb $0x0, 0x8(%rbx)
je 0x24590d
testq %r14, %r14
movl 0x8(%rsp), %ecx
je 0x245943
addl %eax, (%r14)
jmp 0x245943
movq 0x50(%rbx), %rax
movq 0x10(%rsp), %rcx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
callq 0x22fc59
pushq $0x1
popq %rdx
movq %r15, %rdi
movl %eax, %esi
movq %r14, %rcx
callq 0x24580a
movl %eax, 0xc(%rsp)
testl %eax, %eax
movl 0x8(%rsp), %ecx
jne 0x24585a
testl %ecx, %ecx
je 0x24595f
leaq 0xc(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x245aee
movl (%r14), %r12d
jmp 0x24585d
movq 0x70(%rbx), %rdi
callq 0x2236f2
testl %eax, %eax
jne 0x24585a
movq 0x50(%rbx), %rax
movq 0x10(%rsp), %rcx
movzbl (%rax,%rcx), %esi
orl $0x8, %esi
movq %rbx, %rdi
callq 0x2366bf
xorl %r12d, %r12d
jmp 0x24585d