// File: /workspace/github_c_makefile_star2_O1/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 0x2a8ea0
leaq 0x1364a5(%rip), %rsi    # 0x3df31f
leaq 0x1365af(%rip), %rdx    # 0x3df430
leaq 0x1362fd(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x1201c, %ecx          # imm = 0x1201C
xorl %eax, %eax
callq 0x27e637
jmp 0x2a8f06
movq %rcx, %r15
movl %edx, %r14d
movq %rdi, %r12
leaq 0x18(%rsp), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x2a8be0
movl %eax, %ebp
testl %eax, %eax
jne 0x2a8f06
movq 0x18(%rsp), %rbx
cmpb $0x0, 0x1(%rbx)
je 0x2a8f17
leaq 0x13644f(%rip), %rsi    # 0x3df31f
leaq 0x136559(%rip), %rdx    # 0x3df430
leaq 0x1362a7(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x12021, %ecx          # imm = 0x12021
xorl %eax, %eax
callq 0x27e637
movb $0x0, 0x1(%rbx)
testq %rbx, %rbx
je 0x2a8f06
movq 0x70(%rbx), %rdi
callq 0x2949b7
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x1(%rbx)
movzbl 0x9(%rbx), %r13d
movzwl 0x18(%rbx), %eax
testw %ax, %ax
je 0x2a8fae
movq %r13, 0x10(%rsp)
movl %r14d, 0xc(%rsp)
xorl %r14d, %r14d
movzwl 0x1a(%rbx), %eax
movq 0x60(%rbx), %rcx
movzbl (%rcx,%r14,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%r14,2), %r13d
orl %edx, %r13d
andl %eax, %r13d
addq 0x50(%rbx), %r13
cmpb $0x0, 0x8(%rbx)
jne 0x2a8f7e
movl (%r13), %esi
bswapl %esi
movq %r12, %rdi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2a8e60
testl %eax, %eax
jne 0x2a9002
movq %rbx, %rdi
movq %r13, %rsi
leaq 0x20(%rsp), %rdx
callq 0x2a9035
movl %eax, %ebp
testl %eax, %eax
jne 0x2a8ef4
incq %r14
movzwl 0x18(%rbx), %eax
cmpq %rax, %r14
jb 0x2a8f3a
movl 0xc(%rsp), %r14d
movq 0x10(%rsp), %r13
cmpb $0x0, 0x8(%rbx)
je 0x2a8fc1
testq %r15, %r15
je 0x2a8fe6
movzwl %ax, %eax
addl %eax, (%r15)
jmp 0x2a8fe6
movq 0x50(%rbx), %rax
movl 0x8(%rax,%r13), %esi
bswapl %esi
movq %r12, %rdi
movl $0x1, %edx
movq %r15, %rcx
callq 0x2a8e60
movl %eax, %ebp
testl %eax, %eax
jne 0x2a8ef4
testl %r14d, %r14d
je 0x2a9009
testl %ebp, %ebp
jne 0x2a8ef4
movq 0x48(%rbx), %rdi
movl 0x4(%rbx), %edx
movq %rbx, %rsi
callq 0x2a9252
movl %eax, %ebp
jmp 0x2a8ef4
movq 0x70(%rbx), %rdi
callq 0x280e3a
movl %eax, %ebp
testl %eax, %eax
jne 0x2a8ef4
movq 0x50(%rbx), %rax
movzbl (%rax,%r13), %esi
orl $0x8, %esi
movq %rbx, %rdi
callq 0x296f6d
jmp 0x2a8ef4