// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: writeSuperJournal
static int writeSuperJournal(Pager *pPager, const char *zSuper){
  int rc;                          /* Return code */
  int nSuper;                      /* Length of string zSuper */
  i64 iHdrOff;                     /* Offset of header in journal file */
  i64 jrnlSize;                    /* Size of journal file on disk */
  u32 cksum = 0;                   /* Checksum of string zSuper */

  assert( pPager->setSuper==0 );
  assert( !pagerUseWal(pPager) );

  if( !zSuper
   || pPager->journalMode==PAGER_JOURNALMODE_MEMORY
   || !isOpen(pPager->jfd)
  ){
    return SQLITE_OK;
  }
  pPager->setSuper = 1;
  assert( pPager->journalHdr <= pPager->journalOff );

  /* Calculate the length in bytes and the checksum of zSuper */
  for(nSuper=0; zSuper[nSuper]; nSuper++){
    cksum += zSuper[nSuper];
  }

  /* If in full-sync mode, advance to the next disk sector before writing
  ** the super-journal name. This is in case the previous page written to
  ** the journal has already been synced.
  */
  if( pPager->fullSync ){
    pPager->journalOff = journalHdrOffset(pPager);
  }
  iHdrOff = pPager->journalOff;

  /* Write the super-journal data to the end of the journal file. If
  ** an error occurs, return the error code to the caller.
  */
  if( (0 != (rc = write32bits(pPager->jfd, iHdrOff, PAGER_MJ_PGNO(pPager))))
   || (0 != (rc = sqlite3OsWrite(pPager->jfd, zSuper, nSuper, iHdrOff+4)))
   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper, nSuper)))
   || (0 != (rc = write32bits(pPager->jfd, iHdrOff+4+nSuper+4, cksum)))
   || (0 != (rc = sqlite3OsWrite(pPager->jfd, aJournalMagic, 8,
                                 iHdrOff+4+nSuper+8)))
  ){
    return rc;
  }
  pPager->journalOff += (nSuper+20);

  /* If the pager is in peristent-journal mode, then the physical
  ** journal-file may extend past the end of the super-journal name
  ** and 8 bytes of magic data just written to the file. This is
  ** dangerous because the code to rollback a hot-journal file
  ** will not be able to find the super-journal name to determine
  ** whether or not the journal is hot.
  **
  ** Easiest thing to do in this scenario is to truncate the journal
  ** file to the required size.
  */
  if( SQLITE_OK==(rc = sqlite3OsFileSize(pPager->jfd, &jrnlSize))
   && jrnlSize>pPager->journalOff
  ){
    rc = sqlite3OsTruncate(pPager->jfd, pPager->journalOff);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x3e8539
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x4, %eax
je 0x3e8539
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
jne 0x3e8545
movl $0x0, -0x4(%rbp)
jmp 0x3e86fe
movq -0x10(%rbp), %rax
movb $0x1, 0x17(%rax)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
cmpb $0x0, (%rax,%rcx)
je 0x3e857f
movq -0x18(%rbp), %rax
movslq -0x20(%rbp), %rcx
movsbl (%rax,%rcx), %eax
addl -0x34(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x3e8554
movq -0x10(%rbp), %rax
cmpb $0x0, 0xc(%rax)
je 0x3e859d
movq -0x10(%rbp), %rdi
callq 0x3e0410
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rsi
movl 0x2576f5(%rip), %eax    # 0x63fcb0
movq -0x10(%rbp), %rcx
cltd
idivl 0xbc(%rcx)
movl %eax, %edx
addl $0x1, %edx
callq 0x3dca80
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3e8699
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x18(%rbp), %rsi
movl -0x20(%rbp), %edx
movq -0x28(%rbp), %rcx
addq $0x4, %rcx
callq 0x3c6930
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3e8699
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x4, %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
movl -0x20(%rbp), %edx
callq 0x3dca80
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3e8699
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x4, %rsi
movslq -0x20(%rbp), %rax
addq %rax, %rsi
addq $0x4, %rsi
movl -0x34(%rbp), %edx
callq 0x3dca80
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3e8699
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rcx
addq $0x4, %rcx
movslq -0x20(%rbp), %rax
addq %rax, %rcx
addq $0x8, %rcx
leaq 0x1bec38(%rip), %rsi    # 0x5a72bc
movl $0x8, %edx
callq 0x3c6930
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
je 0x3e86a1
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e86fe
movl -0x20(%rbp), %eax
addl $0x14, %eax
movslq %eax, %rcx
movq -0x10(%rbp), %rax
addq 0x60(%rax), %rcx
movq %rcx, 0x60(%rax)
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
leaq -0x30(%rbp), %rsi
callq 0x3dfbd0
movl %eax, %ecx
movl %ecx, -0x1c(%rbp)
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3e86f8
movq -0x30(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x60(%rcx), %rax
jle 0x3e86f8
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rsi
callq 0x3e01f0
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)