// File: /workspace/github_c_makefile_star2_O3/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
movq %rdi, %r14
cmpb %sil, 0x33(%rdi)
je 0x2f86c
movq 0x10(%r14), %r12
testq %r12, %r12
je 0x2f868
leaq 0x28(%r14), %r13
testb $0x1, 0x32(%r14)
movl %esi, -0x2c(%rbp)
jne 0x2f7d1
movq %r12, %rdi
callq 0x355ed
movq %rax, %r12
leaq 0x10(%r14), %rax
movq %rax, -0x38(%rbp)
movq (%r13), %rax
testq %rax, %rax
je 0x2f822
leaq -0x48(%rbp), %r15
movq %rax, %r13
movq 0x10(%rax), %rdi
testq %rdi, %rdi
je 0x2f84a
leaq -0x40(%rbp), %rsi
movq %r15, %rdx
callq 0x35790
movq $0x0, 0x10(%r13)
movq -0x40(%rbp), %rdi
movq %r12, %rsi
callq 0x356b1
movq %rax, %r12
movq 0x8(%r13), %rax
testq %rax, %rax
jne 0x2f7e6
addq $0x8, %r13
movq %r14, %rdi
callq 0x35598
movq %rax, (%r13)
testq %rax, %rax
je 0x2f856
movq %rax, %r15
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r12, %rdi
callq 0x3572f
movq %rax, 0x10(%r15)
jmp 0x2f856
movq %r12, %rdi
callq 0x3572f
movq %rax, 0x10(%r13)
xorps %xmm0, %xmm0
movq -0x38(%rbp), %rax
movups %xmm0, (%rax)
orb $0x1, 0x32(%r14)
movl -0x2c(%rbp), %esi
movb %sil, 0x33(%r14)
movq 0x28(%r14), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2f8a2
movq 0x10(%rcx), %rdx
testq %rdx, %rdx
je 0x2f897
movl $0x8, %esi
cmpq %rbx, (%rdx)
jl 0x2f891
movl $0x10, %esi
jle 0x2f89d
movq (%rdx,%rsi), %rdx
jmp 0x2f87b
movq 0x8(%rcx), %rcx
jmp 0x2f872
movl $0x1, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq