// File: /workspace/github_c_makefile_star2_O2/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3BtreePrevious
SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
  int rc;
  MemPage *pPage;

  assert( cursorHoldsMutex(pCur) );
  assert( pRes!=0 );
  assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID );
  pCur->atLast = 0;
  if( pCur->eState!=CURSOR_VALID ){
    if( ALWAYS(pCur->eState>=CURSOR_REQUIRESEEK) ){
      rc = btreeRestoreCursorPosition(pCur);
      if( rc!=SQLITE_OK ){
        *pRes = 0;
        return rc;
      }
    }
    if( CURSOR_INVALID==pCur->eState ){
      *pRes = 1;
      return SQLITE_OK;
    }
    if( pCur->skipNext ){
      assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT );
      pCur->eState = CURSOR_VALID;
      if( pCur->skipNext<0 ){
        pCur->skipNext = 0;
        *pRes = 0;
        return SQLITE_OK;
      }
      pCur->skipNext = 0;
    }
  }

  pPage = pCur->apPage[pCur->iPage];
  assert( pPage->isInit );
  if( !pPage->leaf ){
    int idx = pCur->aiIdx[pCur->iPage];
    rc = moveToChild(pCur, get4byte(findCell(pPage, idx)));
    if( rc ){
      *pRes = 0;
      return rc;
    }
    rc = moveToRightmost(pCur);
  }else{
    while( pCur->aiIdx[pCur->iPage]==0 ){
      if( pCur->iPage==0 ){
        pCur->eState = CURSOR_INVALID;
        *pRes = 1;
        return SQLITE_OK;
      }
      moveToParent(pCur);
    }
    pCur->info.nSize = 0;
    pCur->validNKey = 0;

    pCur->aiIdx[pCur->iPage]--;
    pPage = pCur->apPage[pCur->iPage];
    if( pPage->intKey && !pPage->leaf ){
      rc = sqlite3BtreePrevious(pCur, pRes);
    }else{
      rc = SQLITE_OK;
    }
  }
  *pRes = 0;
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
movb $0x0, 0x75(%rdi)
movb 0x77(%rdi), %al
pushq $0x1
popq %r15
cmpb $0x1, %al
jne 0x2aa97
movzwl 0x7a(%r14), %ecx
movswq %cx, %rdx
movq 0xa8(%r14,%rdx,8), %rax
cmpb $0x0, 0x3(%rax)
je 0x2aab7
movswq %cx, %rax
cmpw $0x0, 0x7c(%r14,%rax,2)
jne 0x2aafc
testw %cx, %cx
je 0x2ab36
movq %r14, %rdi
callq 0x2bcc5
movzwl 0x7a(%r14), %ecx
jmp 0x2aa72
cmpb $0x3, %al
jb 0x2ab41
movq %r14, %rdi
callq 0x2b99e
testl %eax, %eax
je 0x2ab3d
xorl %r15d, %r15d
jmp 0x2ab68
movzwl 0x7c(%r14,%rdx,2), %ecx
movzwl 0x12(%rax), %edx
movq 0x60(%rax), %rsi
movzbl (%rsi,%rcx,2), %r8d
shll $0x8, %r8d
movzbl 0x1(%rsi,%rcx,2), %edi
orl %r8d, %edi
andl %edx, %edi
addq 0x50(%rax), %rdi
callq 0x180a3
movq %r14, %rdi
movl %eax, %esi
callq 0x2bcf4
xorl %r15d, %r15d
testl %eax, %eax
jne 0x2ab68
movq %r14, %rdi
callq 0x2bf3f
jmp 0x2ab68
andw $0x0, 0x5e(%r14)
movb $0x0, 0x76(%r14)
decw 0x7c(%r14,%rax,2)
movswq 0x7a(%r14), %rax
movq 0xa8(%r14,%rax,8), %rax
xorl %r15d, %r15d
cmpb $0x0, 0x2(%rax)
je 0x2ab66
cmpb $0x0, 0x3(%rax)
jne 0x2ab66
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2aa3c
jmp 0x2ab68
movb $0x0, 0x77(%r14)
jmp 0x2ab66
movb 0x77(%r14), %al
testb %al, %al
je 0x2ab66
movl 0x70(%r14), %eax
testl %eax, %eax
je 0x2aa5b
movb $0x1, 0x77(%r14)
andl $0x0, 0x70(%r14)
testl %eax, %eax
jns 0x2aa5b
xorl %r15d, %r15d
xorl %eax, %eax
movl %r15d, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq