// File: /workspace/github_c_makefile_star2_O2/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 0x70d60(%rip), %rax     # 0x88f60
testq %rax, %rax
je 0x18207
callq *%rax
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x18221
movq 0x18(%rdi), %r15
callq 0x9c7b
movq %r15, %rdi
jmp 0x1820e
movb $0x0, 0x8(%rbx)
movq 0x118(%rbx), %rdi
movzbl 0xd(%rbx), %esi
movl 0xbc(%rbx), %edx
movq %r14, %rcx
callq 0x1a8d5
andq $0x0, 0x118(%rbx)
movq %rbx, %rdi
callq 0x1a6c5
cmpb $0x0, 0x12(%rbx)
je 0x1825e
movq %rbx, %rdi
callq 0x1a9ff
jmp 0x1828b
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x18283
movq %rbx, %rdi
callq 0x1aad7
cmpb $0xd, %al
je 0x1827c
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x18283
movl %eax, 0x2c(%rbx)
movb $0x6, 0x13(%rbx)
movq %rbx, %rdi
callq 0x1ab18
movq 0x70cd6(%rip), %rax     # 0x88f68
testq %rax, %rax
je 0x18299
callq *%rax
movq 0x50(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x182af
movq %r15, %rdi
callq *0x8(%rax)
andq $0x0, (%r15)
movq 0x48(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x182c5
movq %r15, %rdi
callq *0x8(%rax)
andq $0x0, (%r15)
movq %r14, %rdi
callq 0x1a82f
movq 0x110(%rbx), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x182e3
callq *0x6f21d(%rip)          # 0x87500
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x9c7b