// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pagerAddPageToRollbackJournal
static SQLITE_NOINLINE int pagerAddPageToRollbackJournal(PgHdr *pPg){
  Pager *pPager = pPg->pPager;
  int rc;
  u32 cksum;
  char *pData2;
  i64 iOff = pPager->journalOff;

  /* We should never write to the journal file the page that
  ** contains the database locks.  The following assert verifies
  ** that we do not. */
  assert( pPg->pgno!=PAGER_MJ_PGNO(pPager) );

  assert( pPager->journalHdr<=pPager->journalOff );
  pData2 = pPg->pData;
  cksum = pager_cksum(pPager, (u8*)pData2);

  /* Even if an IO or diskfull error occurs while journalling the
  ** page in the block above, set the need-sync flag for the page.
  ** Otherwise, when the transaction is rolled back, the logic in
  ** playback_one_page() will think that the page needs to be restored
  ** in the database file. And if an IO error occurs while doing so,
  ** then corruption may follow.
  */
  pPg->flags |= PGHDR_NEED_SYNC;

  rc = write32bits(pPager->jfd, iOff, pPg->pgno);
  if( rc!=SQLITE_OK ) return rc;
  rc = sqlite3OsWrite(pPager->jfd, pData2, pPager->pageSize, iOff+4);
  if( rc!=SQLITE_OK ) return rc;
  rc = write32bits(pPager->jfd, iOff+pPager->pageSize+4, cksum);
  if( rc!=SQLITE_OK ) return rc;

  IOTRACE(("JOUT %p %d %lld %d\n", pPager, pPg->pgno,
           pPager->journalOff, pPager->pageSize));
  PAGER_INCR(sqlite3_pager_writej_count);
  PAGERTRACE(("JOURNAL %d page %d needSync=%d hash(%08x)\n",
       PAGERID(pPager), pPg->pgno,
       ((pPg->flags&PGHDR_NEED_SYNC)?1:0), pager_pagehash(pPg)));

  pPager->journalOff += 8 + pPager->pageSize;
  pPager->nRec++;
  assert( pPager->pInJournal!=0 );
  rc = sqlite3BitvecSet(pPager->pInJournal, pPg->pgno);
  testcase( rc==SQLITE_NOMEM );
  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
  rc |= addToSavepointBitvecs(pPager, pPg->pgno);
  assert( rc==SQLITE_OK || rc==SQLITE_NOMEM );
  return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %r14
movq 0x8(%rdi), %r12
movq 0x28(%rdi), %rbx
movq 0x60(%rbx), %r15
movl 0x34(%rbx), %ebp
movslq 0xbc(%rbx), %rax
cmpq $0xc9, %rax
jl 0x28d8b4
addq $0xc8, %rax
movzbl -0x190(%r12,%rax), %ecx
addl %ecx, %ebp
addq $-0xc8, %rax
cmpq $0x190, %rax            # imm = 0x190
ja 0x28d89b
orb $0x8, 0x34(%r14)
movq 0x50(%rbx), %rdi
movl 0x30(%r14), %eax
bswapl %eax
leaq 0x8(%rsp), %rsi
movl %eax, (%rsi)
movq (%rdi), %rax
movl $0x4, %edx
movq %r15, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28d959
movq 0x50(%rbx), %rdi
movl 0xbc(%rbx), %edx
addq $0x4, %r15
movq (%rdi), %rax
movq %r12, %rsi
movq %r15, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28d959
movq 0x50(%rbx), %rdi
movslq 0xbc(%rbx), %rax
addq %rax, %r15
bswapl %ebp
leaq 0xc(%rsp), %rsi
movl %ebp, (%rsi)
movq (%rdi), %rax
movl $0x4, %edx
movq %r15, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28d959
movslq 0xbc(%rbx), %rax
movq 0x40(%rbx), %rdi
movq 0x60(%rbx), %rcx
addq %rcx, %rax
addq $0x8, %rax
movq %rax, 0x60(%rbx)
incl 0x30(%rbx)
movl 0x30(%r14), %esi
callq 0x286fa5
movl %eax, %ebp
movl 0x30(%r14), %esi
movq %rbx, %rdi
callq 0x286bec
orl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq