// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: getPageMMap
static int getPageMMap(
  Pager *pPager,      /* The pager open on the database file */
  Pgno pgno,          /* Page number to fetch */
  DbPage **ppPage,    /* Write a pointer to the page here */
  int flags           /* PAGER_GET_XXX flags */
){
  int rc = SQLITE_OK;
  PgHdr *pPg = 0;
  u32 iFrame = 0;                 /* Frame to read from WAL file */

  /* It is acceptable to use a read-only (mmap) page for any page except
  ** page 1 if there is no write-transaction open or the ACQUIRE_READONLY
  ** flag was specified by the caller. And so long as the db is not a
  ** temporary or in-memory database.  */
  const int bMmapOk = (pgno>1
   && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))
  );

  assert( USEFETCH(pPager) );

  /* Optimization note:  Adding the "pgno<=1" term before "pgno==0" here
  ** allows the compiler optimizer to reuse the results of the "pgno>1"
  ** test in the previous statement, and avoid testing pgno==0 in the
  ** common case where pgno is large. */
  if( pgno<=1 && pgno==0 ){
    return SQLITE_CORRUPT_BKPT;
  }
  assert( pPager->eState>=PAGER_READER );
  assert( assert_pager_state(pPager) );
  assert( pPager->hasHeldSharedLock==1 );
  assert( pPager->errCode==SQLITE_OK );

  if( bMmapOk && pagerUseWal(pPager) ){
    rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
    if( rc!=SQLITE_OK ){
      *ppPage = 0;
      return rc;
    }
  }
  if( bMmapOk && iFrame==0 ){
    void *pData = 0;
    rc = sqlite3OsFetch(pPager->fd,
        (i64)(pgno-1) * pPager->pageSize, pPager->pageSize, &pData
    );
    if( rc==SQLITE_OK && pData ){
      if( pPager->eState>PAGER_READER || pPager->tempFile ){
        pPg = sqlite3PagerLookup(pPager, pgno);
      }
      if( pPg==0 ){
        rc = pagerAcquireMapPage(pPager, pgno, pData, &pPg);
      }else{
        sqlite3OsUnfetch(pPager->fd, (i64)(pgno-1)*pPager->pageSize, pData);
      }
      if( pPg ){
        assert( rc==SQLITE_OK );
        *ppPage = pPg;
        return SQLITE_OK;
      }
    }
    if( rc!=SQLITE_OK ){
      *ppPage = 0;
      return rc;
    }
  }
  return getPageNormal(pPager, pgno, ppPage, flags);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, %r14d
movq %rdi, %r15
movl $0x0, 0xc(%rsp)
cmpl $0x2, %esi
jb 0x292bfd
cmpb $0x1, 0x14(%r15)
sete %al
movl %ebp, %r12d
andl $0x2, %r12d
shrl %r12d
orb %al, %r12b
jmp 0x292c00
xorl %r12d, %r12d
testl %r14d, %r14d
je 0x292cd5
testb %r12b, %r12b
je 0x292c3a
movq 0x120(%r15), %rdi
testq %rdi, %rdi
je 0x292c3a
leaq 0xc(%rsp), %rdx
movl %r14d, %esi
callq 0x290ec3
testl %eax, %eax
je 0x292c3a
movl %eax, %r13d
movq $0x0, (%rbx)
jmp 0x292dd6
cmpl $0x0, 0xc(%rsp)
sete %al
andb %al, %r12b
cmpb $0x1, %r12b
jne 0x292dc3
leaq 0x10(%rsp), %rcx
movq $0x0, (%rcx)
movq 0x48(%r15), %rdi
leal -0x1(%r14), %r13d
movslq 0xbc(%r15), %rdx
movq %rdx, %rsi
imulq %r13, %rsi
movq (%rdi), %rax
callq *0x88(%rax)
testl %eax, %eax
jne 0x292dac
cmpq $0x0, 0x10(%rsp)
je 0x292dac
cmpb $0x1, 0x14(%r15)
ja 0x292ca0
cmpb $0x0, 0x10(%r15)
je 0x292d34
movq %r15, %rdi
movl %r14d, %esi
callq 0x2930a5
movq %rax, %r12
testq %r12, %r12
je 0x292d06
movq 0x48(%r15), %rdi
movslq 0xbc(%r15), %rsi
imulq %r13, %rsi
movq 0x10(%rsp), %rdx
movq (%rdi), %rax
callq *0x90(%rax)
jmp 0x292da2
leaq 0x14c643(%rip), %rsi    # 0x3df31f
leaq 0x14c74d(%rip), %rdx    # 0x3df430
leaq 0x14c49b(%rip), %r8     # 0x3df185
movl $0xb, %r13d
movl $0xb, %edi
movl $0xdfc8, %ecx           # imm = 0xDFC8
xorl %eax, %eax
callq 0x27e637
jmp 0x292dd6
movq 0x10(%rsp), %rdx
movq 0xa8(%r15), %r12
testq %r12, %r12
je 0x292d3c
movq 0x20(%r12), %rax
movq %rax, 0xa8(%r15)
xorl %eax, %eax
movq %rax, 0x20(%r12)
movq 0x10(%r12), %rcx
movq %rax, (%rcx)
jmp 0x292d91
xorl %r12d, %r12d
jmp 0x292cae
movq %rdx, 0x18(%rsp)
movzwl 0xb0(%r15), %edi
addq $0x48, %rdi
movq %rdi, 0x20(%rsp)
callq 0x27c381
movq %rax, %r12
testq %rax, %rax
je 0x292de8
movq %r12, %rdi
xorl %esi, %esi
movq 0x20(%rsp), %rdx
callq 0x173a0
movq %r12, %rax
addq $0x48, %rax
movq %rax, 0x10(%r12)
movl $0x10020, 0x34(%r12)    # imm = 0x10020
movq %r15, 0x28(%r12)
movq 0x18(%rsp), %rdx
movl %r14d, 0x30(%r12)
movq %rdx, 0x8(%r12)
incl 0x98(%r15)
xorl %eax, %eax
xorl %r13d, %r13d
testq %r12, %r12
jne 0x292db6
testl %eax, %eax
je 0x292dbd
xorl %r12d, %r12d
movl %eax, %r13d
movq %r12, (%rbx)
xorl %eax, %eax
jmp 0x292dbf
movb $0x1, %al
testb %al, %al
je 0x292dd6
movq %r15, %rdi
movl %r14d, %esi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x292e0c
movl %eax, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r15), %rdi
movslq 0xbc(%r15), %rsi
imulq %r13, %rsi
movq (%rdi), %rax
movq 0x18(%rsp), %rdx
callq *0x90(%rax)
movl $0x7, %eax
jmp 0x292da4