// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x24(%rax), %eax
movq -0x18(%rbp), %rcx
addl 0x28(%rcx), %eax
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
movzwl 0x44(%rcx), %ecx
movslq %ecx, %rcx
addq %rcx, %rax
movq -0x30(%rbp), %rcx
cmpq 0x58(%rcx), %rax
ja 0x403623
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x30(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq -0x30(%rbp), %rdx
movzwl 0x12(%rdx), %edx
movslq %edx, %rdx
addq %rdx, %rcx
cmpq %rcx, %rax
jae 0x403635
movl $0x11d58, %edi          # imm = 0x11D58
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x403784
movq -0x30(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rsi
movq -0x18(%rbp), %rdx
movq -0x10(%rbp), %rax
movzwl 0x44(%rax), %r8d
xorl %ecx, %ecx
callq 0x4044e0
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x403669
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x403784
movq -0x10(%rbp), %rax
movzwl 0x44(%rax), %eax
cmpl -0x20(%rbp), %eax
jne 0x403682
movl $0x0, -0x4(%rbp)
jmp 0x403784
movq -0x10(%rbp), %rax
movzwl 0x44(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movslq -0x1c(%rbp), %rax
addq %rax, %rdi
callq 0x3db720
movl %eax, -0x3c(%rbp)
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x38(%rax), %eax
subl $0x4, %eax
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movl -0x3c(%rbp), %esi
leaq -0x30(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3e6f40
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
je 0x4036e3
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x403784
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3e4110
cmpl $0x1, %eax
je 0x403704
movl $0x11d6b, %edi          # imm = 0x11D6B
callq 0x3dff80
movl %eax, -0x24(%rbp)
jmp 0x40374d
movl -0x1c(%rbp), %eax
addl -0x40(%rbp), %eax
cmpl -0x20(%rbp), %eax
jae 0x403721
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x3db720
movl %eax, -0x3c(%rbp)
jmp 0x40372a
movl -0x20(%rbp), %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x30(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x50(%rax), %rsi
addq $0x4, %rsi
movq -0x18(%rbp), %rdx
movl -0x1c(%rbp), %ecx
movl -0x40(%rbp), %r8d
callq 0x4044e0
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c62b0
cmpl $0x0, -0x24(%rbp)
je 0x403768
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x403784
movl -0x40(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jl 0x4036bd
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)