// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3PagerGet
SQLITE_PRIVATE int sqlite3PagerGet(
  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 */
  const int noContent = (flags & PAGER_GET_NOCONTENT);

  /* 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 && USEFETCH(pPager)
   && (pPager->eState==PAGER_READER || (flags & PAGER_GET_READONLY))
#ifdef SQLITE_HAS_CODEC
   && pPager->xCodec==0
#endif
  );

  /* 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( noContent==0 || bMmapOk==0 );

  assert( pPager->hasHeldSharedLock==1 );

  /* If the pager is in the error state, return an error immediately. 
  ** Otherwise, request the page from the PCache layer. */
  if( pPager->errCode!=SQLITE_OK ){
    rc = pPager->errCode;
  }else{
    if( bMmapOk && pagerUseWal(pPager) ){
      rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
      if( rc!=SQLITE_OK ) goto pager_acquire_err;
    }

    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 ){
          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 ){
        goto pager_acquire_err;
      }
    }

    {
      sqlite3_pcache_page *pBase;
      pBase = sqlite3PcacheFetch(pPager->pPCache, pgno, 3);
      if( pBase==0 ){
        rc = sqlite3PcacheFetchStress(pPager->pPCache, pgno, &pBase);
        if( rc!=SQLITE_OK ) goto pager_acquire_err;
        if( pBase==0 ){
          pPg = *ppPage = 0;
          rc = SQLITE_NOMEM;
          goto pager_acquire_err;
        }
      }
      pPg = *ppPage = sqlite3PcacheFetchFinish(pPager->pPCache, pgno, pBase);
      assert( pPg!=0 );
    }
  }

  if( rc!=SQLITE_OK ){
    /* Either the call to sqlite3PcacheFetch() returned an error or the
    ** pager was already in the error-state when this function was called.
    ** Set pPg to 0 and jump to the exception handler.  */
    pPg = 0;
    goto pager_acquire_err;
  }
  assert( pPg==(*ppPage) );
  assert( pPg->pgno==pgno );
  assert( pPg->pPager==pPager || pPg->pPager==0 );

  if( pPg->pPager && !noContent ){
    /* In this case the pcache already contains an initialized copy of
    ** the page. Return without further ado.  */
    assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
    pPager->aStat[PAGER_STAT_HIT]++;
    return SQLITE_OK;

  }else{
    /* The pager cache has created a new page. Its content needs to 
    ** be initialized.  */

    pPg->pPager = pPager;

    /* The maximum page number is 2^31. Return SQLITE_CORRUPT if a page
    ** number greater than this, or the unused locking-page, is requested. */
    if( pgno>PAGER_MAX_PGNO || pgno==PAGER_MJ_PGNO(pPager) ){
      rc = SQLITE_CORRUPT_BKPT;
      goto pager_acquire_err;
    }

    if( MEMDB || pPager->dbSize<pgno || noContent || !isOpen(pPager->fd) ){
      if( pgno>pPager->mxPgno ){
        rc = SQLITE_FULL;
        goto pager_acquire_err;
      }
      if( noContent ){
        /* Failure to set the bits in the InJournal bit-vectors is benign.
        ** It merely means that we might do some extra work to journal a 
        ** page that does not need to be journaled.  Nevertheless, be sure 
        ** to test the case where a malloc error occurs while trying to set 
        ** a bit in a bit vector.
        */
        sqlite3BeginBenignMalloc();
        if( pgno<=pPager->dbOrigSize ){
          TESTONLY( rc = ) sqlite3BitvecSet(pPager->pInJournal, pgno);
          testcase( rc==SQLITE_NOMEM );
        }
        TESTONLY( rc = ) addToSavepointBitvecs(pPager, pgno);
        testcase( rc==SQLITE_NOMEM );
        sqlite3EndBenignMalloc();
      }
      memset(pPg->pData, 0, pPager->pageSize);
      IOTRACE(("ZERO %p %d\n", pPager, pgno));
    }else{
      if( pagerUseWal(pPager) && bMmapOk==0 ){
        rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iFrame);
        if( rc!=SQLITE_OK ) goto pager_acquire_err;
      }
      assert( pPg->pPager==pPager );
      pPager->aStat[PAGER_STAT_MISS]++;
      rc = readDbPage(pPg, iFrame);
      if( rc!=SQLITE_OK ){
        goto pager_acquire_err;
      }
    }
    pager_set_pagehash(pPg);
  }

  return SQLITE_OK;

