// File: /workspace/github_c_makefile_star2_O1/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 0x3357a
leaq 0x462bd(%rip), %rsi     # 0x79814
leaq 0x45fdb(%rip), %rcx     # 0x79539
movl $0xb, %r15d
movl $0xb, %edi
movl $0xde85, %edx           # imm = 0xDE85
xorl %eax, %eax
callq 0xb8cc
jmp 0x3369d
movq %rcx, %r12
movl %edx, %r14d
movq %rdi, %r13
leaq -0x40(%rbp), %rdx
xorl %ecx, %ecx
callq 0x302c8
movl %eax, %r15d
testl %eax, %eax
jne 0x3369d
movq -0x40(%rbp), %rbx
movzwl 0x10(%rbx), %eax
testw %ax, %ax
je 0x3361b
movq %r12, -0x38(%rbp)
movl %r14d, -0x2c(%rbp)
xorl %r12d, %r12d
movzwl 0x12(%rbx), %eax
movq 0x60(%rbx), %rcx
movzbl (%rcx,%r12,2), %edx
shll $0x8, %edx
movzbl 0x1(%rcx,%r12,2), %r14d
orl %edx, %r14d
andl %eax, %r14d
addq 0x50(%rbx), %r14
cmpb $0x0, 0x3(%rbx)
jne 0x335f1
movl (%r14), %esi
bswapl %esi
movq %r13, %rdi
movl $0x1, %edx
movq -0x38(%rbp), %rcx
callq 0x3353a
testl %eax, %eax
jne 0x33668
movq %rbx, %rdi
movq %r14, %rsi
callq 0x30802
movl %eax, %r15d
testl %eax, %eax
jne 0x3368f
incq %r12
movzwl 0x10(%rbx), %eax
cmpq %rax, %r12
jb 0x335b1
movl -0x2c(%rbp), %r14d
movq -0x38(%rbp), %r12
cmpb $0x0, 0x3(%rbx)
je 0x3362f
testq %r12, %r12
je 0x3364f
movzwl %ax, %eax
addl %eax, (%r12)
jmp 0x3364f
movq 0x50(%rbx), %rax
movl 0x8(%rax), %esi
bswapl %esi
movq %r13, %rdi
movl $0x1, %edx
movq %r12, %rcx
callq 0x3353a
movl %eax, %r15d
testl %eax, %eax
jne 0x3368f
testl %r14d, %r14d
je 0x3366d
testl %r15d, %r15d
jne 0x3368f
movq 0x48(%rbx), %rdi
movl 0x70(%rbx), %edx
movq %rbx, %rsi
callq 0x32647
movl %eax, %r15d
jmp 0x3368f
movq 0x68(%rbx), %rdi
callq 0xdebf
movl %eax, %r15d
testl %eax, %eax
jne 0x3368f
movq 0x50(%rbx), %rax
movzbl (%rax), %esi
orl $0x8, %esi
movq %rbx, %rdi
callq 0x20900
testq %rbx, %rbx
je 0x3369d
movq 0x68(%rbx), %rdi
callq 0xdcd4
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq