// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/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;
    }
  
    /* Open the journal file if it is not already open. */
    if( !isOpen(pPager->jfd) ){
      if( pPager->journalMode==PAGER_JOURNALMODE_MEMORY ){
        sqlite3MemJournalOpen(pPager->jfd);
      }else{
        const int flags =                   /* VFS flags to open journal file */
          SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|
          (pPager->tempFile ? 
            (SQLITE_OPEN_DELETEONCLOSE|SQLITE_OPEN_TEMP_JOURNAL):
            (SQLITE_OPEN_MAIN_JOURNAL)
          );
  #ifdef SQLITE_ENABLE_ATOMIC_WRITE
        rc = sqlite3JournalOpen(
            pVfs, pPager->zJournal, pPager->jfd, flags, jrnlBufferSize(pPager)
        );
  #else
        rc = sqlite3OsOpen(pVfs, pPager->zJournal, pPager->jfd, flags, 0);
  #endif
      }
      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->setMaster = 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 0x2b087
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x2b1b7
movq -0x10(%rbp), %rdi
callq 0x211a0
cmpl $0x0, %eax
jne 0x2b188
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x2, %eax
je 0x2b188
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %edi
callq 0x22360
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x2b0d8
movl $0x7, -0x4(%rbp)
jmp 0x2b1b7
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, (%rax)
jne 0x2b149
movq -0x10(%rbp), %rax
movzbl 0x9(%rax), %eax
cmpl $0x4, %eax
jne 0x2b102
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdi
callq 0x21c10
jmp 0x2b147
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %edx
movl $0x800, %eax            # imm = 0x800
movl $0x1008, %ecx           # imm = 0x1008
cmpl $0x0, %edx
cmovnel %ecx, %eax
orl $0x6, %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0xd8(%rax), %rsi
movq -0x10(%rbp), %rax
movq 0x50(%rax), %rdx
movl -0x24(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x20df0
movl %eax, -0x14(%rbp)
jmp 0x2b149
cmpl $0x0, -0x14(%rbp)
jne 0x2b186
movq -0x10(%rbp), %rax
movl $0x0, 0x30(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x60(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x16(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0x68(%rax)
movq -0x10(%rbp), %rdi
callq 0x24510
movl %eax, -0x14(%rbp)
jmp 0x2b188
cmpl $0x0, -0x14(%rbp)
je 0x2b1a9
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x26630
movq -0x10(%rbp), %rax
movq $0x0, 0x40(%rax)
jmp 0x2b1b1
movq -0x10(%rbp), %rax
movb $0x3, 0x13(%rax)
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq