// File: /workspace/github_c_makefile_star2_O3/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
cmpb $0x1, %al
jne 0x2dcbc
movzwl 0x7a(%r14), %eax
movswq %ax, %rcx
movq 0xa8(%r14,%rcx,8), %rsi
cmpb $0x0, 0x3(%rsi)
movzwl 0x7c(%r14,%rcx,2), %edx
je 0x2dcd1
testq %rdx, %rdx
je 0x2dcb0
movw $0x0, 0x5e(%r14)
movb $0x0, 0x76(%r14)
decw 0x7c(%r14,%rcx,2)
movswq 0x7a(%r14), %rax
movq 0xa8(%r14,%rax,8), %rax
xorl %r15d, %r15d
cmpb $0x0, 0x2(%rax)
je 0x2dd35
cmpb $0x0, 0x3(%rax)
jne 0x2dd35
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2dc0b
jmp 0x2dd41
movq %r14, %rdi
callq 0x30ae3
movzwl 0x7a(%r14), %eax
movswq %ax, %rcx
cmpw $0x0, 0x7c(%r14,%rcx,2)
jne 0x2dc50
testw %ax, %ax
jne 0x2dc96
movb $0x0, 0x77(%r14)
jmp 0x2dd39
cmpb $0x3, %al
jb 0x2dd0f
movq %r14, %rdi
callq 0x30735
testl %eax, %eax
je 0x2dd0b
xorl %r15d, %r15d
jmp 0x2dd41
movzwl 0x12(%rsi), %eax
movq 0x50(%rsi), %rcx
movq 0x60(%rsi), %rsi
movzbl (%rsi,%rdx,2), %edi
shll $0x8, %edi
movzbl 0x1(%rsi,%rdx,2), %edx
orl %edi, %edx
andl %eax, %edx
movl (%rcx,%rdx), %esi
bswapl %esi
movq %r14, %rdi
callq 0x30b22
xorl %r15d, %r15d
testl %eax, %eax
jne 0x2dd41
movq %r14, %rdi
callq 0x30dbb
jmp 0x2dd41
movb 0x77(%r14), %al
testb %al, %al
je 0x2dd39
movl 0x70(%r14), %eax
testl %eax, %eax
je 0x2dc2a
movb $0x1, 0x77(%r14)
movl $0x0, 0x70(%r14)
jns 0x2dc2a
xorl %r15d, %r15d
xorl %eax, %eax
jmp 0x2dd41
xorl %eax, %eax
movl $0x1, %r15d
movl %r15d, (%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq