// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x3c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x3e7da0
movl %eax, %ecx
movl -0x3c(%rbp), %eax
cmpl %ecx, %eax
jbe 0x401135
movl $0x10464, %edi          # imm = 0x10464
callq 0x3dff80
movl %eax, -0x30(%rbp)
jmp 0x4011f6
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movl -0x14(%rbp), %esi
movl -0x2c(%rbp), %ecx
leaq -0x38(%rbp), %rdx
callq 0x3c6020
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x401159
jmp 0x4011f6
movq -0x38(%rbp), %rdi
callq 0x3e40f0
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq (%rax), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
jne 0x4011a4
movq -0x38(%rbp), %rdi
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rdx
callq 0x3e75b0
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x3e4130
movl %eax, -0x30(%rbp)
cmpl $0x0, -0x30(%rbp)
je 0x4011a2
jmp 0x4011ea
jmp 0x4011a4
cmpq $0x0, -0x28(%rbp)
je 0x4011e1
movq -0x20(%rbp), %rax
movq (%rax), %rax
movzwl 0x18(%rax), %eax
cmpl $0x1, %eax
jl 0x4011d2
movq -0x20(%rbp), %rax
movq (%rax), %rax
movzbl 0x2(%rax), %eax
movq -0x28(%rbp), %rcx
movzbl 0x55(%rcx), %ecx
cmpl %ecx, %eax
je 0x4011e1
movl $0x10479, %edi          # imm = 0x10479
callq 0x3dff80
movl %eax, -0x30(%rbp)
jmp 0x4011ea
movl $0x0, -0x4(%rbp)
jmp 0x401230
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x3e9b70
cmpq $0x0, -0x28(%rbp)
je 0x40122a
movq -0x28(%rbp), %rax
movb 0x54(%rax), %cl
addb $-0x1, %cl
movb %cl, 0x54(%rax)
movq -0x28(%rbp), %rax
movq -0x28(%rbp), %rcx
movsbq 0x54(%rcx), %rcx
movq 0x90(%rax,%rcx,8), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x88(%rax)
movl -0x30(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)