// File: /workspace/github_c_makefile_star2_O2/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
andl $0x0, 0xc(%rsp)
cmpl $0x1, %esi
jbe 0x232ada
testb $0x2, %bpl
jne 0x232ab7
cmpb $0x1, 0x14(%r14)
jne 0x232adf
movq 0x120(%r14), %rdi
testq %rdi, %rdi
je 0x232b1d
leaq 0xc(%rsp), %rdx
movl %r15d, %esi
callq 0x231213
testl %eax, %eax
je 0x232b16
andq $0x0, (%rbx)
jmp 0x232aef
testl %r15d, %r15d
je 0x232afe
movq %r14, %rdi
movl %r15d, %esi
movq %rbx, %rdx
movl %ebp, %ecx
callq 0x232c41
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xdfc8, %edi           # imm = 0xDFC8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x232547
cmpl $0x0, 0xc(%rsp)
jne 0x232adf
leaq 0x10(%rsp), %r12
andq $0x0, (%r12)
movq 0x48(%r14), %rdi
leal -0x1(%r15), %r13d
movslq 0xbc(%r14), %rdx
movq %rdx, %rsi
imulq %r13, %rsi
movq (%rdi), %rax
movq %r12, %rcx
callq *0x88(%rax)
testl %eax, %eax
sete %cl
movq (%r12), %r12
testq %r12, %r12
setne %dl
andb %cl, %dl
cmpb $0x1, %dl
jne 0x232ba5
movq %r13, %rbp
cmpb $0x1, 0x14(%r14)
ja 0x232b70
cmpb $0x0, 0x10(%r14)
je 0x232bb2
movq %r14, %rdi
movl %r15d, %esi
callq 0x232e4f
movq 0x10(%rsp), %r12
testq %rax, %rax
je 0x232bb2
movq %rax, %r13
movq 0x48(%r14), %rdi
movslq 0xbc(%r14), %rsi
imulq %rbp, %rsi
movq (%rdi), %rax
movq %r12, %rdx
callq *0x90(%rax)
jmp 0x232c14
testl %eax, %eax
je 0x232adf
xorl %r13d, %r13d
jmp 0x232c16
movq 0xa8(%r14), %r13
testq %r13, %r13
je 0x232bd8
movq 0x20(%r13), %rax
movq %rax, 0xa8(%r14)
andq $0x0, 0x20(%r13)
movq 0x10(%r13), %rax
andq $0x0, (%rax)
jmp 0x232c05
movzwl 0xb0(%r14), %edi
addq $0x48, %rdi
callq 0x2227e2
testq %rax, %rax
je 0x232c1e
movq %rax, %r13
addq $0x48, %rax
movq %rax, 0x10(%r13)
movl $0x10020, 0x34(%r13)    # imm = 0x10020
movq %r14, 0x28(%r13)
movl %r15d, 0x30(%r13)
movq %r12, 0x8(%r13)
incl 0x98(%r14)
xorl %eax, %eax
movq %r13, (%rbx)
jmp 0x232aef
movq 0x48(%r14), %rdi
movslq 0xbc(%r14), %rsi
imulq %rbp, %rsi
movq (%rdi), %rax
movq %r12, %rdx
callq *0x90(%rax)
pushq $0x7
popq %rax
jmp 0x232bad