// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: getAndInitPage
static int getAndInitPage(
  BtShared *pBt,                  /* The database file */
  Pgno pgno,                      /* Number of the page to get */
  MemPage **ppPage,               /* Write the page pointer here */
  BtCursor *pCur,                 /* Cursor to receive the page, or NULL */
  int bReadOnly                   /* True for a read-only page */
){
  int rc;
  DbPage *pDbPage;
  assert( sqlite3_mutex_held(pBt->mutex) );
  assert( pCur==0 || ppPage==&pCur->pPage );
  assert( pCur==0 || bReadOnly==pCur->curPagerFlags );
  assert( pCur==0 || pCur->iPage>0 );

  if( pgno>btreePagecount(pBt) ){
    rc = SQLITE_CORRUPT_BKPT;
    goto getAndInitPage_error1;
  }
  rc = sqlite3PagerGet(pBt->pPager, pgno, (DbPage**)&pDbPage, bReadOnly);
  if( rc ){
    goto getAndInitPage_error1;
  }
  *ppPage = (MemPage*)sqlite3PagerGetExtra(pDbPage);
  if( (*ppPage)->isInit==0 ){
    btreePageFromDbPage(pDbPage, pgno, pBt);
    rc = btreeInitPage(*ppPage);
    if( rc!=SQLITE_OK ){
      goto getAndInitPage_error2;
    }
  }
  assert( (*ppPage)->pgno==pgno );
  assert( (*ppPage)->aData==sqlite3PagerGetData(pDbPage) );

  /* If obtaining a child page for a cursor, we must verify that the page is
  ** compatible with the root page. */
  if( pCur && ((*ppPage)->nCell<1 || (*ppPage)->intKey!=pCur->curIntKey) ){
    rc = SQLITE_CORRUPT_PGNO(pgno);
    goto getAndInitPage_error2;
  }
  return SQLITE_OK;

getAndInitPage_error2:
  releasePage(*ppPage);
getAndInitPage_error1:
  if( pCur ){
    pCur->iPage--;
    pCur->pPage = pCur->apPage[pCur->iPage];
  }
  testcase( pgno==0 );
  assert( pgno!=0 || rc==SQLITE_CORRUPT );
  return rc;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rcx, %rbx
cmpl %esi, 0x40(%rdi)
jae 0x2a8c21
leaq 0x136724(%rip), %rsi    # 0x3df31f
leaq 0x13682e(%rip), %rdx    # 0x3df430
leaq 0x13657c(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x10464, %ecx          # imm = 0x10464
xorl %eax, %eax
callq 0x27e637
jmp 0x2a8c41
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %r12
movq (%rdi), %rdi
leaq 0x8(%rsp), %rdx
movl %r8d, %ecx
callq *0x108(%rdi)
movl %eax, %ebp
testl %eax, %eax
je 0x2a8c70
testq %rbx, %rbx
je 0x2a8c61
movb 0x54(%rbx), %al
decb %al
movb %al, 0x54(%rbx)
movsbq %al, %rax
movq 0x90(%rbx,%rax,8), %rax
movq %rax, 0x88(%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, (%r14)
cmpb $0x0, (%rax)
je 0x2a8cc7
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x2a8c61
movq (%r14), %rax
cmpw $0x0, 0x18(%rax)
je 0x2a8c9a
movb 0x2(%rax), %al
cmpb 0x55(%rbx), %al
je 0x2a8c61
leaq 0x13667e(%rip), %rsi    # 0x3df31f
leaq 0x136788(%rip), %rdx    # 0x3df430
leaq 0x1364d6(%rip), %r8     # 0x3df185
movl $0xb, %ebp
movl $0xb, %edi
movl $0x10479, %ecx          # imm = 0x10479
xorl %eax, %eax
callq 0x27e637
jmp 0x2a8d08
movq 0x10(%rcx), %rax
cmpl %r15d, 0x4(%rax)
je 0x2a8cf6
movq 0x8(%rcx), %rdx
movq %rdx, 0x50(%rax)
movq %rcx, 0x70(%rax)
movq %r12, 0x48(%rax)
movl %r15d, 0x4(%rax)
xorl %ecx, %ecx
cmpl $0x1, %r15d
movl $0x64, %edx
cmovnel %ecx, %edx
movb %dl, 0x9(%rax)
movq (%r14), %rdi
callq 0x294e54
movl %eax, %ebp
testl %eax, %eax
je 0x2a8c81
movq (%r14), %rax
testq %rax, %rax
je 0x2a8c41
movq 0x70(%rax), %rdi
callq 0x2949b7
jmp 0x2a8c41