// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: backupOnePage
static int backupOnePage(
  sqlite3_backup *p,              /* Backup handle */
  Pgno iSrcPg,                    /* Source database page to backup */
  const u8 *zSrcData,             /* Source database page data */
  int bUpdate                     /* True for an update, false otherwise */
){
  Pager * const pDestPager = sqlite3BtreePager(p->pDest);
  const int nSrcPgsz = sqlite3BtreeGetPageSize(p->pSrc);
  int nDestPgsz = sqlite3BtreeGetPageSize(p->pDest);
  const int nCopy = MIN(nSrcPgsz, nDestPgsz);
  const i64 iEnd = (i64)iSrcPg*(i64)nSrcPgsz;
  int rc = SQLITE_OK;
  i64 iOff;

  assert( sqlite3BtreeGetReserveNoMutex(p->pSrc)>=0 );
  assert( p->bDestLocked );
  assert( !isFatalError(p->rc) );
  assert( iSrcPg!=PENDING_BYTE_PAGE(p->pSrc->pBt) );
  assert( zSrcData );

  /* Catch the case where the destination is an in-memory database and the
  ** page sizes of the source and destination differ.
  */
  if( nSrcPgsz!=nDestPgsz && sqlite3PagerIsMemdb(pDestPager) ){
    rc = SQLITE_READONLY;
  }

  /* This loop runs once for each destination page spanned by the source
  ** page. For each iteration, variable iOff is set to the byte offset
  ** of the destination page.
  */
  for(iOff=iEnd-(i64)nSrcPgsz; rc==SQLITE_OK && iOff<iEnd; iOff+=nDestPgsz){
    DbPage *pDestPg = 0;
    Pgno iDest = (Pgno)(iOff/nDestPgsz)+1;
    if( iDest==PENDING_BYTE_PAGE(p->pDest->pBt) ) continue;
    if( SQLITE_OK==(rc = sqlite3PagerGet(pDestPager, iDest, &pDestPg, 0))
     && SQLITE_OK==(rc = sqlite3PagerWrite(pDestPg))
    ){
      const u8 *zIn = &zSrcData[iOff%nSrcPgsz];
      u8 *zDestData = sqlite3PagerGetData(pDestPg);
      u8 *zOut = &zDestData[iOff%nDestPgsz];

      /* Copy the data from the source page into the destination page.
      ** Then clear the Btree layer MemPage.isInit flag. Both this module
      ** and the pager code use this trick (clearing the first byte
      ** of the page 'extra' space to invalidate the Btree layers
      ** cached parse of the page). MemPage.isInit is marked
      ** "MUST BE FIRST" for this purpose.
      */
      memcpy(zOut, zIn, nCopy);
      ((u8 *)sqlite3PagerGetExtra(pDestPg))[0] = 0;
      if( iOff==0 && bUpdate==0 ){
        sqlite3Put4byte(&zOut[28], sqlite3BtreeLastPage(p->pSrc));
      }
    }
    sqlite3PagerUnref(pDestPg);
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3bfda0
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3c5fc0
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x3c5fc0
movl %eax, -0x30(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x3c60ba
movl -0x2c(%rbp), %eax
movl %eax, -0x7c(%rbp)
jmp 0x3c60c0
movl -0x30(%rbp), %eax
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
movslq -0x2c(%rbp), %rcx
imulq %rcx, %rax
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x30(%rbp), %eax
je 0x3c60f9
movq -0x28(%rbp), %rdi
callq 0x3e7dc0
cmpl $0x0, %eax
je 0x3c60f9
movl $0x8, -0x44(%rbp)
movq -0x40(%rbp), %rax
movslq -0x2c(%rbp), %rcx
subq %rcx, %rax
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x44(%rbp)
movb %al, -0x7d(%rbp)
jne 0x3c6121
movq -0x50(%rbp), %rax
cmpq -0x40(%rbp), %rax
setl %al
movb %al, -0x7d(%rbp)
movb -0x7d(%rbp), %al
testb $0x1, %al
jne 0x3c612d
jmp 0x3c627e
movq $0x0, -0x58(%rbp)
movq -0x50(%rbp), %rax
movslq -0x30(%rbp), %rcx
cqto
idivq %rcx
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x84(%rbp)
movl 0x279b59(%rip), %eax    # 0x63fcb0
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
movq 0x8(%rcx), %rcx
xorl %edx, %edx
divl 0x34(%rcx)
movl %eax, %ecx
movl -0x84(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3c617c
jmp 0x3c626d
movq -0x28(%rbp), %rdi
movl -0x5c(%rbp), %esi
leaq -0x58(%rbp), %rdx
xorl %ecx, %ecx
callq 0x3c6020
movl %eax, %ecx
movl %ecx, -0x44(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3c6264
movq -0x58(%rbp), %rdi
callq 0x3c6610
movl %eax, %ecx
movl %ecx, -0x44(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3c6264
movq -0x18(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x50(%rbp), %rax
movslq -0x2c(%rbp), %rcx
cqto
idivq %rcx
movq -0x98(%rbp), %rax
addq %rdx, %rax
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdi
callq 0x3c6290
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x50(%rbp), %rax
movslq -0x30(%rbp), %rcx
cqto
idivq %rcx
movq -0x90(%rbp), %rax
addq %rdx, %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rdi
movq -0x68(%rbp), %rsi
movslq -0x34(%rbp), %rdx
callq 0x19610
movq -0x58(%rbp), %rdi
callq 0x3e40f0
movb $0x0, (%rax)
cmpq $0x0, -0x50(%rbp)
jne 0x3c6262
cmpl $0x0, -0x1c(%rbp)
jne 0x3c6262
movq -0x78(%rbp), %rax
addq $0x1c, %rax
movq %rax, -0xa0(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x3c6000
movq -0xa0(%rbp), %rdi
movl %eax, %esi
callq 0x3dd200
jmp 0x3c6264
movq -0x58(%rbp), %rdi
callq 0x3c62b0
movslq -0x30(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x3c6108
movl -0x44(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)