// File: /workspace/github_c_makefile_star2_O1/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), %cl
cmpb $0x1, %cl
jne 0x38078
movsbq 0x58(%rbx), %rcx
movq 0x98(%rbx,%rcx,8), %rax
movzwl 0x70(%rbx,%rcx,2), %edx
incl %edx
movw %dx, 0x70(%rbx,%rcx,2)
movb 0x5(%rax), %cl
cmpw 0x12(%rax), %dx
jae 0x380b3
testb %cl, %cl
jne 0x38146
jmp 0x38129
xorl %eax, %eax
cmpb $0x3, %cl
jb 0x38087
movq %rbx, %rdi
callq 0x3704a
testl %eax, %eax
jne 0x38148
cmpb $0x0, 0x56(%rbx)
je 0x3813f
movl 0x50(%rbx), %eax
testl %eax, %eax
je 0x38049
movb $0x1, 0x56(%rbx)
movl $0x0, 0x50(%rbx)
jg 0x38146
jmp 0x38049
testb %cl, %cl
je 0x3810f
movsbq 0x58(%rbx), %rax
testq %rax, %rax
je 0x38132
movw $0x0, 0x36(%rbx)
andb $-0x7, 0x54(%rbx)
leal -0x1(%rax), %ecx
movb %cl, 0x58(%rbx)
movq 0x98(%rbx,%rax,8), %rax
movq 0x70(%rax), %rdi
callq 0x25020
movsbq 0x58(%rbx), %rcx
movq 0x98(%rbx,%rcx,8), %rax
movzwl 0x70(%rbx,%rcx,2), %ecx
cmpw 0x12(%rax), %cx
jae 0x380b7
cmpb $0x0, 0x2(%rax)
je 0x38146
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x33e9a
movq 0x50(%rax), %rcx
movzbl 0x6(%rax), %eax
movl 0x8(%rcx,%rax), %esi
bswapl %esi
movq %rbx, %rdi
callq 0x37494
testl %eax, %eax
jne 0x38148
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x3814d
movl $0x1, (%r14)
movb $0x0, 0x56(%rbx)
jmp 0x38146
movl $0x1, (%r14)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq