// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pager_delsuper
static int pager_delsuper(Pager *pPager, const char *zSuper){
  sqlite3_vfs *pVfs = pPager->pVfs;
  int rc;                   /* Return code */
  sqlite3_file *pSuper;     /* Malloc'd super-journal file descriptor */
  sqlite3_file *pJournal;   /* Malloc'd child-journal file descriptor */
  char *zSuperJournal = 0;  /* Contents of super-journal file */
  i64 nSuperJournal;        /* Size of super-journal file */
  char *zJournal;           /* Pointer to one journal within MJ file */
  char *zSuperPtr;          /* Space to hold super-journal filename */
  int nSuperPtr;            /* Amount of space allocated to zSuperPtr[] */

  /* Allocate space for both the pJournal and pSuper file descriptors.
  ** If successful, open the super-journal file for reading.
  */
  pSuper = (sqlite3_file *)sqlite3MallocZero(pVfs->szOsFile * 2);
  if( !pSuper ){
    rc = SQLITE_NOMEM_BKPT;
    pJournal = 0;
  }else{
    const int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_SUPER_JOURNAL);
    rc = sqlite3OsOpen(pVfs, zSuper, pSuper, flags, 0);
    pJournal = (sqlite3_file *)(((u8 *)pSuper) + pVfs->szOsFile);
  }
  if( rc!=SQLITE_OK ) goto delsuper_out;

  /* Load the entire super-journal file into space obtained from
  ** sqlite3_malloc() and pointed to by zSuperJournal.   Also obtain
  ** sufficient space (in zSuperPtr) to hold the names of super-journal
  ** files extracted from regular rollback-journals.
  */
  rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
  if( rc!=SQLITE_OK ) goto delsuper_out;
  nSuperPtr = pVfs->mxPathname+1;
  zSuperJournal = sqlite3Malloc(nSuperJournal + nSuperPtr + 2);
  if( !zSuperJournal ){
    rc = SQLITE_NOMEM_BKPT;
    goto delsuper_out;
  }
  zSuperPtr = &zSuperJournal[nSuperJournal+2];
  rc = sqlite3OsRead(pSuper, zSuperJournal, (int)nSuperJournal, 0);
  if( rc!=SQLITE_OK ) goto delsuper_out;
  zSuperJournal[nSuperJournal] = 0;
  zSuperJournal[nSuperJournal+1] = 0;

  zJournal = zSuperJournal;
  while( (zJournal-zSuperJournal)<nSuperJournal ){
    int exists;
    rc = sqlite3OsAccess(pVfs, zJournal, SQLITE_ACCESS_EXISTS, &exists);
    if( rc!=SQLITE_OK ){
      goto delsuper_out;
    }
    if( exists ){
      /* One of the journals pointed to by the super-journal exists.
      ** Open it and check if it points at the super-journal. If
      ** so, return without deleting the super-journal file.
      ** NB:  zJournal is really a MAIN_JOURNAL.  But call it a
      ** SUPER_JOURNAL here so that the VFS will not send the zJournal
      ** name into sqlite3_database_file_object().
      */
      int c;
      int flags = (SQLITE_OPEN_READONLY|SQLITE_OPEN_SUPER_JOURNAL);
      rc = sqlite3OsOpen(pVfs, zJournal, pJournal, flags, 0);
      if( rc!=SQLITE_OK ){
        goto delsuper_out;
      }

      rc = readSuperJournal(pJournal, zSuperPtr, nSuperPtr);
      sqlite3OsClose(pJournal);
      if( rc!=SQLITE_OK ){
        goto delsuper_out;
      }

      c = zSuperPtr[0]!=0 && strcmp(zSuperPtr, zSuper)==0;
      if( c ){
        /* We have a match. Do not delete the super-journal file. */
        goto delsuper_out;
      }
    }
    zJournal += (sqlite3Strlen30(zJournal)+1);
  }

  sqlite3OsClose(pSuper);
  rc = sqlite3OsDelete(pVfs, zSuper, 0);

delsuper_out:
  sqlite3_free(zSuperJournal);
  if( pSuper ){
    sqlite3OsClose(pSuper);
    assert( !isOpen(pJournal) );
    sqlite3_free(pSuper);
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
movslq %eax, %rdi
callq 0x3c51d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x3e38f0
movl $0x7, -0x1c(%rbp)
movq $0x0, -0x30(%rbp)
jmp 0x3e3928
movl $0x4001, -0x58(%rbp)    # imm = 0x4001
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x28(%rbp), %rdx
movl $0x4001, %ecx           # imm = 0x4001
xorl %eax, %eax
movl %eax, %r8d
callq 0x3dbb90
movl %eax, -0x1c(%rbp)
movq -0x28(%rbp), %rax
movq -0x18(%rbp), %rcx
movslq 0x4(%rcx), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e3933
jmp 0x3e3ae9
movq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x3dfbd0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e394e
jmp 0x3e3ae9
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
movq -0x40(%rbp), %rdi
movslq -0x54(%rbp), %rax
addq %rax, %rdi
addq $0x2, %rdi
callq 0x3c0760
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x3e3986
movl $0x7, -0x1c(%rbp)
jmp 0x3e3ae9
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
addq $0x2, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rax
movl %eax, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3dfc00
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e39be
jmp 0x3e3ae9
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x38(%rbp), %rax
movq -0x40(%rbp), %rcx
movb $0x0, 0x1(%rax,%rcx)
movq -0x38(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
subq %rcx, %rax
cmpq -0x40(%rbp), %rax
jge 0x3e3ace
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
xorl %edx, %edx
leaq -0x5c(%rbp), %rcx
callq 0x3e36f0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e3a15
jmp 0x3e3ae9
cmpl $0x0, -0x5c(%rbp)
je 0x3e3aad
movl $0x4001, -0x64(%rbp)    # imm = 0x4001
movq -0x18(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x30(%rbp), %rdx
movl -0x64(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x3dbb90
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e3a4d
jmp 0x3e3ae9
movq -0x30(%rbp), %rdi
movq -0x50(%rbp), %rsi
movl -0x54(%rbp), %edx
callq 0x3e3560
movl %eax, -0x1c(%rbp)
movq -0x30(%rbp), %rdi
callq 0x3dbe40
cmpl $0x0, -0x1c(%rbp)
je 0x3e3a71
jmp 0x3e3ae9
movq -0x50(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x65(%rbp)
je 0x3e3a98
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x19980
cmpl $0x0, %eax
sete %al
movb %al, -0x65(%rbp)
movb -0x65(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x60(%rbp)
cmpl $0x0, -0x60(%rbp)
je 0x3e3aab
jmp 0x3e3ae9
jmp 0x3e3aad
movq -0x48(%rbp), %rdi
callq 0x3c3400
movl %eax, %ecx
addl $0x1, %ecx
movq -0x48(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x48(%rbp)
jmp 0x3e39df
movq -0x28(%rbp), %rdi
callq 0x3dbe40
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
xorl %edx, %edx
callq 0x3e3c10
movl %eax, -0x1c(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3c0800
cmpq $0x0, -0x28(%rbp)
je 0x3e3b0b
movq -0x28(%rbp), %rdi
callq 0x3dbe40
movq -0x28(%rbp), %rdi
callq 0x3c0800
movl -0x1c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)