// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: sqlite3RowSetTest
SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, u8 iBatch, sqlite3_int64 iRowid){
  struct RowSetEntry *p, *pTree;

  /* This routine is never called after sqlite3RowSetNext() */
  assert( pRowSet!=0 && (pRowSet->rsFlags & ROWSET_NEXT)==0 );

  /* Sort entries into the forest on the first test of a new batch 
  */
  if( iBatch!=pRowSet->iBatch ){
    p = pRowSet->pEntry;
    if( p ){
      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;
      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){
        p = rowSetEntrySort(p);
      }
      for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){
        ppPrevTree = &pTree->pRight;
        if( pTree->pLeft==0 ){
          pTree->pLeft = rowSetListToTree(p);
          break;
        }else{
          struct RowSetEntry *pAux, *pTail;
          rowSetTreeToList(pTree->pLeft, &pAux, &pTail);
          pTree->pLeft = 0;
          p = rowSetEntryMerge(pAux, p);
        }
      }
      if( pTree==0 ){
        *ppPrevTree = pTree = rowSetEntryAlloc(pRowSet);
        if( pTree ){
          pTree->v = 0;
          pTree->pRight = 0;
          pTree->pLeft = rowSetListToTree(p);
        }
      }
      pRowSet->pEntry = 0;
      pRowSet->pLast = 0;
      pRowSet->rsFlags |= ROWSET_SORTED;
    }
    pRowSet->iBatch = iBatch;
  }

  /* Test to see if the iRowid value appears anywhere in the forest.
  ** Return 1 if it does and 0 if not.
  */
  for(pTree = pRowSet->pForest; pTree; pTree=pTree->pRight){
    p = pTree->pLeft;
    while( p ){
      if( p->v<iRowid ){
        p = p->pRight;
      }else if( p->v>iRowid ){
        p = p->pLeft;
      }else{
        return 1;
      }
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
cmpb %sil, 0x33(%rdi)
je 0x2efee
movq 0x10(%rdi), %r12
testq %r12, %r12
je 0x2efea
leaq 0x28(%rdi), %r13
testb $0x1, 0x32(%rdi)
movq %rdi, -0x30(%rbp)
movl %esi, -0x34(%rbp)
jne 0x2ef3c
movq %r12, %rdi
callq 0x34ea8
movq -0x30(%rbp), %rdi
movq %rax, %r12
movq (%r13), %r15
testq %r15, %r15
sete %r14b
je 0x2ef9b
leaq 0x8(%r15), %r13
movq 0x10(%r15), %rdi
addq $0x10, %r15
testq %rdi, %rdi
je 0x2ef8c
leaq -0x40(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x3504f
movq $0x0, (%r15)
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x34f68
movq %rax, %r12
movq (%r13), %r15
testq %r15, %r15
sete %r14b
jne 0x2ef49
jmp 0x2ef97
movq %r12, %rdi
callq 0x34fe6
movq %rax, (%r15)
movq -0x30(%rbp), %rdi
leaq 0x10(%rdi), %rax
testb %r14b, %r14b
je 0x2efdd
movq -0x30(%rbp), %rdi
movq %rax, %r14
callq 0x34e53
movq -0x30(%rbp), %rdi
movq %rax, %r15
movq %r14, %rax
movq %r15, (%r13)
testq %r15, %r15
je 0x2efdd
xorps %xmm0, %xmm0
movups %xmm0, (%r15)
movq %r12, %rdi
callq 0x34fe6
movq -0x30(%rbp), %rdi
movq %rax, 0x10(%r15)
movq %r14, %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
orb $0x1, 0x32(%rdi)
movl -0x34(%rbp), %esi
movb %sil, 0x33(%rdi)
movq 0x28(%rdi), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2f024
movq 0x10(%rcx), %rdx
testq %rdx, %rdx
je 0x2f019
movl $0x8, %esi
cmpq %rbx, (%rdx)
jl 0x2f013
movl $0x10, %esi
jle 0x2f01f
movq (%rdx,%rsi), %rdx
jmp 0x2effd
movq 0x8(%rcx), %rcx
jmp 0x2eff4
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq