// File: /workspace/github_c_makefile_star2_O0/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
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movb $0x0, 0x75(%rax)
movq -0x10(%rbp), %rax
movzbl 0x77(%rax), %eax
cmpl $0x1, %eax
je 0x3cf0d
movq -0x10(%rbp), %rax
movzbl 0x77(%rax), %eax
cmpl $0x3, %eax
jl 0x3ce9f
movq -0x10(%rbp), %rdi
callq 0x40550
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3ce9d
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3d0ac
jmp 0x3ce9f
movq -0x10(%rbp), %rax
movzbl 0x77(%rax), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
jne 0x3cec3
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3d0ac
movq -0x10(%rbp), %rax
cmpl $0x0, 0x70(%rax)
je 0x3cf0b
movq -0x10(%rbp), %rax
movb $0x1, 0x77(%rax)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x70(%rax)
jge 0x3cf00
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3d0ac
movq -0x10(%rbp), %rax
movl $0x0, 0x70(%rax)
jmp 0x3cf0d
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movswq 0x7a(%rcx), %rcx
movq 0xa8(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpb $0x0, 0x3(%rax)
jne 0x3cfd5
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movswq 0x7a(%rcx), %rcx
movzwl 0x7c(%rax,%rcx,2), %eax
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x28(%rbp), %rax
movq 0x50(%rax), %rdi
movq -0x28(%rbp), %rax
movzwl 0x12(%rax), %eax
movq -0x28(%rbp), %rcx
movq 0x60(%rcx), %rcx
movl -0x2c(%rbp), %edx
shll %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
shll $0x8, %ecx
movq -0x28(%rbp), %rdx
movq 0x60(%rdx), %rdx
movl -0x2c(%rbp), %esi
shll %esi
movslq %esi, %rsi
movzbl 0x1(%rdx,%rsi), %edx
orl %edx, %ecx
andl %ecx, %eax
cltq
addq %rax, %rdi
callq 0x20a50
movq -0x38(%rbp), %rdi
movl %eax, %esi
callq 0x40b80
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x3cfc4
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x3d0ac
movq -0x10(%rbp), %rdi
callq 0x41460
movl %eax, -0x1c(%rbp)
jmp 0x3d09c
jmp 0x3cfd7
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movswq 0x7a(%rcx), %rcx
movzwl 0x7c(%rax,%rcx,2), %eax
cmpl $0x0, %eax
jne 0x3d024
movq -0x10(%rbp), %rax
movswl 0x7a(%rax), %eax
cmpl $0x0, %eax
jne 0x3d019
movq -0x10(%rbp), %rax
movb $0x0, 0x77(%rax)
movq -0x18(%rbp), %rax
movl $0x1, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x3d0ac
movq -0x10(%rbp), %rdi
callq 0x40b30
jmp 0x3cfd7
movq -0x10(%rbp), %rax
movw $0x0, 0x5e(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x76(%rax)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movswq 0x7a(%rcx), %rcx
movw 0x7c(%rax,%rcx,2), %dx
addw $-0x1, %dx
movw %dx, 0x7c(%rax,%rcx,2)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movswq 0x7a(%rcx), %rcx
movq 0xa8(%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movzbl 0x2(%rax), %eax
cmpl $0x0, %eax
je 0x3d093
movq -0x28(%rbp), %rax
cmpb $0x0, 0x3(%rax)
jne 0x3d093
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x3ce40
movl %eax, -0x1c(%rbp)
jmp 0x3d09a
movl $0x0, -0x1c(%rbp)
jmp 0x3d09c
movq -0x18(%rbp), %rax
movl $0x0, (%rax)
movl -0x1c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)