// File: /workspace/github_c_makefile_star2_O3/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3PagerClose
SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager){
  u8 *pTmp = (u8 *)pPager->pTmpSpace;

  assert( assert_pager_state(pPager) );
  disable_simulated_io_errors();
  sqlite3BeginBenignMalloc();
  pagerFreeMapHdrs(pPager);
  /* pPager->errCode = 0; */
  pPager->exclusiveMode = 0;
#ifndef SQLITE_OMIT_WAL
  sqlite3WalClose(pPager->pWal, pPager->ckptSyncFlags, pPager->pageSize, pTmp);
  pPager->pWal = 0;
#endif
  pager_reset(pPager);
  if( MEMDB ){
    pager_unlock(pPager);
  }else{
    /* If it is open, sync the journal file before calling UnlockAndRollback.
    ** If this is not done, then an unsynced portion of the open journal 
    ** file may be played back into the database. If a power failure occurs 
    ** while this is happening, the database could become corrupt.
    **
    ** If an error occurs while trying to sync the journal, shift the pager
    ** into the ERROR state. This causes UnlockAndRollback to unlock the
    ** database and close the journal file without attempting to roll it
    ** back or finalize it. The next database user will have to do hot-journal
    ** rollback before accessing the database file.
    */
    if( isOpen(pPager->jfd) ){
      pager_error(pPager, pagerSyncHotJournal(pPager));
    }
    pagerUnlockAndRollback(pPager);
  }
  sqlite3EndBenignMalloc();
  enable_simulated_io_errors();
  PAGERTRACE(("CLOSE %d\n", PAGERID(pPager)));
  IOTRACE(("CLOSE %p\n", pPager))
  sqlite3OsClose(pPager->jfd);
  sqlite3OsClose(pPager->fd);
  sqlite3PageFree(pTmp);
  sqlite3PcacheClose(pPager->pPCache);

#ifdef SQLITE_HAS_CODEC
  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
#endif

  assert( !pPager->aSavepoint && !pPager->pInJournal );
  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );

  sqlite3_free(pPager);
  return SQLITE_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x108(%rdi), %r14
movq 0x7bb82(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x1a3e5
callq *%rax
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x1a402
movq 0x18(%rdi), %r15
callq 0xa3c7
movq %r15, %rdi
testq %r15, %r15
jne 0x1a3f1
movb $0x0, 0x8(%rbx)
movq 0x118(%rbx), %rdi
movzbl 0xd(%rbx), %esi
movl 0xbc(%rbx), %edx
movq %r14, %rcx
callq 0x1ce6f
movq $0x0, 0x118(%rbx)
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1a440
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1a42e
movq 0x110(%rbx), %rdi
xorl %esi, %esi
callq 0x1cd4d
cmpb $0x0, 0x12(%rbx)
je 0x1a45e
movq %rbx, %rdi
callq 0x1cfa6
jmp 0x1a48b
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1a483
movq %rbx, %rdi
callq 0x1d0b4
cmpb $0xd, %al
je 0x1a47c
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x1a483
movl %eax, 0x2c(%rbx)
movb $0x6, 0x13(%rbx)
movq %rbx, %rdi
callq 0x1d0f7
movq 0x7bad6(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x1a499
callq *%rax
movq 0x50(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x1a4b2
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq 0x48(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x1a4cb
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq %r14, %rdi
callq 0x1cdc9
movq 0x110(%rbx), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x1a4e9
callq *0x7a017(%rip)          # 0x94500
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa3c7