// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e7da0
movl %eax, %ecx
movl -0x5c(%rbp), %eax
cmpl %ecx, %eax
jbe 0x4015b0
movl $0x1201c, %edi          # imm = 0x1201C
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x4017a1
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
leaq -0x28(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
callq 0x4010f0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x4015db
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4017a1
movq -0x28(%rbp), %rax
cmpb $0x0, 0x1(%rax)
je 0x4015f7
movl $0x12021, %edi          # imm = 0x12021
callq 0x3dff80
movl %eax, -0x2c(%rbp)
jmp 0x40178a
movq -0x28(%rbp), %rax
movb $0x1, 0x1(%rax)
movq -0x28(%rbp), %rax
movzbl 0x9(%rax), %eax
movl %eax, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x18(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4016dc
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movq -0x28(%rbp), %rcx
movzwl 0x1a(%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, 0x8(%rax)
jne 0x4016ad
movq -0x10(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3db720
movq -0x68(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x401570
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x4016ab
jmp 0x40178a
jmp 0x4016ad
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
leaq -0x58(%rbp), %rdx
callq 0x4017b0
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x4016cc
jmp 0x40178a
jmp 0x4016ce
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x401611
movq -0x28(%rbp), %rax
cmpb $0x0, 0x8(%rax)
jne 0x401727
movq -0x10(%rbp), %rax
movq %rax, -0x70(%rbp)
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
movl -0x40(%rbp), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
callq 0x3db720
movq -0x70(%rbp), %rdi
movl %eax, %esi
movq -0x20(%rbp), %rcx
movl $0x1, %edx
callq 0x401570
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x401725
jmp 0x40178a
jmp 0x401740
cmpq $0x0, -0x20(%rbp)
je 0x40173e
movq -0x28(%rbp), %rax
movzwl 0x18(%rax), %ecx
movq -0x20(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
jmp 0x401740
cmpl $0x0, -0x18(%rbp)
je 0x401755
movq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rsi
callq 0x401990
jmp 0x401788
movq -0x28(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x2c(%rbp)
cmpl $0x0, %eax
jne 0x401786
movq -0x28(%rbp), %rdi
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rax
movslq -0x40(%rbp), %rcx
movzbl (%rax,%rcx), %esi
orl $0x8, %esi
callq 0x3e79f0
jmp 0x401788
jmp 0x40178a
movq -0x28(%rbp), %rax
movb $0x0, 0x1(%rax)
movq -0x28(%rbp), %rdi
callq 0x3e9b70
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw (%rax,%rax)