// File: /workspace/github_c_makefile_star2_O0/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
subq $0x60, %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)
movl -0x24(%rbp), %eax
andl $0x1, %eax
movl %eax, -0x38(%rbp)
xorl %eax, %eax
cmpl $0x1, -0x14(%rbp)
movb %al, -0x51(%rbp)
jbe 0x123f9
movq -0x10(%rbp), %rax
movzbl 0x1a(%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x51(%rbp)
je 0x123f9
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %ecx
movb $0x1, %al
cmpl $0x1, %ecx
movb %al, -0x52(%rbp)
je 0x123f3
movl -0x24(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
setne %al
movb %al, -0x52(%rbp)
movb -0x52(%rbp), %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x3c(%rbp)
cmpl $0x1, -0x14(%rbp)
ja 0x12422
cmpl $0x0, -0x14(%rbp)
jne 0x12422
movl $0xbe59, %edi           # imm = 0xBE59
callq 0x2a650
movl %eax, -0x4(%rbp)
jmp 0x127c6
movq -0x10(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
je 0x1243b
movq -0x10(%rbp), %rax
movl 0x2c(%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x12604
cmpl $0x0, -0x3c(%rbp)
je 0x12476
movq -0x10(%rbp), %rdi
callq 0x273a0
cmpl $0x0, %eax
je 0x12476
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x14(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x2ef00
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x12474
jmp 0x1279c
jmp 0x12476
cmpl $0x0, -0x3c(%rbp)
je 0x12572
cmpl $0x0, -0x34(%rbp)
jne 0x12572
movq $0x0, -0x48(%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 -0x48(%rbp), %rcx
callq 0x31bb0
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
jne 0x12565
cmpq $0x0, -0x48(%rbp)
je 0x12565
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x1, %eax
jle 0x124fb
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x2ee30
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x1251b
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x48(%rbp), %rdx
leaq -0x30(%rbp), %rcx
callq 0x31bf0
movl %eax, -0x28(%rbp)
jmp 0x12545
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 -0x48(%rbp), %rdx
callq 0x2c9d0
cmpq $0x0, -0x30(%rbp)
je 0x12563
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x127c6
jmp 0x12565
cmpl $0x0, -0x28(%rbp)
je 0x12570
jmp 0x1279c
jmp 0x12572
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rdi
movl -0x14(%rbp), %esi
movl $0x3, %edx
callq 0x2f1e0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x125e2
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rdi
movl -0x14(%rbp), %esi
leaq -0x50(%rbp), %rdx
callq 0x31d40
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x125ba
jmp 0x1279c
cmpq $0x0, -0x50(%rbp)
jne 0x125e0
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq $0x0, -0x30(%rbp)
movl $0x7, -0x28(%rbp)
jmp 0x1279c
jmp 0x125e2
movq -0x10(%rbp), %rax
movq 0x110(%rax), %rdi
movl -0x14(%rbp), %esi
movq -0x50(%rbp), %rdx
callq 0x2f220
movq -0x20(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x12617
movq $0x0, -0x30(%rbp)
jmp 0x1279c
movq -0x30(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x12647
cmpl $0x0, -0x38(%rbp)
jne 0x12647
movq -0x10(%rbp), %rax
movl 0xf0(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xf0(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x127c6
movq -0x10(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpl $0x7fffffff, -0x14(%rbp) # imm = 0x7FFFFFFF
ja 0x1267f
movl -0x14(%rbp), %eax
movl %eax, -0x58(%rbp)
movl 0xad2a8(%rip), %eax     # 0xbf910
movq -0x10(%rbp), %rcx
cltd
idivl 0xbc(%rcx)
movl %eax, %ecx
movl -0x58(%rbp), %eax
addl $0x1, %ecx
cmpl %ecx, %eax
jne 0x12691
movl $0xbeb2, %edi           # imm = 0xBEB2
callq 0x2a650
movl %eax, -0x28(%rbp)
jmp 0x1279c
movq -0x10(%rbp), %rax
movzbl 0x13(%rax), %eax
cmpl $0x0, %eax
jne 0x126be
movq -0x10(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x14(%rbp), %eax
jb 0x126be
cmpl $0x0, -0x38(%rbp)
jne 0x126be
movq -0x10(%rbp), %rax
movq 0x48(%rax), %rax
cmpq $0x0, (%rax)
jne 0x1272d
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc0(%rcx), %eax
jbe 0x126d9
movl $0xd, -0x28(%rbp)
jmp 0x1279c
cmpl $0x0, -0x38(%rbp)
je 0x12711
callq 0x2a3f0
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x20(%rcx), %eax
ja 0x12700
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movl -0x14(%rbp), %esi
callq 0x282e0
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x27dc0
callq 0x2a440
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movslq 0xbc(%rax), %rdx
xorl %esi, %esi
callq 0xb2b0
jmp 0x12791
movq -0x10(%rbp), %rdi
callq 0x273a0
cmpl $0x0, %eax
je 0x12765
cmpl $0x0, -0x3c(%rbp)
jne 0x12765
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movl -0x14(%rbp), %esi
leaq -0x34(%rbp), %rdx
callq 0x2ef00
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x12763
jmp 0x1279c
jmp 0x12765
movq -0x10(%rbp), %rax
movl 0xf4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xf4(%rax)
movq -0x30(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x2f080
movl %eax, -0x28(%rbp)
cmpl $0x0, -0x28(%rbp)
je 0x1278f
jmp 0x1279c
jmp 0x12791
jmp 0x12793
movl $0x0, -0x4(%rbp)
jmp 0x127c6
cmpq $0x0, -0x30(%rbp)
je 0x127ac
movq -0x30(%rbp), %rdi
callq 0x2ee90
movq -0x10(%rbp), %rdi
callq 0x2f4f0
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movl -0x28(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop