// File: /workspace/github_c_makefile_star2_O1/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, %r14d
movl %esi, %r15d
movq %rdi, %rbx
movq $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
cmpl $0x2, %esi
jb 0x10042
cmpb $0x0, 0x1a(%rbx)
je 0x10042
cmpb $0x1, 0x14(%rbx)
sete %al
movl %r14d, %r12d
andl $0x2, %r12d
shrl %r12d
orb %al, %r12b
jmp 0x10045
xorl %r12d, %r12d
testl %r15d, %r15d
je 0x100a4
movq %rdx, -0x40(%rbp)
movl 0x2c(%rbx), %r13d
testl %r13d, %r13d
je 0x100ce
testl %r13d, %r13d
je 0x10195
movq $0x0, -0x30(%rbp)
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x10076
callq 0x24d68
cmpl $0x0, 0x98(%rbx)
jne 0x10094
movq 0x110(%rbx), %rax
cmpl $0x0, 0x18(%rax)
jne 0x10094
movq %rbx, %rdi
callq 0x22a5d
movq -0x40(%rbp), %rax
movq $0x0, (%rax)
jmp 0x103c3
leaq 0x6d42d(%rip), %rsi     # 0x7d4d8
leaq 0x6d0cb(%rip), %rcx     # 0x7d17d
movl $0xb, %r13d
movl $0xb, %edi
movl $0xbe59, %edx           # imm = 0xBE59
xorl %eax, %eax
callq 0xa4b0
jmp 0x103c3
testb %r12b, %r12b
je 0x100f7
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
je 0x100f7
leaq -0x34(%rbp), %rdx
movl %r15d, %esi
callq 0x24da6
testl %eax, %eax
je 0x100f7
movl %eax, %r13d
jmp 0x10068
cmpl $0x0, -0x34(%rbp)
sete %al
andb %r12b, %al
xorl %r13d, %r13d
cmpb $0x1, %al
jne 0x102bf
leaq -0x50(%rbp), %rcx
movq $0x0, (%rcx)
movq 0x48(%rbx), %rdi
leal -0x1(%r15), %eax
movslq 0xbc(%rbx), %rdx
movq %rdx, %rsi
movq %rax, -0x48(%rbp)
imulq %rax, %rsi
movq (%rdi), %rax
callq *0x88(%rax)
movl %eax, %r13d
testl %eax, %eax
jne 0x102a4
cmpq $0x0, -0x50(%rbp)
je 0x102a4
cmpb $0x2, 0x14(%rbx)
jb 0x10165
movq %rbx, %rdi
movl %r15d, %esi
callq 0x24d28
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x10277
movq 0x48(%rbx), %rdi
movslq 0xbc(%rbx), %rsi
imulq -0x48(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq (%rdi), %rax
callq *0x90(%rax)
xorl %r13d, %r13d
jmp 0x1028d
movq -0x30(%rbp), %rcx
testb $0x1, %r14b
jne 0x101b1
cmpq $0x0, 0x20(%rcx)
je 0x101b1
incl 0xf0(%rbx)
jmp 0x103c0
movq %rbx, 0x20(%rcx)
testl %r15d, %r15d
js 0x101ce
movl 0x835b0(%rip), %eax     # 0x93770
cltd
idivl 0xbc(%rbx)
incl %eax
cmpl %r15d, %eax
jne 0x101f8
leaq 0x6d303(%rip), %rsi     # 0x7d4d8
leaq 0x6cfa1(%rip), %rcx     # 0x7d17d
movl $0xb, %r13d
movl $0xb, %edi
movl $0xbeb2, %edx           # imm = 0xBEB2
xorl %eax, %eax
callq 0xa4b0
jmp 0x10068
cmpb $0x0, 0x13(%rbx)
je 0x10357
movl $0xd, %r13d
cmpl %r15d, 0xc0(%rbx)
jb 0x10068
testb $0x1, %r14b
je 0x1025d
movq %rcx, %r14
movq 0x852b3(%rip), %rax     # 0x954d8
testq %rax, %rax
je 0x1022c
callq *%rax
cmpl %r15d, 0x20(%rbx)
jb 0x1023e
movq 0x40(%rbx), %rdi
movl %r15d, %esi
callq 0x20610
movq %rbx, %rdi
movl %r15d, %esi
callq 0x2032c
movq 0x85290(%rip), %rax     # 0x954e0
testq %rax, %rax
movq %r14, %rcx
je 0x1025d
callq *%rax
movq %r14, %rcx
movq 0x8(%rcx), %rdi
movslq 0xbc(%rbx), %rdx
xorl %r13d, %r13d
xorl %esi, %esi
callq 0xa210
jmp 0x103c3
movq -0x50(%rbp), %rdx
leaq -0x30(%rbp), %rcx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x26162
movl %eax, %r13d
movq -0x30(%rbp), %rax
testq %rax, %rax
je 0x102a4
movq -0x40(%rbp), %rcx
movq %rax, (%rcx)
movl $0x1, %eax
jmp 0x102ae
xorl %eax, %eax
testl %r13d, %r13d
setne %al
addl %eax, %eax
cmpl $0x2, %eax
je 0x10068
testl %eax, %eax
jne 0x103c0
movq 0x110(%rbx), %rax
movzbl 0x2d(%rax), %edx
andl $0x3, %edx
movq 0x40(%rax), %rdi
movl %r15d, %esi
callq *0x8312e(%rip)          # 0x93408
movq %rax, %rdx
testq %rax, %rax
je 0x10307
movq 0x110(%rbx), %rdi
movl %r15d, %esi
callq 0x2509e
movq -0x40(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, -0x30(%rbp)
movl %r13d, %eax
movb $0x1, %r13b
jmp 0x1043a
movq 0x110(%rbx), %r13
xorl %eax, %eax
cmpb $0x2, 0x2d(%r13)
je 0x10433
movq 0x40(%r13), %rdi
movq %rdx, -0x48(%rbp)
callq *0x830d7(%rip)          # 0x93400
cmpl 0x20(%r13), %eax
jle 0x10411
movq 0x10(%r13), %rsi
testq %rsi, %rsi
je 0x103d5
cmpw $0x0, 0x2e(%rsi)
jne 0x10351
testb $0x8, 0x2c(%rsi)
je 0x103f3
movq 0x40(%rsi), %rsi
jmp 0x10337
testb $0x1, %r14b
jne 0x10202
cmpl %r15d, 0x1c(%rbx)
jb 0x10202
movq 0x48(%rbx), %rax
cmpq $0x0, (%rax)
je 0x10202
movq 0x118(%rbx), %rdi
testq %rdi, %rdi
sete %al
orb %r12b, %al
testb $0x1, %al
jne 0x103a7
leaq -0x34(%rbp), %rdx
movl %r15d, %esi
movq %rcx, %r14
callq 0x24da6
movq %r14, %rcx
testl %eax, %eax
jne 0x100ef
incl 0xf4(%rbx)
movl -0x34(%rbp), %esi
movq %rcx, %rdi
callq 0x24f68
testl %eax, %eax
jne 0x100ef
xorl %r13d, %r13d
movl %r13d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, 0x10(%r13)
movq 0x8(%r13), %rsi
testq %rsi, %rsi
je 0x103ef
cmpw $0x0, 0x2e(%rsi)
je 0x103f7
movq 0x40(%rsi), %rsi
jmp 0x103dd
xorl %esi, %esi
jmp 0x103f7
movq %rsi, 0x10(%r13)
testq %rsi, %rsi
je 0x10411
movq 0x38(%r13), %rdi
callq *0x30(%r13)
movq -0x48(%rbp), %rdx
cmpl $0x5, %eax
je 0x10411
testl %eax, %eax
jne 0x10433
movq 0x40(%r13), %rdi
movl %r15d, %esi
movl $0x2, %edx
callq *0x82fe5(%rip)          # 0x93408
movq %rax, %rdx
xorl %ecx, %ecx
testq %rax, %rax
movl $0x7, %eax
cmovnel %ecx, %eax
xorl %r13d, %r13d
testl %eax, %eax
je 0x1044b
testb %r13b, %r13b
movl %eax, %r13d
jne 0x10057
jmp 0x10068
testq %rdx, %rdx
jne 0x102e2
xorl %r13d, %r13d
movq -0x40(%rbp), %rax
movq %r13, (%rax)
movq %r13, -0x30(%rbp)
movl $0x7, %eax
jmp 0x1043a