// File: /workspace/github_c_makefile_star2_O1/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 0x37367
cmpb $0x4, %al
jne 0x37352
movl 0x50(%rbx), %r14d
jmp 0x37448
movq 0x40(%rbx), %rdi
callq 0xa620
movq $0x0, 0x40(%rbx)
movb $0x0, 0x56(%rbx)
cmpb $0x0, 0x58(%rbx)
jns 0x373bd
movl 0x48(%rbx), %esi
testl %esi, %esi
je 0x37422
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x98(%rbx), %rdx
movzbl 0x55(%rbx), %r8d
xorl %ecx, %ecx
callq 0x374f6
testl %eax, %eax
je 0x3742b
movl %eax, %r14d
jmp 0x37444
leal -0x1(%rax), %ecx
movb %cl, 0x58(%rbx)
movsbq %al, %rax
movq 0x98(%rbx,%rax,8), %rax
movq 0x70(%rax), %rdi
callq 0x25020
movb 0x58(%rbx), %al
testb %al, %al
jne 0x373a2
movq 0x98(%rbx), %rax
cmpb $0x0, (%rax)
je 0x373fb
cmpq $0x0, 0x60(%rbx)
sete %cl
cmpb %cl, 0x2(%rax)
jne 0x373fb
xorl %r14d, %r14d
movw %r14w, 0x70(%rbx)
movw %r14w, 0x36(%rbx)
andb $-0xf, 0x54(%rbx)
cmpw %r14w, 0x12(%rax)
je 0x3743e
movb $0x1, 0x56(%rbx)
jmp 0x37448
leaq 0x460d6(%rip), %rsi     # 0x7d4d8
leaq 0x45d74(%rip), %rcx     # 0x7d17d
movl $0xb, %r14d
movl $0xb, %edi
movl $0xea67, %edx           # imm = 0xEA67
xorl %eax, %eax
callq 0xa4b0
jmp 0x37448
movb $0x0, 0x56(%rbx)
xorl %r14d, %r14d
jmp 0x37448
movb $0x0, 0x58(%rbx)
movq 0x98(%rbx), %rax
movb 0x2(%rax), %al
movb %al, 0x59(%rbx)
jmp 0x373c4
cmpb $0x0, 0x5(%rax)
je 0x37450
movb $0x0, 0x56(%rbx)
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq
cmpl $0x1, 0x88(%rax)
jne 0x37474
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 0x37494
leaq 0x4605d(%rip), %rsi     # 0x7d4d8
leaq 0x45cfb(%rip), %rcx     # 0x7d17d
movl $0xb, %r14d
movl $0xb, %edi
movl $0xea72, %edx           # imm = 0xEA72
jmp 0x37419