// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x14(%rbp)
movb %al, -0x41(%rbp)
jbe 0x3e0b3e
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x42(%rbp)
je 0x3e0b38
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x42(%rbp)
movb -0x42(%rbp), %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x38(%rbp)
cmpl $0x1, -0x14(%rbp)
ja 0x3e0b67
cmpl $0x0, -0x14(%rbp)
jne 0x3e0b67
movl $0xdfc8, %edi           # imm = 0xDFC8
callq 0x3dff80
movl %eax, -0x4(%rbp)
jmp 0x3e0cdd
cmpl $0x0, -0x38(%rbp)
je 0x3e0bb3
movq -0x10(%rbp), %rax
cmpq $0x0, 0x120(%rax)
je 0x3e0bb3
movq -0x10(%rbp), %rax
movq 0x120(%rax), %rdi
movl -0x14(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x3ddfb0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x3e0bb1
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e0cdd
jmp 0x3e0bb3
cmpl $0x0, -0x38(%rbp)
je 0x3e0cc7
cmpl $0x0, -0x34(%rbp)
jne 0x3e0cc7
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
movq -0x10(%rbp), %rax
movslq 0xbc(%rax), %rax
imulq %rax, %rsi
movq -0x10(%rbp), %rax
movl 0xbc(%rax), %edx
leaq -0x40(%rbp), %rcx
callq 0x3e0f30
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x3e0cac
cmpq $0x0, -0x40(%rbp)
je 0x3e0cac
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x1, %eax
jg 0x3e0c35
movq -0x10(%rbp), %rax
movzbl 0x10(%rax), %eax
cmpl $0x0, %eax
je 0x3e0c45
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x3e0f70
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x3e0c65
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x40(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x3e0fd0
movl %eax, -0x28(%rbp)
jmp 0x3e0c8f
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rdi
movl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, %eax
movl %eax, %esi
movq -0x10(%rbp), %rax
movslq 0xbc(%rax), %rax
imulq %rax, %rsi
movq -0x40(%rbp), %rdx
callq 0x3e1110
cmpq $0x0, -0x30(%rbp)
je 0x3e0caa
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3e0cdd
jmp 0x3e0cac
cmpl $0x0, -0x28(%rbp)
je 0x3e0cc5
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3e0cdd
jmp 0x3e0cc7
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x20(%rbp), %rdx
movl -0x24(%rbp), %ecx
callq 0x3e0cf0
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)