// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: pager_unlock
static void pager_unlock(Pager *pPager){

  assert( pPager->eState==PAGER_READER 
       || pPager->eState==PAGER_OPEN 
       || pPager->eState==PAGER_ERROR 
  );

  sqlite3BitvecDestroy(pPager->pInJournal);
  pPager->pInJournal = 0;
  releaseAllSavepoints(pPager);

  if( pagerUseWal(pPager) ){
    assert( !isOpen(pPager->jfd) );
    sqlite3WalEndReadTransaction(pPager->pWal);
    pPager->eState = PAGER_OPEN;
  }else if( !pPager->exclusiveMode ){
    int rc;                       /* Error code returned by pagerUnlockDb() */
    int iDc = isOpen(pPager->fd)?sqlite3OsDeviceCharacteristics(pPager->fd):0;

    /* If the operating system support deletion of open files, then
    ** close the journal file when dropping the database lock.  Otherwise
    ** another connection with journal_mode=delete might delete the file
    ** out from under us.
    */
    assert( (PAGER_JOURNALMODE_MEMORY   & 5)!=1 );
    assert( (PAGER_JOURNALMODE_OFF      & 5)!=1 );
    assert( (PAGER_JOURNALMODE_WAL      & 5)!=1 );
    assert( (PAGER_JOURNALMODE_DELETE   & 5)!=1 );
    assert( (PAGER_JOURNALMODE_TRUNCATE & 5)==1 );
    assert( (PAGER_JOURNALMODE_PERSIST  & 5)==1 );
    if( 0==(iDc & SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN)
     || 1!=(pPager->journalMode & 5)
    ){
      sqlite3OsClose(pPager->jfd);
    }

    /* If the pager is in the ERROR state and the call to unlock the database
    ** file fails, set the current lock to UNKNOWN_LOCK. See the comment
    ** above the #define for UNKNOWN_LOCK for an explanation of why this
    ** is necessary.
    */
    rc = pagerUnlockDb(pPager, NO_LOCK);
    if( rc!=SQLITE_OK && pPager->eState==PAGER_ERROR ){
      pPager->eLock = UNKNOWN_LOCK;
    }

    /* The pager state may be changed from PAGER_ERROR to PAGER_OPEN here
    ** without clearing the error code. This is intentional - the error
    ** code is cleared and the cache reset in the block below.
    */
    assert( pPager->errCode || pPager->eState!=PAGER_ERROR );
    pPager->changeCountDone = 0;
    pPager->eState = PAGER_OPEN;
  }

  /* If Pager.errCode is set, the contents of the pager cache cannot be
  ** trusted. Now that there are no outstanding references to the pager,
  ** it can safely move back to PAGER_OPEN state. This happens in both
  ** normal and exclusive-locking mode.
  */
  if( pPager->errCode ){
    assert( !MEMDB );
    pager_reset(pPager);
    pPager->changeCountDone = pPager->tempFile;
    pPager->eState = PAGER_OPEN;
    pPager->errCode = SQLITE_OK;
    if( USEFETCH(pPager) ) sqlite3OsUnfetch(pPager->fd, 0, 0);
  }

  pPager->journalOff = 0;
  pPager->journalHdr = 0;
  pPager->setMaster = 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movq 0x40(%rdi), %rdi
callq 0x1df1e
movq $0x0, 0x40(%rbx)
movq %rbx, %rdi
callq 0x1df58
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x1d1a3
callq 0x1dfed
movb $0x0, 0x13(%rbx)
jmp 0x1d1a9
cmpb $0x0, 0x8(%rbx)
je 0x1d20e
cmpl $0x0, 0x2c(%rbx)
je 0x1d1fe
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1d1c5
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1d1b3
movq 0x110(%rbx), %rdi
xorl %esi, %esi
callq 0x1cf10
movb 0x10(%rbx), %al
movb %al, 0x15(%rbx)
movb $0x0, 0x13(%rbx)
movl $0x0, 0x2c(%rbx)
cmpb $0x0, 0x94(%rbx)
je 0x1d1fe
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
xorl %esi, %esi
xorl %edx, %edx
callq *0x90(%rax)
movb $0x0, 0x16(%rbx)
xorps %xmm0, %xmm0
movups %xmm0, 0x60(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1d22c
callq *0x60(%rax)
btl $0xb, %eax
jae 0x1d22c
movb 0x9(%rbx), %al
andb $0x5, %al
cmpb $0x1, %al
je 0x1d245
movq 0x50(%rbx), %r14
movq (%r14), %rax
testq %rax, %rax
je 0x1d245
movq %r14, %rdi
callq *0x8(%rax)
movq $0x0, (%r14)
movq 0x48(%rbx), %rdi
movq (%rdi), %rax
testq %rax, %rax
je 0x1d262
xorl %esi, %esi
callq *0x40(%rax)
cmpb $0x5, 0x14(%rbx)
je 0x1d264
movb $0x0, 0x14(%rbx)
jmp 0x1d264
xorl %eax, %eax
testl %eax, %eax
je 0x1d272
cmpb $0x6, 0x13(%rbx)
jne 0x1d272
movb $0x5, 0x14(%rbx)
movb $0x0, 0x15(%rbx)
jmp 0x1d19d