// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/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;

  assert( sqlite3_mutex_held(pBt->mutex) );
  if( pgno>btreePagecount(pBt) ){
    return SQLITE_CORRUPT_BKPT;
  }

  rc = getAndInitPage(pBt, pgno, &pPage, 0);
  if( rc ) return rc;
  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);
    if( rc ) goto cleardatabasepage_out;
  }
  if( !pPage->leaf ){
    rc = clearDatabasePage(pBt, get4byte(&pPage->aData[8]), 1, pnChange);
    if( rc ) goto cleardatabasepage_out;
  }else if( pnChange ){
    assert( pPage->intKey );
    *pnChange += pPage->nCell;
  }
  if( freePageFlag ){
    freePage(pPage, &rc);
  }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
    zeroPage(pPage, pPage->aData[0] | PTF_LEAF);
  }

cleardatabasepage_out:
  releasePage(pPage);
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
cmpl %esi, 0x3c(%rdi)
jae 0x33c95
leaq 0x45ba2(%rip), %rsi     # 0x79814
leaq 0x458c0(%rip), %rcx     # 0x79539
movl $0xb, %r13d
movl $0xb, %edi
movl $0xde85, %edx           # imm = 0xDE85
xorl %eax, %eax
callq 0xb9c7
jmp 0x33d8e
movq %rcx, %rbx
movl %edx, %r15d
movq %rdi, %r12
leaq -0x40(%rbp), %rdx
xorl %r14d, %r14d
xorl %ecx, %ecx
callq 0x30bd2
movl %eax, %r13d
testl %eax, %eax
jne 0x33d8e
movq %rbx, -0x30(%rbp)
movq -0x40(%rbp), %rbx
cmpw $0x0, 0x10(%rbx)
je 0x33d2d
movl %r15d, -0x34(%rbp)
xorl %r15d, %r15d
movzwl 0x12(%rbx), %eax
movq 0x60(%rbx), %rcx
movzbl (%rcx,%r15,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%r15,2), %r14d
orl %edx, %r14d
andl %eax, %r14d
addq 0x50(%rbx), %r14
cmpb $0x0, 0x3(%rbx)
jne 0x33d0d
movl (%r14), %esi
bswapl %esi
movq %r12, %rdi
movl $0x1, %edx
movq -0x30(%rbp), %rcx
callq 0x33c55
testl %eax, %eax
jne 0x33d82
movq %rbx, %rdi
movq %r14, %rsi
callq 0x310b9
testl %eax, %eax
jne 0x33d82
incq %r15
movzwl 0x10(%rbx), %r14d
cmpq %r14, %r15
jb 0x33ccd
movl -0x34(%rbp), %r15d
cmpb $0x0, 0x3(%rbx)
je 0x33d41
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0x33d5f
addl %r14d, (%rax)
jmp 0x33d5f
movq 0x50(%rbx), %rax
movl 0x8(%rax), %esi
bswapl %esi
movq %r12, %rdi
movl $0x1, %edx
movq -0x30(%rbp), %rcx
callq 0x33c55
testl %eax, %eax
jne 0x33d82
testl %r15d, %r15d
je 0x33d75
movq 0x48(%rbx), %rdi
movl 0x70(%rbx), %edx
movq %rbx, %rsi
callq 0x32d90
jmp 0x33d82
movq 0x68(%rbx), %rdi
callq 0xdfbf
testl %eax, %eax
je 0x33da0
movl %eax, %r13d
movq 0x68(%rbx), %rdi
callq 0xddd3
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x50(%rbx), %rax
movzbl (%rax), %esi
orl $0x8, %esi
movq %rbx, %rdi
callq 0x20600
xorl %r13d, %r13d
jmp 0x33d85