// File: /workspace/github_c_makefile_star2_O3/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), %r15
movq %r15, 0x8(%rsp)
movq 0x38(%rdi), %rsi
movzwl 0x44(%rdi), %r8d
leaq (%rsi,%r8), %rax
cmpq 0x58(%r15), %rax
ja 0x2a0816
movzwl 0x12(%r15), %eax
addq 0x50(%r15), %rax
cmpq %rax, %rsi
jae 0x2a0854
leaq 0x1353ae(%rip), %rsi    # 0x3d5bcb
leaq 0x1354b8(%rip), %rdx    # 0x3d5cdc
leaq 0x135206(%rip), %r8     # 0x3d5a31
movl $0xb, %r13d
movl $0xb, %edi
movl $0x11d58, %ecx          # imm = 0x11D58
xorl %eax, %eax
callq 0x274d08
movl %r13d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdi, %r12
xorl %r13d, %r13d
movq %r15, %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x2a29e4
testl %eax, %eax
je 0x2a0870
movl %eax, %r13d
jmp 0x2a0842
movzwl 0x44(%r12), %r14d
cmpl %r14d, %ebp
je 0x2a0842
movq 0x38(%r12), %rax
movl %r14d, %ecx
movl (%rax,%rcx), %eax
bswapl %eax
movl %eax, 0x4(%rsp)
movq 0x48(%r15), %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 0x28ced9
testl %eax, %eax
jne 0x2a086b
movq 0x8(%rsp), %r15
movq 0x70(%r15), %rax
cmpw $0x1, 0x36(%rax)
jne 0x2a08dc
leal (%r12,%r14), %eax
cmpl %ebp, %eax
jae 0x2a090a
movq 0x50(%r15), %rsi
movl (%rsi), %eax
bswapl %eax
movl %eax, 0x4(%rsp)
jmp 0x2a0914
movl $0xb, %r13d
movl $0xb, %edi
leaq 0x1352dd(%rip), %rsi    # 0x3d5bcb
leaq 0x1353e7(%rip), %rdx    # 0x3d5cdc
movl $0x11d6b, %ecx          # imm = 0x11D6B
leaq 0x135130(%rip), %r8     # 0x3d5a31
xorl %eax, %eax
callq 0x274d08
jmp 0x2a092c
movl %ebp, %r12d
subl %r14d, %r12d
movq 0x50(%r15), %rsi
addq $0x4, %rsi
movq %r15, %rdi
movq %rbx, %rdx
movl %r14d, %ecx
movl %r12d, %r8d
callq 0x2a29e4
movl %eax, %r13d
movq 0x70(%r15), %rdi
testq %rdi, %rdi
je 0x2a093a
callq 0x28ab87
testl %r13d, %r13d
jne 0x2a0842
addl %r12d, %r14d
xorl %r13d, %r13d
cmpl %ebp, %r14d
jl 0x2a089d
jmp 0x2a0842