// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: readDbPage
static int readDbPage(PgHdr *pPg){
  Pager *pPager = pPg->pPager; /* Pager object associated with page pPg */
  int rc = SQLITE_OK;          /* Return code */

#ifndef SQLITE_OMIT_WAL
  u32 iFrame = 0;              /* Frame of WAL containing pgno */

  assert( pPager->eState>=PAGER_READER && !MEMDB );
  assert( isOpen(pPager->fd) );

  if( pagerUseWal(pPager) ){
    rc = sqlite3WalFindFrame(pPager->pWal, pPg->pgno, &iFrame);
    if( rc ) return rc;
  }
  if( iFrame ){
    rc = sqlite3WalReadFrame(pPager->pWal, iFrame,pPager->pageSize,pPg->pData);
  }else
#endif
  {
    i64 iOffset = (pPg->pgno-1)*(i64)pPager->pageSize;
    rc = sqlite3OsRead(pPager->fd, pPg->pData, pPager->pageSize, iOffset);
    if( rc==SQLITE_IOERR_SHORT_READ ){
      rc = SQLITE_OK;
    }
  }

  if( pPg->pgno==1 ){
    if( rc ){
      /* If the read is unsuccessful, set the dbFileVers[] to something
      ** that will never be a valid file version.  dbFileVers[] is a copy
      ** of bytes 24..39 of the database.  Bytes 28..31 should always be
      ** zero or the size of the database in page. Bytes 32..35 and 35..39
      ** should be page numbers which are never 0xffffffff.  So filling
      ** pPager->dbFileVers[] with all 0xff bytes should suffice.
      **
      ** For an encrypted database, the situation is more complex:  bytes
      ** 24..39 of the database are white noise.  But the probability of
      ** white noise equaling 16 bytes of 0xff is vanishingly small so
      ** we should still be ok.
      */
      memset(pPager->dbFileVers, 0xff, sizeof(pPager->dbFileVers));
    }else{
      u8 *dbFileVers = &((u8*)pPg->pData)[24];
      memcpy(&pPager->dbFileVers, dbFileVers, sizeof(pPager->dbFileVers));
    }
  }
  PAGER_INCR(sqlite3_pager_readdb_count);
  PAGER_INCR(pPager->nRead);
  IOTRACE(("PGIN %p %d\n", pPager, pPg->pgno));
  PAGERTRACE(("FETCH %d page %d hash(%08x)\n",
               PAGERID(pPager), pPg->pgno, pager_pagehash(pPg)));

  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x3e14a5
movq -0x18(%rbp), %rax
movq 0x120(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %esi
leaq -0x20(%rbp), %rdx
callq 0x3ddfb0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3e14a3
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e158d
jmp 0x3e14a5
cmpl $0x0, -0x20(%rbp)
je 0x3e14d5
movq -0x18(%rbp), %rax
movq 0x120(%rax), %rdi
movl -0x20(%rbp), %esi
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %edx
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rcx
callq 0x3e1640
movl %eax, -0x1c(%rbp)
jmp 0x3e152c
movq -0x10(%rbp), %rax
movl 0x30(%rax), %eax
subl $0x1, %eax
movl %eax, %eax
movq -0x18(%rbp), %rcx
movslq 0xbc(%rcx), %rcx
imulq %rcx, %rax
movq %rax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq 0x48(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x18(%rbp), %rax
movl 0xbc(%rax), %edx
movq -0x28(%rbp), %rcx
callq 0x3dfc00
movl %eax, -0x1c(%rbp)
cmpl $0x20a, -0x1c(%rbp)     # imm = 0x20A
jne 0x3e152a
movl $0x0, -0x1c(%rbp)
jmp 0x3e152c
movq -0x10(%rbp), %rax
cmpl $0x1, 0x30(%rax)
jne 0x3e1587
cmpl $0x0, -0x1c(%rbp)
je 0x3e1558
movq -0x18(%rbp), %rdi
addq $0x88, %rdi
movl $0xff, %esi
movl $0x10, %edx
callq 0x19360
jmp 0x3e1585
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x18, %rax
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq (%rcx), %rdx
movq %rdx, 0x88(%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x90(%rax)
jmp 0x3e1587
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)