// File: /workspace/github_c_makefile_star2_O3/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
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
movq $0x0, -0x38(%rbp)
movl $0x0, -0x2c(%rbp)
cmpl $0x2, %esi
jb 0x1015a
cmpb $0x0, 0x1a(%rbx)
movl 0x2c(%rbx), %r13d
je 0x10163
testl %r13d, %r13d
jne 0x104c1
movl %ecx, -0x30(%rbp)
testb $0x2, %cl
jne 0x1012e
cmpb $0x1, 0x14(%rbx)
jne 0x1016f
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x10349
leaq -0x2c(%rbp), %rdx
movl %r15d, %esi
callq 0x24bef
testl %eax, %eax
je 0x1033c
movl %eax, %r13d
jmp 0x104b3
testl %r15d, %r15d
je 0x101cc
movl 0x2c(%rbx), %r13d
testl %r13d, %r13d
jne 0x104c1
movl %ecx, -0x30(%rbp)
xorl %r13d, %r13d
movq 0x110(%rbx), %rax
movzbl 0x2d(%rax), %edx
movq 0x40(%rax), %rdi
andl $0x3, %edx
movl %r15d, %esi
callq *0x8128b(%rip)          # 0x91418
testq %rax, %rax
je 0x101f6
movq 0x110(%rbx), %rdi
movl %r15d, %esi
movq %rax, %rdx
callq 0x24ea6
movq %rax, %r12
movq %rax, (%r14)
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %ecx
testb $0x1, %cl
jne 0x10217
cmpq $0x0, 0x20(%r12)
je 0x10217
incl 0xf0(%rbx)
xorl %r13d, %r13d
jmp 0x104e6
leaq 0x6b315(%rip), %rsi     # 0x7b4e8
leaq 0x6afb3(%rip), %rcx     # 0x7b18d
movl $0xb, %r13d
movl $0xb, %edi
movl $0xbe59, %edx           # imm = 0xBE59
xorl %eax, %eax
callq 0xa4c0
jmp 0x104e6
movq 0x110(%rbx), %r12
cmpb $0x2, 0x2d(%r12)
jne 0x1025f
movq $0x0, (%r14)
movl $0x7, %r13d
jmp 0x104c1
movq %rbx, 0x20(%r12)
testl %r15d, %r15d
js 0x10235
movl 0x81559(%rip), %eax     # 0x91780
cltd
idivl 0xbc(%rbx)
incl %eax
cmpl %r15d, %eax
jne 0x1029e
leaq 0x6b2ac(%rip), %rsi     # 0x7b4e8
leaq 0x6af4a(%rip), %rcx     # 0x7b18d
movl $0xb, %r13d
movl $0xb, %edi
movl $0xbeb2, %edx           # imm = 0xBEB2
xorl %eax, %eax
callq 0xa4c0
jmp 0x104b3
movl %r13d, -0x40(%rbp)
movq 0x40(%r12), %rdi
callq *0x811a2(%rip)          # 0x91410
cmpl 0x20(%r12), %eax
jle 0x10482
movq 0x10(%r12), %rsi
testq %rsi, %rsi
je 0x10314
cmpw $0x0, 0x2e(%rsi)
jne 0x10298
testb $0x8, 0x2c(%rsi)
je 0x10467
movq 0x40(%rsi), %rsi
jmp 0x1027e
cmpb $0x0, 0x13(%rbx)
je 0x103df
movl $0xd, %r13d
cmpl %r15d, 0xc0(%rbx)
jb 0x104b3
testb $0x1, %cl
je 0x102f9
movq 0x83221(%rip), %rax     # 0x934e8
testq %rax, %rax
je 0x102ce
callq *%rax
cmpl %r15d, 0x20(%rbx)
jb 0x102e0
movq 0x40(%rbx), %rdi
movl %r15d, %esi
callq 0x20534
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2022b
movq 0x831fe(%rip), %rax     # 0x934f0
testq %rax, %rax
je 0x102f9
callq *%rax
movq 0x8(%r12), %rdi
movslq 0xbc(%rbx), %rdx
xorl %r13d, %r13d
xorl %esi, %esi
callq 0xa220
jmp 0x104e6
movq $0x0, 0x10(%r12)
movq 0x8(%r12), %rsi
testq %rsi, %rsi
je 0x10482
cmpw $0x0, 0x2e(%rsi)
je 0x1046c
movq 0x40(%rsi), %rsi
jmp 0x10322
movb $0x1, %r13b
cmpl $0x0, -0x2c(%rbp)
jne 0x10172
leaq -0x48(%rbp), %r12
movq $0x0, (%r12)
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 %r12, %rcx
callq *0x88(%rax)
movl %eax, %r13d
testl %eax, %eax
sete %al
movq (%r12), %rdx
testq %rdx, %rdx
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x104ae
cmpb $0x2, 0x14(%rbx)
jb 0x10444
movq %rbx, %rdi
movl %r15d, %esi
callq 0x24b71
movq %rax, -0x38(%rbp)
movq -0x48(%rbp), %rdx
testq %rax, %rax
je 0x10444
movq %rax, %r12
movq 0x48(%rbx), %rdi
movslq 0xbc(%rbx), %rsi
imulq -0x40(%rbp), %rsi
movq (%rdi), %rax
callq *0x90(%rax)
jmp 0x1045f
testb $0x1, %cl
jne 0x102a8
cmpl %r15d, 0x1c(%rbx)
jb 0x102a8
movq 0x48(%rbx), %rax
cmpq $0x0, (%rax)
je 0x102a8
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
sete %al
orb %al, %r13b
jne 0x10426
leaq -0x2c(%rbp), %rdx
movl %r15d, %esi
callq 0x24bef
testl %eax, %eax
jne 0x10152
incl 0xf4(%rbx)
movl -0x2c(%rbp), %esi
movq %r12, %rdi
callq 0x24d70
testl %eax, %eax
jne 0x10152
jmp 0x101c4
leaq -0x38(%rbp), %r12
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rcx
callq 0x25ef2
movq (%r12), %r12
testq %r12, %r12
je 0x104ab
movq %r12, (%r14)
jmp 0x101c4
movq %rsi, 0x10(%r12)
movq 0x38(%r12), %rdi
callq *0x30(%r12)
cmpl $0x5, %eax
je 0x10482
movl %eax, %r13d
testl %eax, %eax
jne 0x104b3
movq 0x40(%r12), %rdi
movl %r15d, %esi
movl $0x2, %edx
callq *0x80f83(%rip)          # 0x91418
testq %rax, %rax
je 0x104a3
movl -0x40(%rbp), %r13d
jmp 0x10192
movl $0x7, %r13d
jmp 0x104b3
movl %eax, %r13d
testl %r13d, %r13d
je 0x104f8
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x104c1
callq 0x24bb1
cmpl $0x0, 0x98(%rbx)
jne 0x104df
movq 0x110(%rbx), %rax
cmpl $0x0, 0x18(%rax)
jne 0x104df
movq %rbx, %rdi
callq 0x22901
movq $0x0, (%r14)
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %r13b
jmp 0x10172