// File: /workspace/github_c_makefile_star2_O3/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 0x29f3df
leaq 0x136812(%rip), %rsi    # 0x3d5bcb
leaq 0x13691c(%rip), %rdx    # 0x3d5cdc
leaq 0x13666a(%rip), %r8     # 0x3d5a31
movl $0xb, %ebp
movl $0xb, %edi
movl $0x10464, %ecx          # imm = 0x10464
xorl %eax, %eax
callq 0x274d08
jmp 0x29f3ff
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 0x29f42e
testq %rbx, %rbx
je 0x29f41f
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), %rax
movq 0x10(%rax), %rdi
movq %rdi, (%r14)
cmpb $0x0, (%rdi)
je 0x29f485
xorl %ebp, %ebp
testq %rbx, %rbx
je 0x29f41f
movq (%r14), %rax
cmpw $0x0, 0x18(%rax)
je 0x29f458
movb 0x2(%rax), %al
cmpb 0x55(%rbx), %al
je 0x29f41f
leaq 0x13676c(%rip), %rsi    # 0x3d5bcb
leaq 0x136876(%rip), %rdx    # 0x3d5cdc
leaq 0x1365c4(%rip), %r8     # 0x3d5a31
movl $0xb, %ebp
movl $0xb, %edi
movl $0x10479, %ecx          # imm = 0x10479
xorl %eax, %eax
callq 0x274d08
jmp 0x29f4be
cmpl %r15d, 0x4(%rdi)
je 0x29f4b3
movq 0x8(%rax), %rcx
movq %rcx, 0x50(%rdi)
movq %rax, 0x70(%rdi)
movq %r12, 0x48(%rdi)
movl %r15d, 0x4(%rdi)
xorl %eax, %eax
cmpl $0x1, %r15d
movl $0x64, %ecx
cmovnel %eax, %ecx
movb %cl, 0x9(%rdi)
movq (%r14), %rdi
callq 0x28b010
movl %eax, %ebp
testl %eax, %eax
je 0x29f43f
movq (%r14), %rax
testq %rax, %rax
je 0x29f3ff
movq 0x70(%rax), %rdi
callq 0x28ab87
jmp 0x29f3ff