// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movq 0x110(%rdi), %r14
movq 0x23a7c1(%rip), %rax    # 0x4c9e48
testq %rax, %rax
je 0x28f68e
callq *%rax
movq 0xa8(%rbx), %rdi
testq %rdi, %rdi
je 0x28f6ab
movq 0x20(%rdi), %r12
callq 0x27c490
movq %r12, %rdi
testq %r12, %r12
jne 0x28f69a
movb $0x0, 0x8(%rbx)
testq %r15, %r15
je 0x28f6ce
testb $0x8, 0x31(%r15)
jne 0x28f6ce
movq %rbx, %rdi
callq 0x295600
xorl %r8d, %r8d
testl %eax, %eax
cmoveq %r14, %r8
jmp 0x28f6d1
xorl %r8d, %r8d
movq 0x120(%rbx), %rdi
movzbl 0xf(%rbx), %edx
movl 0xbc(%rbx), %ecx
movq %r15, %rsi
callq 0x29565c
movq $0x0, 0x120(%rbx)
movq %rbx, %rdi
callq 0x294c73
cmpb $0x0, 0x13(%rbx)
je 0x28f70d
movq %rbx, %rdi
callq 0x293695
jmp 0x28f764
movq 0x50(%rbx), %rax
cmpq $0x0, (%rax)
je 0x28f75c
movq %rbx, %rdi
callq 0x2957a1
cmpb $0xd, %al
je 0x28f72b
movzbl %al, %ecx
cmpl $0xa, %ecx
jne 0x28f75c
movl %eax, 0x2c(%rbx)
movb $0x6, 0x14(%rbx)
testl %eax, %eax
je 0x28f73f
leaq 0x3478(%rip), %rax      # 0x292bb5
jmp 0x28f755
cmpb $0x0, 0x1a(%rbx)
je 0x28f74e
leaq 0x3474(%rip), %rax      # 0x292bc0
jmp 0x28f755
leaq 0x36b7(%rip), %rax      # 0x292e0c
movq %rax, 0x108(%rbx)
movq %rbx, %rdi
callq 0x293239
movq 0x23a6e5(%rip), %rax    # 0x4c9e50
testq %rax, %rax
je 0x28f772
callq *%rax
movq 0x50(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x28f78b
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq 0x48(%rbx), %r15
movq (%r15), %rax
testq %rax, %rax
je 0x28f7a4
movq %r15, %rdi
callq *0x8(%rax)
movq $0x0, (%r15)
movq %r14, %rdi
callq 0x292b46
movq 0x118(%rbx), %rax
movq 0x40(%rax), %rdi
callq *0x236fa3(%rip)         # 0x4c6760
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x27c490