// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pager_open_journal
static int pager_open_journal(Pager *pPager){
  int rc = SQLITE_OK;                        /* Return code */
  sqlite3_vfs * const pVfs = pPager->pVfs;   /* Local cache of vfs pointer */

  assert( pPager->eState==PAGER_WRITER_LOCKED );
  assert( assert_pager_state(pPager) );
  assert( pPager->pInJournal==0 );

  /* If already in the error state, this function is a no-op.  But on
  ** the other hand, this routine is never called if we are already in
  ** an error state. */
  if( NEVER(pPager->errCode) ) return pPager->errCode;

  if( !pagerUseWal(pPager) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){
    pPager->pInJournal = sqlite3BitvecCreate(pPager->dbSize);
    if( pPager->pInJournal==0 ){
      return SQLITE_NOMEM_BKPT;
    }

    /* Open the journal file if it is not already open. */
    if( !isOpen(pPager->jfd) ){
      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
        sqlite3MemJournalOpen(pPager->jfd);
      }else{
        int flags = SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE;
        int nSpill;

        if( pPager->tempFile ){
          flags |= (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL);
          nSpill = sqlite3Config.nStmtSpill;
        }else{
          flags |= SQLITE_OPEN_MAIN_JOURNAL;
          nSpill = jrnlBufferSize(pPager);
        }

        /* Verify that the database still has the same name as it did when
        ** it was originally opened. */
        rc = databaseIsUnmoved(pPager);
        if( rc==SQLITE_OK ){
          rc = sqlite3JournalOpen (
              pVfs, pPager->zJournal, pPager->jfd, flags, nSpill
          );
        }
      }
      assert( rc!=SQLITE_OK || isOpen(pPager->jfd) );
    }


    /* Write the first journal header to the journal file and open
    ** the sub-journal if necessary.
    */
    if( rc==SQLITE_OK ){
      /* TODO: Check if all of these are really required. */
      pPager->nRec = 0;
      pPager->journalOff = 0;
      pPager->setSuper = 0;
      pPager->journalHdr = 0;
      rc = writeJournalHdr(pPager);
    }
  }

  if( rc!=SQLITE_OK ){
    sqlite3BitvecDestroy(pPager->pInJournal);
    pPager->pInJournal = 0;
  }else{
    assert( pPager->eState==PAGER_WRITER_LOCKED );
    pPager->eState = PAGER_WRITER_CACHEMOD;
  }

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x3e8177
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e82de
movq -0x10(%rbp), %rax
cmpq $0x0, 0x120(%rax)
jne 0x3e82af
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x2, %eax
je 0x3e82af
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x3dd500
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x3e81c8
movl $0x7, -0x4(%rbp)
jmp 0x3e82de
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
jne 0x3e8270
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x4, %eax
jne 0x3e81f6
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x3e8440
jmp 0x3e826e
movl $0x6, -0x24(%rbp)
movq -0x10(%rbp), %rax
cmpb $0x0, 0x10(%rax)
je 0x3e821d
movl -0x24(%rbp), %eax
orl $0x1008, %eax           # imm = 0x1008
movl %eax, -0x24(%rbp)
movl 0x257654(%rip), %eax    # 0x63f86c
movl %eax, -0x28(%rbp)
jmp 0x3e8234
movl -0x24(%rbp), %eax
orl $0x800, %eax            # imm = 0x800
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e8470
movl %eax, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e51a0
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jne 0x3e826c
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdx
movl -0x24(%rbp), %ecx
movl -0x28(%rbp), %r8d
callq 0x3dcb40
movl %eax, -0x14(%rbp)
jmp 0x3e826e
jmp 0x3e8270
cmpl $0x0, -0x14(%rbp)
jne 0x3e82ad
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x17(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x10(%rbp), %rdi
callq 0x3e0470
movl %eax, -0x14(%rbp)
jmp 0x3e82af
cmpl $0x0, -0x14(%rbp)
je 0x3e82d0
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x3e2290
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x3e82d8
movq -0x10(%rbp), %rax
movb $0x3, 0x14(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)