// File: /workspace/github_c_makefile_star2_O3/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 %r14
pushq %rbx
movq %rdi, %rbx
movb 0x56(%rdi), %al
cmpb $0x3, %al
jb 0x36793
cmpb $0x4, %al
jne 0x3677e
movl 0x50(%rbx), %r14d
jmp 0x36875
movq 0x40(%rbx), %rdi
callq 0xa630
movq $0x0, 0x40(%rbx)
movb $0x0, 0x56(%rbx)
movb 0x58(%rbx), %al
testb %al, %al
jns 0x367ef
movl 0x48(%rbx), %esi
testl %esi, %esi
je 0x3684f
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x98(%rbx), %rdx
movzbl 0x55(%rbx), %r8d
xorl %ecx, %ecx
callq 0x36926
testl %eax, %eax
je 0x36858
movl %eax, %r14d
jmp 0x36871
leal -0x1(%rax), %ecx
movb %cl, 0x58(%rbx)
movsbq %al, %rax
movq 0x98(%rbx,%rax,8), %rax
movq 0x70(%rax), %rdi
callq 0x24e28
movb 0x58(%rbx), %al
testb %al, %al
jne 0x367cf
movq 0x98(%rbx), %rax
cmpb $0x0, (%rax)
je 0x36828
cmpq $0x0, 0x60(%rbx)
sete %cl
cmpb %cl, 0x2(%rax)
jne 0x36828
xorl %r14d, %r14d
movw %r14w, 0x70(%rbx)
movw %r14w, 0x36(%rbx)
andb $-0xf, 0x54(%rbx)
cmpw %r14w, 0x12(%rax)
je 0x3686b
movb $0x1, 0x56(%rbx)
jmp 0x36875
leaq 0x44cb9(%rip), %rsi     # 0x7b4e8
leaq 0x44957(%rip), %rcx     # 0x7b18d
movl $0xb, %r14d
movl $0xb, %edi
movl $0xea67, %edx           # imm = 0xEA67
xorl %eax, %eax
callq 0xa4c0
jmp 0x36875
movb $0x0, 0x56(%rbx)
xorl %r14d, %r14d
jmp 0x36875
movb $0x0, 0x58(%rbx)
movq 0x98(%rbx), %rax
movb 0x2(%rax), %al
movb %al, 0x59(%rbx)
jmp 0x367f1
cmpb $0x0, 0x5(%rax)
je 0x3687d
movb $0x0, 0x56(%rbx)
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1, 0x88(%rax)
jne 0x368a1
movq 0x50(%rax), %rcx
movzbl 0x6(%rax), %eax
movl 0x8(%rcx,%rax), %esi
bswapl %esi
movb $0x1, 0x56(%rbx)
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x368c1
leaq 0x44c40(%rip), %rsi     # 0x7b4e8
leaq 0x448de(%rip), %rcx     # 0x7b18d
movl $0xb, %r14d
movl $0xb, %edi
movl $0xea72, %edx           # imm = 0xEA72
jmp 0x36846