// File: /workspace/github_c_makefile_star2_O0/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
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2ab10
movl %eax, %ecx
movl -0x40(%rbp), %eax
cmpl %ecx, %eax
jbe 0x46320
movl $0xde85, %edi           # imm = 0xDE85
callq 0x24410
movl %eax, -0x4(%rbp)
jmp 0x464c5
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x28(%rbp), %rdx
xorl %ecx, %ecx
callq 0x40ca0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x46346
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x464c5
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x10(%rcx), %ecx
cmpl %ecx, %eax
jge 0x46414
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x28(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
movq -0x28(%rbp), %rdx
movq 0x60(%rdx), %rdx
movl -0x3c(%rbp), %esi
shll %esi
movslq %esi, %rsi
movzbl (%rdx,%rsi), %edx
shll $0x8, %edx
movq -0x28(%rbp), %rsi
movq 0x60(%rsi), %rsi
movl -0x3c(%rbp), %edi
shll %edi
movslq %edi, %rdi
movzbl 0x1(%rsi,%rdi), %esi
orl %esi, %edx
andl %edx, %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
cmpb $0x0, 0x3(%rax)
jne 0x463e9
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rdi
callq 0x20a50
movq -0x48(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x462e0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x463e7
jmp 0x464b6
jmp 0x463e9
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x41db0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x46404
jmp 0x464b6
jmp 0x46406
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x4634d
movq -0x28(%rbp), %rax
cmpb $0x0, 0x3(%rax)
jne 0x46458
movq -0x10(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
addq $0x8, %rdi
callq 0x20a50
movq -0x50(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x462e0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x46456
jmp 0x464b6
jmp 0x46471
cmpq $0x0, -0x20(%rbp)
je 0x4646f
movq -0x28(%rbp), %rax
movzwl 0x10(%rax), %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x46471
cmpl $0x0, -0x18(%rbp)
je 0x46486
movq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x44f90
jmp 0x464b4
movq -0x28(%rbp), %rax
movq 0x68(%rax), %rdi
callq 0xef80
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jne 0x464b2
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movzbl (%rax), %esi
orl $0x8, %esi
callq 0x2a920
jmp 0x464b4
jmp 0x464b6
movq -0x28(%rbp), %rdi
callq 0x29fd0
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop