// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: moveToRoot
static int moveToRoot(BtCursor *pCur){
  MemPage *pRoot;
  int rc = SQLITE_OK;

  assert( cursorOwnsBtShared(pCur) );
  assert( CURSOR_INVALID < CURSOR_REQUIRESEEK );
  assert( CURSOR_VALID   < CURSOR_REQUIRESEEK );
  assert( CURSOR_FAULT   > CURSOR_REQUIRESEEK );
  assert( pCur->eState < CURSOR_REQUIRESEEK || pCur->iPage<0 );
  assert( pCur->pgnoRoot>0 || pCur->iPage<0 );

  if( pCur->iPage>=0 ){
    if( pCur->iPage ){
      releasePageNotNull(pCur->pPage);
      while( --pCur->iPage ){
        releasePageNotNull(pCur->apPage[pCur->iPage]);
      }
      pCur->pPage = pCur->apPage[0];
      goto skip_init;
    }
  }else if( pCur->pgnoRoot==0 ){
    pCur->eState = CURSOR_INVALID;
    return SQLITE_EMPTY;
  }else{
    assert( pCur->iPage==(-1) );
    if( pCur->eState>=CURSOR_REQUIRESEEK ){
      if( pCur->eState==CURSOR_FAULT ){
        assert( pCur->skipNext!=SQLITE_OK );
        return pCur->skipNext;
      }
      sqlite3BtreeClearCursor(pCur);
    }
    rc = getAndInitPage(pCur->pBtree->pBt, pCur->pgnoRoot, &pCur->pPage,
                        0, pCur->curPagerFlags);
    if( rc!=SQLITE_OK ){
      pCur->eState = CURSOR_INVALID;
      return rc;
    }
    pCur->iPage = 0;
    pCur->curIntKey = pCur->pPage->intKey;
  }
  pRoot = pCur->pPage;
  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_PAGE(pCur->pPage);
  }

skip_init:
  pCur->ix = 0;
  pCur->info.nSize = 0;
  pCur->curFlags &= ~(BTCF_AtLast|BTCF_ValidNKey|BTCF_ValidOvfl);

  pRoot = pCur->pPage;
  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;
    rc = SQLITE_EMPTY;
  }
  return rc;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpb $0x0, 0x54(%rdi)
js 0x2454cc
movq 0x88(%rbx), %rdi
jne 0x245494
jmp 0x24555d
movsbq %al, %rax
movq 0x90(%rbx,%rax,8), %rdi
callq 0x2376cc
movb 0x54(%rbx), %al
decb %al
movb %al, 0x54(%rbx)
jne 0x245488
movq 0x90(%rbx), %rdi
movq %rdi, 0x88(%rbx)
andw $0x0, 0x56(%rbx)
andw $0x0, 0x46(%rbx)
andb $-0xf, 0x1(%rbx)
xorl %eax, %eax
cmpw %ax, 0x18(%rdi)
je 0x2454e2
movb $0x0, (%rbx)
jmp 0x24554a
movl 0x50(%rbx), %esi
testl %esi, %esi
je 0x2454e8
movb (%rbx), %al
cmpb $0x3, %al
jb 0x245528
cmpb $0x4, %al
jne 0x24551d
movl 0x4(%rbx), %eax
jmp 0x24554a
cmpb $0x0, 0x8(%rdi)
je 0x2454f0
movb $0x1, (%rbx)
pushq $0x10
popq %rax
jmp 0x24554a
cmpl $0x1, 0x4(%rdi)
jne 0x245581
movq 0x50(%rdi), %rax
movzbl 0x9(%rdi), %ecx
leaq (%rax,%rcx), %rdi
addq $0x8, %rdi
callq 0x22fc59
movb $0x0, (%rbx)
movq %rbx, %rdi
movl %eax, %esi
popq %rbx
jmp 0x2455c6
movq %rbx, %rdi
callq 0x238672
movl 0x50(%rbx), %esi
movq 0x8(%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x88(%rbx), %rdx
movzbl 0x2(%rbx), %r8d
xorl %ecx, %ecx
callq 0x24561b
testl %eax, %eax
je 0x24554c
movb $0x1, (%rbx)
popq %rbx
retq
movb $0x0, 0x54(%rbx)
movq 0x88(%rbx), %rdi
movb 0x2(%rdi), %al
movb %al, 0x55(%rbx)
cmpb $0x0, (%rdi)
je 0x245576
cmpq $0x0, 0x80(%rbx)
sete %al
cmpb %al, 0x2(%rdi)
je 0x2454b1
movl $0x1105b, %edi          # imm = 0x1105B
popq %rbx
jmp 0x232547
movl $0x11068, %edi          # imm = 0x11068
jmp 0x24557b