// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: btreeNext
static SQLITE_NOINLINE int btreeNext(BtCursor *pCur, int *pRes){
  int rc;
  int idx;
  MemPage *pPage;

  assert( cursorHoldsMutex(pCur) );
  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
  assert( *pRes==0 );
  if( pCur->eState!=CURSOR_VALID ){
    assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
    rc = restoreCursorPosition(pCur);
    if( rc!=SQLITE_OK ){
      return rc;
    }
    if( CURSOR_INVALID==pCur->eState ){
      *pRes = 1;
      return SQLITE_OK;
    }
    if( pCur->skipNext ){
      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
      pCur->eState = CURSOR_VALID;
      if( pCur->skipNext>0 ){
        pCur->skipNext = 0;
        return SQLITE_OK;
      }
      pCur->skipNext = 0;
    }
  }

  pPage = pCur->apPage[pCur->iPage];
  idx = ++pCur->aiIdx[pCur->iPage];
  assert( pPage->isInit );

  /* If the database file is corrupt, it is possible for the value of idx 
  ** to be invalid here. This can only occur if a second cursor modifies
  ** the page while cursor pCur is holding a reference to it. Which can
  ** only happen if the database is corrupt in such a way as to link the
  ** page into more than one b-tree structure. */
  testcase( idx>pPage->nCell );

  if( idx>=pPage->nCell ){
    if( !pPage->leaf ){
      rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8]));
      if( rc ) return rc;
      return moveToLeftmost(pCur);
    }
    do{
      if( pCur->iPage==0 ){
        *pRes = 1;
        pCur->eState = CURSOR_INVALID;
        return SQLITE_OK;
      }
      moveToParent(pCur);
      pPage = pCur->apPage[pCur->iPage];
    }while( pCur->aiIdx[pCur->iPage]>=pPage->nCell );
    if( pPage->intKey ){
      return sqlite3BtreeNext(pCur, pRes);
    }else{
      return SQLITE_OK;
    }
  }
  if( pPage->leaf ){
    return SQLITE_OK;
  }else{
    return moveToLeftmost(pCur);
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movb 0x56(%rdi), %al
cmpb $0x1, %al
jne 0x3193a
movsbq 0x58(%rbx), %rax
movq 0x98(%rbx,%rax,8), %rcx
movzwl 0x70(%rbx,%rax,2), %esi
incl %esi
movw %si, 0x70(%rbx,%rax,2)
movb 0x5(%rcx), %dl
cmpw 0x12(%rcx), %si
jae 0x3196a
testb %dl, %dl
jne 0x319e7
jmp 0x319d3
cmpb $0x3, %al
jb 0x31951
movq %rbx, %rdi
callq 0x30c27
testl %eax, %eax
jne 0x319e9
movb 0x56(%rbx), %al
testb %al, %al
je 0x319a7
movl 0x50(%rbx), %eax
testl %eax, %eax
je 0x3190b
movb $0x1, 0x56(%rbx)
andl $0x0, 0x50(%rbx)
testl %eax, %eax
jg 0x319e7
jmp 0x3190b
testb %dl, %dl
je 0x319b0
testb %al, %al
je 0x319dc
movq %rbx, %rdi
callq 0x30fd4
movsbq 0x58(%rbx), %rax
movq 0x98(%rbx,%rax,8), %rcx
movzwl 0x70(%rbx,%rax,2), %edx
cmpw 0x12(%rcx), %dx
jae 0x3196e
cmpb $0x0, 0x2(%rcx)
je 0x319e7
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x2fa7a
movl $0x1, (%r14)
jmp 0x319e7
movq 0x50(%rcx), %rax
movzbl 0x6(%rcx), %ecx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
callq 0x1c9e4
movq %rbx, %rdi
movl %eax, %esi
callq 0x30ffa
testl %eax, %eax
jne 0x319e9
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x319ee
movl $0x1, (%r14)
movb $0x0, 0x56(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq