// File: /workspace/github_c_makefile_star2_O3/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:
xorl %eax, %eax
testq %rsi, %rsi
je 0x28db57
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
cmpb $0x4, 0x9(%rdi)
je 0x28db49
movq 0x50(%rbx), %rdi
movq (%rdi), %r8
testq %r8, %r8
je 0x28db49
movq %rsi, %r15
movb $0x1, 0x17(%rbx)
movb (%rsi), %al
testb %al, %al
je 0x28da29
xorl %r13d, %r13d
xorl %ebp, %ebp
movsbl %al, %eax
addl %eax, %ebp
movb 0x1(%r15,%r13), %al
incq %r13
testb %al, %al
jne 0x28da13
movl %r13d, %r14d
jmp 0x28da31
xorl %r14d, %r14d
xorl %ebp, %ebp
xorl %r13d, %r13d
cmpb $0x0, 0xc(%rbx)
movq 0x60(%rbx), %r12
je 0x28da64
testq %r12, %r12
je 0x28da5d
decq %r12
movl 0xb8(%rbx), %ecx
movq %r12, %rax
cqto
idivq %rcx
movq %rax, %r12
incq %r12
imulq %rcx, %r12
jmp 0x28da60
xorl %r12d, %r12d
movq %r12, 0x60(%rbx)
movl 0x22e056(%rip), %eax    # 0x4bbac0
cltd
idivl 0xbc(%rbx)
incl %eax
bswapl %eax
movq %rsp, %rsi
movl %eax, (%rsi)
movl $0x4, %edx
movq %r12, %rcx
callq *0x18(%r8)
testl %eax, %eax
jne 0x28db49
movq 0x50(%rbx), %rdi
addq $0x4, %r12
movq (%rdi), %rax
movq %r15, %rsi
movl %r14d, %edx
movq %r12, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28db49
movq 0x50(%rbx), %rdi
addq %r13, %r12
movl %r14d, %eax
bswapl %eax
movq %rsp, %rsi
movl %eax, (%rsi)
movq (%rdi), %rax
movl $0x4, %edx
movq %r12, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28db49
movq 0x50(%rbx), %rdi
leaq 0x4(%r12), %rcx
bswapl %ebp
movq %rsp, %rsi
movl %ebp, (%rsi)
movq (%rdi), %rax
movl $0x4, %edx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28db49
movq 0x50(%rbx), %rdi
addq $0x8, %r12
movq (%rdi), %rax
leaq 0x143fde(%rip), %rsi    # 0x3d1adf
movl $0x8, %edx
movq %r12, %rcx
callq *0x18(%rax)
testl %eax, %eax
jne 0x28db49
movl %r14d, %eax
movq 0x50(%rbx), %rdi
movq 0x60(%rbx), %rcx
addq %rcx, %rax
addq $0x14, %rax
movq %rax, 0x60(%rbx)
movq (%rdi), %rax
movq %rsp, %rsi
callq *0x30(%rax)
testl %eax, %eax
jne 0x28db49
movq 0x60(%rbx), %rsi
xorl %eax, %eax
cmpq %rsi, (%rsp)
jle 0x28db49
movq 0x50(%rbx), %rdi
movq (%rdi), %rax
callq *0x20(%rax)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq