// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3PagerClose
SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager, sqlite3 *db){
  u8 *pTmp = (u8*)pPager->pTmpSpace;
  assert( db || pagerUseWal(pPager)==0 );
  assert( assert_pager_state(pPager) );
  disable_simulated_io_errors();
  sqlite3BeginBenignMalloc();
  pagerFreeMapHdrs(pPager);
  /* pPager->errCode = 0; */
  pPager->exclusiveMode = 0;
#ifndef SQLITE_OMIT_WAL
  {
    u8 *a = 0;
    assert( db || pPager->pWal==0 );
    if( db && 0==(db->flags & SQLITE_NoCkptOnClose)
     && SQLITE_OK==databaseIsUnmoved(pPager)
    ){
      a = pTmp;
    }
    sqlite3WalClose(pPager->pWal, db, pPager->walSyncFlags, pPager->pageSize,a);
    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);
  assert( !pPager->aSavepoint && !pPager->pInJournal );
  assert( !isOpen(pPager->jfd) && !isOpen(pPager->sjfd) );

  sqlite3_free(pPager);
  return SQLITE_OK;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rsi, %r15
movq %rdi, %rbx
movq 0x110(%rdi), %r14
movq 0x2392eb(%rip), %rax    # 0x4bee48
testq %rax, %rax
je 0x285b64
callq *%rax
movq 0xa8(%rbx), %r12
testq %r12, %r12
je 0x285ba8
movq 0x20(%r12), %r13
cmpl $0x0, 0x235ae4(%rip)    # 0x4bb660
je 0x285b97
movq %r12, %rdi
callq *0x235b11(%rip)         # 0x4bb698
cltq
subq %rax, 0x238f68(%rip)    # 0x4beaf8
decq 0x238fa9(%rip)          # 0x4beb40
movq %r12, %rdi
callq *0x235ae8(%rip)         # 0x4bb688
movq %r13, %r12
testq %r13, %r13
jne 0x285b70
movb $0x0, 0x8(%rbx)
testq %r15, %r15
je 0x285bcb
testb $0x8, 0x31(%r15)
jne 0x285bcb
movq %rbx, %rdi
callq 0x28b7ad
xorl %r8d, %r8d
testl %eax, %eax
cmoveq %r14, %r8
jmp 0x285bce
xorl %r8d, %r8d
movq 0x120(%rbx), %rdi
movzbl 0xf(%rbx), %edx
movl 0xbc(%rbx), %ecx
movq %r15, %rsi
callq 0x28b802
movq $0x0, 0x120(%rbx)
movq %rbx, %rdi
callq 0x28ae2e
cmpb $0x0, 0x13(%rbx)
je 0x285c0a
movq %rbx, %rdi
callq 0x289861
jmp 0x285c61
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x285c59
movq %rbx, %rdi
callq 0x28b96c
cmpb $0xd, %al
je 0x285c28
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x285c59
movl %eax, 0x2c(%rbx)
movb $0x6, 0x14(%rbx)
testl %eax, %eax
je 0x285c3c
leaq 0x3175(%rip), %rax      # 0x288daf
jmp 0x285c52
cmpb $0x0, 0x1a(%rbx)
je 0x285c4b
leaq 0x3171(%rip), %rax      # 0x288dba
jmp 0x285c52
leaq 0x3377(%rip), %rax      # 0x288fc9
movq %rax, 0x108(%rbx)
movq %rbx, %rdi
callq 0x2893d8
movq 0x2391e8(%rip), %rax    # 0x4bee50
testq %rax, %rax
je 0x285c6f
callq *%rax
movq 0x50(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x285c88
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq 0x48(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x285ca1
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq %r14, %rdi
callq 0x288d1d
movq 0x118(%rbx), %rax
movq 0x40(%rax), %rdi
callq *0x235aa6(%rip)         # 0x4bb760
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x272c00