// File: /workspace/github_c_makefile_star2_O1/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 0x2aa205
movzwl 0x12(%r15), %eax
addq 0x50(%r15), %rax
cmpq %rax, %rsi
jae 0x2aa243
leaq 0x135113(%rip), %rsi    # 0x3df31f
leaq 0x13521d(%rip), %rdx    # 0x3df430
leaq 0x134f6b(%rip), %r8     # 0x3df185
movl $0xb, %r13d
movl $0xb, %edi
movl $0x11d58, %ecx          # imm = 0x11D58
xorl %eax, %eax
callq 0x27e637
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 0x2ac4d4
testl %eax, %eax
je 0x2aa25f
movl %eax, %r13d
jmp 0x2aa231
movzwl 0x44(%r12), %r14d
cmpl %r14d, %ebp
je 0x2aa231
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 0x296bb1
testl %eax, %eax
jne 0x2aa25a
movq 0x8(%rsp), %r15
movq 0x70(%r15), %rax
cmpw $0x1, 0x36(%rax)
jne 0x2aa2cb
leal (%r12,%r14), %eax
cmpl %ebp, %eax
jae 0x2aa2f9
movq 0x50(%r15), %rax
movl (%rax), %eax
bswapl %eax
movl %eax, 0x4(%rsp)
jmp 0x2aa2ff
movl $0xb, %r13d
movl $0xb, %edi
leaq 0x135042(%rip), %rsi    # 0x3df31f
leaq 0x13514c(%rip), %rdx    # 0x3df430
movl $0x11d6b, %ecx          # imm = 0x11D6B
leaq 0x134e95(%rip), %r8     # 0x3df185
xorl %eax, %eax
callq 0x27e637
jmp 0x2aa31b
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 0x2ac4d4
movl %eax, %r13d
movq 0x70(%r15), %rdi
testq %rdi, %rdi
je 0x2aa329
callq 0x2949b7
testl %r13d, %r13d
jne 0x2aa231
addl %r12d, %r14d
xorl %r13d, %r13d
cmpl %ebp, %r14d
jl 0x2aa28c
jmp 0x2aa231