// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x1, %eax
je 0x4a7fe
movq -0x10(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x3, %eax
jl 0x4a77c
movq -0x10(%rbp), %rdi
callq 0x488c0
movl %eax, -0x2c(%rbp)
jmp 0x4a783
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
jmp 0x4a783
movl -0x2c(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x4a79a
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rax
movzbl 0x56(%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x4a7be
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
je 0x4a7fc
movq -0x10(%rbp), %rax
movb $0x1, 0x56(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x50(%rax)
jle 0x4a7f1
movq -0x10(%rbp), %rax
movl $0x0, 0x50(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rax
movl $0x0, 0x50(%rax)
jmp 0x4a7fe
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movsbq 0x58(%rcx), %rcx
movq 0x98(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rcx
movq -0x10(%rbp), %rax
movsbq 0x58(%rax), %rdx
movw 0x70(%rcx,%rdx,2), %ax
addw $0x1, %ax
movw %ax, 0x70(%rcx,%rdx,2)
movzwl %ax, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x28(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpl %ecx, %eax
jl 0x4a93c
movq -0x28(%rbp), %rax
cmpb $0x0, 0x5(%rax)
jne 0x4a8aa
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rax
movzbl 0x6(%rax), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
callq 0x26b20
movq -0x38(%rbp), %rdi
movl %eax, %esi
callq 0x49040
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x4a899
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rdi
callq 0x4a970
movl %eax, -0x4(%rbp)
jmp 0x4a95b
jmp 0x4a8ac
movq -0x10(%rbp), %rax
movsbl 0x58(%rax), %eax
cmpl $0x0, %eax
jne 0x4a8d7
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x56(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rdi
callq 0x48fe0
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movsbq 0x58(%rcx), %rcx
movq 0x98(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movsbq 0x58(%rcx), %rcx
movzwl 0x70(%rax,%rcx,2), %eax
movq -0x28(%rbp), %rcx
movzwl 0x12(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4a8ac
movq -0x28(%rbp), %rax
cmpb $0x0, 0x2(%rax)
je 0x4a933
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x44a20
movl %eax, -0x4(%rbp)
jmp 0x4a95b
movl $0x0, -0x4(%rbp)
jmp 0x4a95b
movq -0x28(%rbp), %rax
cmpb $0x0, 0x5(%rax)
je 0x4a94f
movl $0x0, -0x4(%rbp)
jmp 0x4a95b
movq -0x10(%rbp), %rdi
callq 0x4a970
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)