// File: /workspace/github_c_makefile_star2_O1/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 0x7b9ca(%rip), %rax     # 0x95f60
testq %rax, %rax
je 0x1a59d
callq *%rax
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x1a5ba
movq 0x18(%rdi), %r15
callq 0xa2e8
movq %r15, %rdi
testq %r15, %r15
jne 0x1a5a9
movb $0x0, 0x8(%rbx)
movq 0x118(%rbx), %rdi
movzbl 0xd(%rbx), %esi
movl 0xbc(%rbx), %edx
movq %r14, %rcx
callq 0x1d032
movq $0x0, 0x118(%rbx)
movq 0x70(%rbx), %rax
testq %rax, %rax
je 0x1a5f8
movl $0x1, 0x18(%rax)
movq 0x40(%rax), %rax
jmp 0x1a5e6
movq 0x110(%rbx), %rdi
xorl %esi, %esi
callq 0x1cf10
cmpb $0x0, 0x12(%rbx)
je 0x1a616
movq %rbx, %rdi
callq 0x1d169
jmp 0x1a643
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x1a63b
movq %rbx, %rdi
callq 0x1d27b
cmpb $0xd, %al
je 0x1a634
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x1a63b
movl %eax, 0x2c(%rbx)
movb $0x6, 0x13(%rbx)
movq %rbx, %rdi
callq 0x1d2c0
movq 0x7b91e(%rip), %rax     # 0x95f68
testq %rax, %rax
je 0x1a651
callq *%rax
movq 0x50(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x1a66a
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq 0x48(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x1a683
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq %r14, %rdi
callq 0x1cf8c
movq 0x110(%rbx), %rax
movq 0x40(%rax), %rdi
testq %rdi, %rdi
je 0x1a6a1
callq *0x79e5f(%rip)          # 0x94500
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xa2e8