// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x3e34a0
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x34(%rax), %ecx
orl $0x8, %ecx
movw %cx, 0x34(%rax)
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %edx
callq 0x3dca80
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e836b
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e8435
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %edx
movq -0x30(%rbp), %rcx
addq $0x4, %rcx
callq 0x3c6930
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e83a2
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e8435
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x30(%rbp), %rsi
movq -0x18(%rbp), %rax
movslq 0xbc(%rax), %rax
addq %rax, %rsi
addq $0x4, %rsi
movl -0x20(%rbp), %edx
callq 0x3dca80
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e83d9
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e8435
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %eax
addl $0x8, %eax
movslq %eax, %rcx
movq -0x18(%rbp), %rax
addq 0x60(%rax), %rcx
movq %rcx, 0x60(%rax)
movq -0x18(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x18(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %esi
callq 0x3dd250
movl %eax, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %esi
callq 0x3dcac0
orl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nop