// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movl %ecx, %ebp
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, %r14
movl $0x0, 0x4(%rsp)
cmpl $0x1, %esi
jbe 0x288e19
testb $0x2, %bpl
jne 0x288ded
cmpb $0x1, 0x14(%r14)
jne 0x288e1e
movq 0x120(%r14), %rdi
testq %rdi, %rdi
je 0x288e6e
leaq 0x4(%rsp), %rdx
movl %r15d, %esi
callq 0x2871d7
testl %eax, %eax
je 0x288e67
movl %eax, %r12d
movq $0x0, (%rbx)
jmp 0x288f8f
testl %r15d, %r15d
je 0x288e36
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x288fc9
movl %eax, %r12d
jmp 0x288f8f
leaq 0x14cd8e(%rip), %rsi    # 0x3d5bcb
leaq 0x14ce98(%rip), %rdx    # 0x3d5cdc
leaq 0x14cbe6(%rip), %r8     # 0x3d5a31
movl $0xb, %r12d
movl $0xb, %edi
movl $0xdfc8, %ecx           # imm = 0xDFC8
xorl %eax, %eax
callq 0x274d08
jmp 0x288f8f
cmpl $0x0, 0x4(%rsp)
jne 0x288e1e
leaq 0x10(%rsp), %r13
movq $0x0, (%r13)
movq 0x48(%r14), %rdi
leal -0x1(%r15), %eax
movslq 0xbc(%r14), %rdx
movq %rdx, %rsi
movq %rax, 0x8(%rsp)
imulq %rax, %rsi
movq (%rdi), %rax
movq %r13, %rcx
callq *0x88(%rax)
movl %eax, %r12d
testl %eax, %eax
sete %al
movq (%r13), %rdx
testq %rdx, %rdx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x288f00
cmpb $0x1, 0x14(%r14)
ja 0x288ec9
cmpb $0x0, 0x10(%r14)
je 0x288f0e
movq %r14, %rdi
movl %r15d, %esi
callq 0x289239
movq 0x10(%rsp), %rdx
testq %rax, %rax
je 0x288f0e
movq %rax, %r13
movq 0x48(%r14), %rdi
movslq 0xbc(%r14), %rsi
imulq 0x8(%rsp), %rsi
movq (%rdi), %rax
callq *0x90(%rax)
jmp 0x288f89
testl %r12d, %r12d
je 0x288e1e
xorl %r13d, %r13d
jmp 0x288f8c
movq 0xa8(%r14), %r13
testq %r13, %r13
je 0x288f34
movq 0x20(%r13), %rax
movq %rax, 0xa8(%r14)
xorl %eax, %eax
movq %rax, 0x20(%r13)
movq 0x10(%r13), %rcx
movq %rax, (%rcx)
jmp 0x288f7a
movq %rdx, %rbp
movzwl 0xb0(%r14), %r12d
addq $0x48, %r12
movq %r12, %rdi
callq 0x272ae6
testq %rax, %rax
je 0x288fa1
movq %rax, %r13
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x173a0
movq %r13, %rax
addq $0x48, %rax
movq %rax, 0x10(%r13)
movl $0x10020, 0x34(%r13)    # imm = 0x10020
movq %r14, 0x28(%r13)
movq %rbp, %rdx
movl %r15d, 0x30(%r13)
movq %rdx, 0x8(%r13)
incl 0x98(%r14)
xorl %r12d, %r12d
movq %r13, (%rbx)
movl %r12d, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r14), %rdi
movslq 0xbc(%r14), %rsi
imulq 0x8(%rsp), %rsi
movq (%rdi), %rax
movq %rbp, %rdx
callq *0x90(%rax)
movl $0x7, %r12d
jmp 0x288f09