// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl %esi, 0x40(%rdi)
jae 0x29f656
leaq 0x13659f(%rip), %rsi    # 0x3d5bcb
leaq 0x1366a9(%rip), %rdx    # 0x3d5cdc
leaq 0x1363f7(%rip), %r8     # 0x3d5a31
movl $0xb, %r12d
movl $0xb, %edi
movl $0x1201c, %ecx          # imm = 0x1201C
xorl %eax, %eax
callq 0x274d08
jmp 0x29f79c
movq %rcx, %r14
movl %edx, %ebp
movq %rdi, %r15
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x29f39e
movl %eax, %r12d
testl %eax, %eax
jne 0x29f79c
movq 0x18(%rsp), %rbx
cmpb $0x0, 0x1(%rbx)
je 0x29f6b4
leaq 0x136541(%rip), %rsi    # 0x3d5bcb
leaq 0x13664b(%rip), %rdx    # 0x3d5cdc
leaq 0x136399(%rip), %r8     # 0x3d5a31
movl $0xb, %r12d
movl $0xb, %edi
movl $0x12021, %ecx          # imm = 0x12021
xorl %eax, %eax
callq 0x274d08
jmp 0x29f78f
movb $0x1, 0x1(%rbx)
movzbl 0x9(%rbx), %r13d
cmpw $0x0, 0x18(%rbx)
je 0x29f739
movq %r13, 0x10(%rsp)
movl %ebp, 0xc(%rsp)
xorl %ebp, %ebp
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 0x29f70e
movl (%r13), %esi
bswapl %esi
movq %r15, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x29f612
testl %eax, %eax
jne 0x29f78c
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x29f7c7
testl %eax, %eax
jne 0x29f78c
incq %rbp
movzwl 0x18(%rbx), %eax
cmpq %rax, %rbp
jb 0x29f6cf
movl 0xc(%rsp), %ebp
movq 0x10(%rsp), %r13
jmp 0x29f73b
xorl %eax, %eax
cmpb $0x0, 0x8(%rbx)
je 0x29f74b
testq %r14, %r14
je 0x29f76a
addl %eax, (%r14)
jmp 0x29f76a
movq 0x50(%rbx), %rax
movl 0x8(%rax,%r13), %esi
bswapl %esi
movq %r15, %rdi
movl $0x1, %edx
movq %r14, %rcx
callq 0x29f612
testl %eax, %eax
jne 0x29f78c
testl %ebp, %ebp
je 0x29f77f
movq 0x48(%rbx), %rdi
movl 0x4(%rbx), %edx
movq %rbx, %rsi
callq 0x29f9d4
jmp 0x29f78c
movq 0x70(%rbx), %rdi
callq 0x2774a1
testl %eax, %eax
je 0x29f7ae
movl %eax, %r12d
movb $0x0, 0x1(%rbx)
movq 0x70(%rbx), %rdi
callq 0x28ab87
movl %r12d, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x50(%rbx), %rax
movzbl (%rax,%r13), %esi
orl $0x8, %esi
movq %rbx, %rdi
callq 0x28d2a2
xorl %r12d, %r12d
jmp 0x29f78f