pager_acquire_err:
  assert( rc!=SQLITE_OK );
  if( pPg ){
    sqlite3PcacheDrop(pPg);
  }
  pagerUnlockIfUnused(pPager);

  *ppPage = 0;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %r12d
movq %rdx, %r13
movl %esi, %r15d
movq %rdi, %rbx
andl $0x0, -0x34(%rbp)
cmpl $0x2, %esi
jb 0xf6c5
cmpb $0x0, 0x1a(%rbx)
movl 0x2c(%rbx), %r14d
je 0xf6ce
testl %r14d, %r14d
jne 0xf79b
xorl %r14d, %r14d
testb $0x2, %r12b
jne 0xf699
cmpb $0x1, 0x14(%rbx)
jne 0xf6da
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0xf84b
leaq -0x34(%rbp), %rdx
movl %r15d, %esi
callq 0x21ae4
testl %eax, %eax
je 0xf83c
movl %eax, %r14d
jmp 0xf79b
testl %r15d, %r15d
je 0xf737
movl 0x2c(%rbx), %r14d
testl %r14d, %r14d
jne 0xf79b
xorl %r14d, %r14d
xorl %eax, %eax
movl %eax, -0x40(%rbp)
movq %r13, -0x30(%rbp)
movq 0x110(%rbx), %rax
movzbl 0x2d(%rax), %edx
andl $0x3, %edx
movq 0x40(%rax), %rdi
movl %r15d, %esi
callq *0x73e0a(%rip)          # 0x83508
testq %rax, %rax
je 0xf747
movq 0x110(%rbx), %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x21d12
movq %rax, %r13
movq -0x30(%rbp), %rax
movq %r13, (%rax)
testb $0x1, %r12b
jne 0xf764
cmpq $0x0, 0x20(%r13)
je 0xf764
incl 0xf0(%rbx)
xorl %r14d, %r14d
jmp 0xf7a8
movl $0xbe59, %edi           # imm = 0xBE59
callq 0x1ec07
pushq $0xb
popq %r14
jmp 0xf7a8
movq 0x110(%rbx), %r13
cmpb $0x2, 0x2d(%r13)
jne 0xf7ba
movq -0x30(%rbp), %r13
andq $0x0, (%r13)
pushq $0x7
popq %r14
jmp 0xf79b
movq %rbx, 0x20(%r13)
testl %r15d, %r15d
js 0xf781
movl 0x740fd(%rip), %eax     # 0x83870
cltd
idivl 0xbc(%rbx)
incl %eax
cmpl %r15d, %eax
jne 0xf7f8
movl $0xbeb2, %edi           # imm = 0xBEB2
callq 0x1ec07
pushq $0xb
popq %r14
movq %r13, %rdi
callq 0x21aaa
movq -0x30(%rbp), %r13
movq %rbx, %rdi
callq 0x21dd9
andq $0x0, (%r13)
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r14d, -0x44(%rbp)
movq 0x40(%r13), %rdi
callq *0x73d38(%rip)          # 0x83500
cmpl 0x20(%r13), %eax
jle 0xfa03
leaq 0x10(%r13), %rax
movq %rax, %rsi
movq (%rsi), %rsi
testq %rsi, %rsi
je 0xf816
cmpw $0x0, 0x2e(%rsi)
jne 0xf7f2
testb $0x8, 0x2c(%rsi)
je 0xf9e8
addq $0x40, %rsi
jmp 0xf7d9
cmpb $0x0, 0x13(%rbx)
je 0xf94d
cmpl %r15d, 0xc0(%rbx)
jae 0xf8f4
pushq $0xd
jmp 0xf78d
andq $0x0, 0x10(%r13)
leaq 0x8(%r13), %rsi
movq (%rsi), %rsi
testq %rsi, %rsi
je 0xfa03
cmpw $0x0, 0x2e(%rsi)
je 0xf9eb
addq $0x40, %rsi
jmp 0xf81f
movl -0x34(%rbp), %r14d
movb $0x1, %al
testl %r14d, %r14d
jne 0xf6dc
movq %r13, -0x30(%rbp)
leaq -0x50(%rbp), %r13
andq $0x0, (%r13)
movq 0x48(%rbx), %rdi
leal -0x1(%r15), %eax
movslq 0xbc(%rbx), %rdx
movq %rdx, %rsi
movq %rax, -0x40(%rbp)
imulq %rax, %rsi
movq (%rdi), %rax
movq %r13, %rcx
callq *0x88(%rax)
movl %eax, %r14d
testl %eax, %eax
sete %al
movq (%r13), %r13
testq %r13, %r13
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xf8dd
cmpb $0x2, 0x14(%rbx)
jb 0xf9b8
movq %rbx, %rdi
movl %r15d, %esi
callq 0x21a6a
movq -0x50(%rbp), %r13
testq %rax, %rax
je 0xf9b8
movq %rax, %r14
movq 0x48(%rbx), %rdi
movslq 0xbc(%rbx), %rsi
imulq -0x40(%rbp), %rsi
movq (%rdi), %rax
movq %r13, %rdx
callq *0x90(%rax)
jmp 0xfa5b
testl %r14d, %r14d
movq -0x30(%rbp), %r13
jne 0xf79b
movb $0x1, %al
xorl %r14d, %r14d
jmp 0xf6dc
testb $0x1, %r12b
je 0xf933
movq 0x75cd7(%rip), %rax     # 0x855d8
testq %rax, %rax
je 0xf908
callq *%rax
cmpl %r15d, 0x20(%rbx)
jb 0xf91a
movq 0x40(%rbx), %rdi
movl %r15d, %esi
callq 0x1da6c
movq %rbx, %rdi
movl %r15d, %esi
callq 0x1d825
movq 0x75cb4(%rip), %rax     # 0x855e0
testq %rax, %rax
je 0xf933
callq *%rax
movq 0x8(%r13), %rdi
movslq 0xbc(%rbx), %rdx
xorl %r14d, %r14d
xorl %esi, %esi
callq 0xa270
jmp 0xf7a8
testb $0x1, %r12b
jne 0xf802
cmpl %r15d, 0x1c(%rbx)
jb 0xf802
movq 0x48(%rbx), %rax
cmpq $0x0, (%rax)
je 0xf802
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
sete %al
movl -0x40(%rbp), %ecx
orb %al, %cl
jne 0xf997
leaq -0x34(%rbp), %rdx
movl %r15d, %esi
callq 0x21ae4
testl %eax, %eax
jne 0xf9b0
movl -0x34(%rbp), %r14d
incl 0xf4(%rbx)
movq %r13, %rdi
movl %r14d, %esi
callq 0x21bf9
testl %eax, %eax
je 0xf732
movl %eax, %r14d
jmp 0xf78f
movq 0xa8(%rbx), %r14
testq %r14, %r14
je 0xfa21
movq 0x18(%r14), %rax
movq %rax, 0xa8(%rbx)
andq $0x0, 0x18(%r14)
movq 0x10(%r14), %rdi
movzwl 0xb0(%rbx), %edx
xorl %esi, %esi
callq 0xa270
jmp 0xfa4d
movq %rsi, (%rax)
movq 0x38(%r13), %rdi
callq *0x30(%r13)
cmpl $0x5, %eax
je 0xfa03
movl %eax, %r14d
testl %eax, %eax
jne 0xf797
movq 0x40(%r13), %rdi
pushq $0x2
popq %rdx
movl %r15d, %esi
callq *0x73af5(%rip)          # 0x83508
testq %rax, %rax
je 0xfa83
movl -0x44(%rbp), %r14d
jmp 0xf703
movzwl 0xb0(%rbx), %edi
addq $0x48, %rdi
callq 0xe97d
testq %rax, %rax
je 0xfa67
movq %rax, %r14
addq $0x48, %rax
movq %rax, 0x10(%r14)
movl $0x10040, 0x2c(%r14)    # imm = 0x10040
movq %rbx, 0x20(%r14)
movl %r15d, 0x28(%r14)
movq %r13, 0x8(%r14)
incl 0x98(%rbx)
movq -0x30(%rbp), %rax
movq %r14, (%rax)
jmp 0xf732
movq 0x48(%rbx), %rdi
movslq 0xbc(%rbx), %rsi
imulq -0x40(%rbp), %rsi
movq (%rdi), %rax
movq %r13, %rdx
callq *0x90(%rax)
pushq $0x7
popq %r14
jmp 0xf797