// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: btreeOverwriteCell
static int btreeOverwriteCell(BtCursor *pCur, const BtreePayload *pX){
  int iOffset;                        /* Next byte of pX->pData to write */
  int nTotal = pX->nData + pX->nZero; /* Total bytes of to write */
  int rc;                             /* Return code */
  MemPage *pPage = pCur->pPage;       /* Page being written */
  BtShared *pBt;                      /* Btree */
  Pgno ovflPgno;                      /* Next overflow page to write */
  u32 ovflPageSize;                   /* Size to write on overflow page */

  if( pCur->info.pPayload + pCur->info.nLocal > pPage->aDataEnd
   || pCur->info.pPayload < pPage->aData + pPage->cellOffset
  ){
    return SQLITE_CORRUPT_BKPT;
  }
  /* Overwrite the local portion first */
  rc = btreeOverwriteContent(pPage, pCur->info.pPayload, pX,
                             0, pCur->info.nLocal);
  if( rc ) return rc;
  if( pCur->info.nLocal==nTotal ) return SQLITE_OK;

  /* Now overwrite the overflow pages */
  iOffset = pCur->info.nLocal;
  assert( nTotal>=0 );
  assert( iOffset>=0 );
  ovflPgno = get4byte(pCur->info.pPayload + iOffset);
  pBt = pPage->pBt;
  ovflPageSize = pBt->usableSize - 4;
  do{
    rc = btreeGetPage(pBt, ovflPgno, &pPage, 0);
    if( rc ) return rc;
    if( sqlite3PagerPageRefcount(pPage->pDbPage)!=1 ){
      rc = SQLITE_CORRUPT_BKPT;
    }else{
      if( iOffset+ovflPageSize<(u32)nTotal ){
        ovflPgno = get4byte(pPage->aData);
      }else{
        ovflPageSize = nTotal - iOffset;
      }
      rc = btreeOverwriteContent(pPage, pPage->aData+4, pX,
                                 iOffset, ovflPageSize);
    }
    sqlite3PagerUnref(pPage->pDbPage);
    if( rc ) return rc;
    iOffset += ovflPageSize;
  }while( iOffset<nTotal );
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %rbx
movl 0x28(%rsi), %ebp
addl 0x24(%rsi), %ebp
movq 0x88(%rdi), %r12
movq %r12, 0x8(%rsp)
movq 0x38(%rdi), %rsi
movzwl 0x44(%rdi), %r8d
leaq (%rsi,%r8), %rax
cmpq 0x58(%r12), %rax
ja 0x2467da
movzwl 0x12(%r12), %eax
addq 0x50(%r12), %rax
cmpq %rax, %rsi
jae 0x2467f2
movl $0x11d58, %edi          # imm = 0x11D58
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x232547
movq %rdi, %r13
xorl %r15d, %r15d
movq %r12, %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2488a4
testl %eax, %eax
je 0x246811
movl %eax, %r15d
jmp 0x2468d2
movzwl 0x44(%r13), %r14d
cmpl %r14d, %ebp
je 0x2468d2
movl %r14d, %edi
addq 0x38(%r13), %rdi
callq 0x22fc59
movl %eax, 0x4(%rsp)
movq 0x48(%r12), %rax
movq %rax, 0x10(%rsp)
movl 0x38(%rax), %r12d
addl $-0x4, %r12d
movq 0x10(%rsp), %rdi
movl 0x4(%rsp), %esi
leaq 0x8(%rsp), %rdx
xorl %ecx, %ecx
callq 0x23639b
testl %eax, %eax
jne 0x246809
movq 0x8(%rsp), %r13
movq 0x70(%r13), %rax
cmpw $0x1, 0x36(%rax)
jne 0x246884
leal (%r12,%r14), %eax
cmpl %ebp, %eax
jae 0x246890
movq 0x50(%r13), %r15
movq %r15, %rdi
callq 0x22fc59
movl %eax, 0x4(%rsp)
jmp 0x24689a
movl $0x11d6b, %edi          # imm = 0x11D6B
callq 0x232547
jmp 0x2468b2
movl %ebp, %r12d
subl %r14d, %r12d
movq 0x50(%r13), %r15
addq $0x4, %r15
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x2488a4
movl %eax, %r15d
movq 0x70(%r13), %rdi
callq 0x2235a4
testl %r15d, %r15d
jne 0x2468d2
addl %r12d, %r14d
cmpl %ebp, %r14d
jl 0x246841
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq