// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: btreePrevious
static SQLITE_NOINLINE int btreePrevious(BtCursor *pCur){
  int rc;
  MemPage *pPage;

  assert( cursorOwnsBtShared(pCur) );
  assert( (pCur->curFlags & (BTCF_AtLast|BTCF_ValidOvfl|BTCF_ValidNKey))==0 );
  assert( pCur->info.nSize==0 );
  if( pCur->eState!=CURSOR_VALID ){
    rc = restoreCursorPosition(pCur);
    if( rc!=SQLITE_OK ){
      return rc;
    }
    if( CURSOR_INVALID==pCur->eState ){
      return SQLITE_DONE;
    }
    if( CURSOR_SKIPNEXT==pCur->eState ){
      pCur->eState = CURSOR_VALID;
      if( pCur->skipNext<0 ) return SQLITE_OK;
    }
  }

  pPage = pCur->pPage;
  assert( pPage->isInit );
  if( !pPage->leaf ){
    int idx = pCur->ix;
    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
    if( rc ) return rc;
    rc = moveToRightmost(pCur);
  }else{
    while( pCur->ix==0 ){
      if( pCur->iPage==0 ){
        pCur->eState = CURSOR_INVALID;
        return SQLITE_DONE;
      }
      moveToParent(pCur);
    }
    assert( pCur->info.nSize==0 );
    assert( (pCur->curFlags & (BTCF_ValidOvfl))==0 );

    pCur->ix--;
    pPage = pCur->pPage;
    if( pPage->intKey && !pPage->leaf ){
      rc = sqlite3BtreePrevious(pCur, 0);
    }else{
      rc = SQLITE_OK;
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x0, %eax
je 0x403471
movq -0x10(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x3, %eax
jl 0x403406
movq -0x10(%rbp), %rdi
callq 0x400870
movl %eax, -0x28(%rbp)
jmp 0x40340d
xorl %eax, %eax
movl %eax, -0x28(%rbp)
jmp 0x40340d
movl -0x28(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x403424
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4035a7
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
movl $0x1, %eax
cmpl %ecx, %eax
jne 0x403440
movl $0x65, -0x4(%rbp)
jmp 0x4035a7
movq -0x10(%rbp), %rax
movzbl (%rax), %ecx
movl $0x2, %eax
cmpl %ecx, %eax
jne 0x40346f
movq -0x10(%rbp), %rax
movb $0x0, (%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jge 0x40346d
movl $0x0, -0x4(%rbp)
jmp 0x4035a7
jmp 0x40346f
jmp 0x403471
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, 0x8(%rax)
jne 0x40351b
movq -0x10(%rbp), %rax
movzwl 0x56(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x20(%rbp), %rax
movzwl 0x1a(%rax), %eax
movq -0x20(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x24(%rbp), %edx
shll %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
movq -0x20(%rbp), %rdx
movq 0x60(%rdx), %rdx
movl -0x24(%rbp), %esi
shll %esi
movslq %esi, %rsi
movzbl 0x1(%rdx,%rsi), %edx
orl %edx, %ecx
andl %ecx, %eax
cltq
addq %rax, %rdi
callq 0x3db720
movq -0x30(%rbp), %rdi
movl %eax, %esi
callq 0x401010
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x40350a
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x4035a7
movq -0x10(%rbp), %rdi
callq 0x4021e0
movl %eax, -0x14(%rbp)
jmp 0x4035a1
jmp 0x40351d
movq -0x10(%rbp), %rax
movzwl 0x56(%rax), %eax
cmpl $0x0, %eax
jne 0x403552
movq -0x10(%rbp), %rax
movsbl 0x54(%rax), %eax
cmpl $0x0, %eax
jne 0x403547
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movl $0x65, -0x4(%rbp)
jmp 0x4035a7
movq -0x10(%rbp), %rdi
callq 0x400f80
jmp 0x40351d
movq -0x10(%rbp), %rax
movw 0x56(%rax), %cx
addw $-0x1, %cx
movw %cx, 0x56(%rax)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0x403598
movq -0x20(%rbp), %rax
cmpb $0x0, 0x8(%rax)
jne 0x403598
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x3fbe20
movl %eax, -0x14(%rbp)
jmp 0x40359f
movl $0x0, -0x14(%rbp)
jmp 0x4035a1
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq