// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: btreeOverwriteContent
static int btreeOverwriteContent(
  MemPage *pPage,           /* MemPage on which writing will occur */
  u8 *pDest,                /* Pointer to the place to start writing */
  const BtreePayload *pX,   /* Source of data to write */
  int iOffset,              /* Offset of first byte to write */
  int iAmt                  /* Number of bytes to be written */
){
  int nData = pX->nData - iOffset;
  if( nData<=0 ){
    /* Overwritting with zeros */
    int i;
    for(i=0; i<iAmt && pDest[i]==0; i++){}
    if( i<iAmt ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      memset(pDest + i, 0, iAmt - i);
    }
  }else{
    if( nData<iAmt ){
      /* Mixed read data and zeros at the end.  Make a recursive call
      ** to write the zeros then fall through to write the real data */
      int rc = btreeOverwriteContent(pPage, pDest+nData, pX, iOffset+nData,
                                 iAmt-nData);
      if( rc ) return rc;
      iAmt = nData;
    }
    if( memcmp(pDest, ((u8*)pX->pData) + iOffset, iAmt)!=0 ){
      int rc = sqlite3PagerWrite(pPage->pDbPage);
      if( rc ) return rc;
      /* In a corrupt database, it is possible for the source and destination
      ** buffers to overlap.  This is harmless since the database is already
      ** corrupt but it does cause valgrind and ASAN warnings.  So use
      ** memmove(). */
      memmove(pDest, ((u8*)pX->pData) + iOffset, iAmt);
    }
  }
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movq -0x20(%rbp), %rax
movl 0x24(%rax), %eax
subl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jg 0x40459a
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x28(%rbp), %ecx
movb %al, -0x3d(%rbp)
jge 0x40453b
movq -0x18(%rbp), %rax
movslq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x0, %eax
sete %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x404544
jmp 0x404551
jmp 0x404546
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x404519
movl -0x30(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x404595
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x40457a
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x404643
movq -0x18(%rbp), %rdi
movslq -0x30(%rbp), %rax
addq %rax, %rdi
movl -0x28(%rbp), %eax
subl -0x30(%rbp), %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x19360
jmp 0x40463c
movl -0x2c(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x4045df
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movslq -0x2c(%rbp), %rax
addq %rax, %rsi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
addl -0x2c(%rbp), %ecx
movl -0x28(%rbp), %r8d
subl -0x2c(%rbp), %r8d
callq 0x4044e0
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
je 0x4045d9
movl -0x38(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x404643
movl -0x2c(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x24(%rbp), %rax
addq %rax, %rsi
movslq -0x28(%rbp), %rdx
callq 0x192c0
cmpl $0x0, %eax
je 0x40463a
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x3c6610
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x40461e
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x404643
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movslq -0x24(%rbp), %rax
addq %rax, %rsi
movslq -0x28(%rbp), %rdx
callq 0x19bf0
jmp 0x40463c
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)