// File: /workspace/github_c_makefile_star2_O3/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 0x3739d
movsbq 0x58(%rbx), %rcx
movq 0x98(%rbx,%rcx,8), %rax
movzwl 0x70(%rbx,%rcx,2), %esi
incl %esi
movw %si, 0x70(%rbx,%rcx,2)
movb 0x5(%rax), %dl
cmpw 0x12(%rax), %si
jae 0x373d2
testb %dl, %dl
jne 0x37456
jmp 0x37442
cmpb $0x3, %al
jb 0x373b4
movq %rbx, %rdi
callq 0x3646f
testl %eax, %eax
jne 0x37458
movb 0x56(%rbx), %al
testb %al, %al
je 0x3741f
movl 0x50(%rbx), %eax
testl %eax, %eax
je 0x3736e
movb $0x1, 0x56(%rbx)
movl $0x0, 0x50(%rbx)
jg 0x37456
jmp 0x3736e
testb %dl, %dl
je 0x37428
testb %cl, %cl
je 0x3744b
movw $0x0, 0x36(%rbx)
andb $-0x7, 0x54(%rbx)
decb %cl
movb %cl, 0x58(%rbx)
movq 0x70(%rax), %rdi
callq 0x24e28
movsbq 0x58(%rbx), %rcx
movq 0x98(%rbx,%rcx,8), %rax
movzwl 0x70(%rbx,%rcx,2), %edx
cmpw 0x12(%rax), %dx
jae 0x373d6
cmpb $0x0, 0x2(%rax)
je 0x37456
movq %rbx, %rdi
movq %r14, %rsi
popq %rbx
popq %r14
popq %rbp
jmp 0x33270
movl $0x1, (%r14)
jmp 0x37456
movq 0x50(%rax), %rcx
movzbl 0x6(%rax), %eax
movl 0x8(%rcx,%rax), %esi
bswapl %esi
movq %rbx, %rdi
callq 0x368c1
testl %eax, %eax
jne 0x37458
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x3745d
movl $0x1, (%r14)
movb $0x0, 0x56(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq