// File: /workspace/github_c_makefile_star2_O0/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
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x3, %eax
jl 0x48e15
movq -0x10(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x4, %eax
jne 0x48e0c
movq -0x10(%rbp), %rax
movl 0x50(%rax), %eax
movl %eax, -0x4(%rbp)
jmp 0x48fd6
movq -0x10(%rbp), %rdi
callq 0x35280
movq -0x10(%rbp), %rax
movsbl 0x58(%rax), %eax
cmpl $0x0, %eax
jl 0x48e5c
jmp 0x48e24
movq -0x10(%rbp), %rax
cmpb $0x0, 0x58(%rax)
je 0x48e57
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rdx
movb 0x58(%rdx), %cl
movb %cl, %sil
addb $-0x1, %sil
movb %sil, 0x58(%rdx)
movsbq %cl, %rcx
movq 0x98(%rax,%rcx,8), %rdi
callq 0x316f0
jmp 0x48e24
jmp 0x48ee4
movq -0x10(%rbp), %rax
cmpl $0x0, 0x48(%rax)
jne 0x48e7a
movq -0x10(%rbp), %rax
movb $0x0, 0x56(%rax)
movl $0x0, -0x4(%rbp)
jmp 0x48fd6
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rdi
movq -0x10(%rbp), %rax
movl 0x48(%rax), %esi
movq -0x10(%rbp), %rdx
addq $0x98, %rdx
movq -0x10(%rbp), %rax
movzbl 0x55(%rax), %r8d
xorl %eax, %eax
movl %eax, %ecx
callq 0x490f0
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x48ec5
movq -0x10(%rbp), %rax
movb $0x0, 0x56(%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x48fd6
movq -0x10(%rbp), %rax
movb $0x0, 0x58(%rax)
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movb 0x2(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x59(%rax)
jmp 0x48ee4
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x48f1c
movq -0x10(%rbp), %rax
cmpq $0x0, 0x60(%rax)
sete %al
andb $0x1, %al
movzbl %al, %eax
movq -0x18(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
je 0x48f2e
movl $0xea67, %edi           # imm = 0xEA67
callq 0x2a650
movl %eax, -0x4(%rbp)
jmp 0x48fd6
movq -0x10(%rbp), %rax
movw $0x0, 0x70(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x36(%rax)
movq -0x10(%rbp), %rax
movzbl 0x54(%rax), %ecx
andl $-0xf, %ecx
movb %cl, 0x54(%rax)
movq -0x18(%rbp), %rax
movzwl 0x12(%rax), %eax
cmpl $0x0, %eax
jle 0x48f67
movq -0x10(%rbp), %rax
movb $0x1, 0x56(%rax)
jmp 0x48fd0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x5(%rax)
jne 0x48fc6
movq -0x18(%rbp), %rax
cmpl $0x1, 0x88(%rax)
je 0x48f8d
movl $0xea72, %edi           # imm = 0xEA72
callq 0x2a650
movl %eax, -0x4(%rbp)
jmp 0x48fd6
movq -0x18(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x18(%rbp), %rax
movzbl 0x6(%rax), %eax
addl $0x8, %eax
cltq
addq %rax, %rdi
callq 0x26b20
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movb $0x1, 0x56(%rax)
movq -0x10(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x49040
movl %eax, -0x1c(%rbp)
jmp 0x48fce
movq -0x10(%rbp), %rax
movb $0x0, 0x56(%rax)
jmp 0x48fd0
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nop