// File: /workspace/github_c_makefile_star2_O2/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: moveToRoot
static int moveToRoot(BtCursor *pCur){
  MemPage *pRoot;
  int rc = SQLITE_OK;

  assert( cursorHoldsMutex(pCur) );
  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );
  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );
  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );
  if( pCur->eState>=CURSOR_REQUIRESEEK ){
    if( pCur->eState==CURSOR_FAULT ){
      assert( pCur->skipNext!=SQLITE_OK );
      return pCur->skipNext;
    }
    sqlite3BtreeClearCursor(pCur);
  }

  if( pCur->iPage>=0 ){
    while( pCur->iPage ){
      assert( pCur->apPage[pCur->iPage]!=0 );
      releasePageNotNull(pCur->apPage[pCur->iPage--]);
    }
  }else if( pCur->pgnoRoot==0 ){
    pCur->eState = CURSOR_INVALID;
    return SQLITE_OK;
  }else{
    assert( pCur->iPage==(-1) );
    rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->apPage[0],
                        0, pCur->curPagerFlags);
    if( rc!=SQLITE_OK ){
      pCur->eState = CURSOR_INVALID;
      return rc;
    }
    pCur->iPage = 0;
    pCur->curIntKey = pCur->apPage[0]->intKey;
  }
  pRoot = pCur->apPage[0];
  assert( pRoot->pgno==pCur->pgnoRoot );

  /* If pCur->pKeyInfo is not NULL, then the caller that opened this cursor
  ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
  ** NULL, the caller expects a table b-tree. If this is not the case,
  ** return an SQLITE_CORRUPT error. 
  **
  ** Earlier versions of SQLite assumed that this test could not fail
  ** if the root page was already loaded when this function was called (i.e.
  ** if pCur->iPage>=0). But this is not so if the database is corrupted 
  ** in such a way that page pRoot is linked into a second b-tree table 
  ** (or the freelist).  */
  assert( pRoot->intKey==1 || pRoot->intKey==0 );
  if( pRoot->isInit==0 || (pCur->pKeyInfo==0)!=pRoot->intKey ){
    return SQLITE_CORRUPT_BKPT;
  }

  pCur->aiIdx[0] = 0;
  pCur->info.nSize = 0;
  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);

  if( pRoot->nCell>0 ){
    pCur->eState = CURSOR_VALID;
  }else if( !pRoot->leaf ){
    Pgno subpage;
    if( pRoot->pgno!=1 ) return SQLITE_CORRUPT_BKPT;
    subpage = get4byte(&pRoot->aData[pRoot->hdrOffset+8]);
    pCur->eState = CURSOR_VALID;
    rc = moveToChild(pCur, subpage);
  }else{
    pCur->eState = CURSOR_INVALID;
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movb 0x56(%rdi), %al
cmpb $0x3, %al
jb 0x30edf
cmpb $0x4, %al
jne 0x30ed7
movl 0x50(%rbx), %eax
jmp 0x30f94
movq %rbx, %rdi
callq 0x24b32
movb 0x58(%rbx), %al
testb %al, %al
js 0x30f4a
testb %al, %al
je 0x30f06
leal -0x1(%rax), %ecx
movb %cl, 0x58(%rbx)
movsbq %al, %rax
movq 0x98(%rbx,%rax,8), %rdi
callq 0x22b9c
movb 0x58(%rbx), %al
jmp 0x30ee6
movq 0x98(%rbx), %rcx
cmpb $0x0, (%rcx)
je 0x30f3b
cmpq $0x0, 0x60(%rbx)
sete %al
cmpb %al, 0x2(%rcx)
jne 0x30f3b
andw $0x0, 0x70(%rbx)
andw $0x0, 0x36(%rbx)
andb $-0xf, 0x54(%rbx)
xorl %eax, %eax
cmpw %ax, 0x12(%rcx)
je 0x30f8a
movb $0x1, 0x56(%rbx)
jmp 0x30f94
movl $0xea67, %edi           # imm = 0xEA67
callq 0x1ec07
pushq $0xb
popq %rax
jmp 0x30f94
movl 0x48(%rbx), %esi
testl %esi, %esi
je 0x30f82
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x98(%rbx), %rdx
movzbl 0x55(%rbx), %r8d
xorl %ecx, %ecx
callq 0x31047
testl %eax, %eax
jne 0x30f90
movb $0x0, 0x58(%rbx)
movq 0x98(%rbx), %rcx
movb 0x2(%rcx), %al
movb %al, 0x59(%rbx)
jmp 0x30f0d
movb $0x0, 0x56(%rbx)
xorl %eax, %eax
jmp 0x30f94
cmpb $0x0, 0x5(%rcx)
je 0x30f9b
movb $0x0, 0x56(%rbx)
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
cmpl $0x1, 0x88(%rcx)
jne 0x30fca
movq 0x50(%rcx), %rax
movzbl 0x6(%rcx), %ecx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
callq 0x1c9e4
movb $0x1, 0x56(%rbx)
movq %rbx, %rdi
movl %eax, %esi
addq $0x8, %rsp
popq %rbx
popq %rbp
jmp 0x30ffa
movl $0xea72, %edi           # imm = 0xEA72
jmp 0x30f40