// File: /workspace/github_c_makefile_star2_O1/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: sqlite3RowSetTest
SQLITE_PRIVATE int sqlite3RowSetTest(RowSet *pRowSet, int 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.
  ** To save unnecessary work, only do this when the batch number changes.
  */
  if( iBatch!=pRowSet->iBatch ){  /*OPTIMIZATION-IF-FALSE*/
    p = pRowSet->pEntry;
    if( p ){
      struct RowSetEntry **ppPrevTree = &pRowSet->pForest;
      if( (pRowSet->rsFlags & ROWSET_SORTED)==0 ){ /*OPTIMIZATION-IF-FALSE*/
        /* Only sort the current set of entries if they need it */
        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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %rbx
movq %rdi, %r14
cmpl %esi, 0x34(%rdi)
je 0x2a7a60
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x2a7a5c
movl %esi, 0x4(%rsp)
leaq 0x28(%r14), %rbp
testb $0x1, 0x32(%r14)
jne 0x2a79c0
movq %r15, %rdi
callq 0x2b0eb7
movq %rax, %r15
movq (%rbp), %r12
testq %r12, %r12
sete %r13b
je 0x2a7a12
leaq 0x8(%r12), %rbp
movq 0x10(%r12), %rdi
addq $0x10, %r12
testq %rdi, %rdi
je 0x2a7a06
leaq 0x8(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x2b1024
movq $0x0, (%r12)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
callq 0x2b0f6f
jmp 0x2a79bd
movq %r15, %rdi
callq 0x2b0fb8
movq %rax, (%r12)
leaq 0x10(%r14), %rax
testb %r13b, %r13b
je 0x2a7a4d
movq %r14, %rdi
movq %rax, %r13
callq 0x2b0e6c
movq %rax, %r12
movq %r13, %rax
movq %r12, (%rbp)
testq %r12, %r12
je 0x2a7a4d
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movq %r15, %rdi
callq 0x2b0fb8
movq %rax, 0x10(%r12)
movq %r13, %rax
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
orb $0x1, 0x32(%r14)
movl 0x4(%rsp), %esi
movl %esi, 0x34(%r14)
movq 0x28(%r14), %rcx
xorl %eax, %eax
testq %rcx, %rcx
je 0x2a7a96
movq 0x10(%rcx), %rdx
testq %rdx, %rdx
je 0x2a7a8b
movl $0x8, %esi
cmpq %rbx, (%rdx)
jl 0x2a7a85
movl $0x10, %esi
jle 0x2a7a91
movq (%rdx,%rsi), %rdx
jmp 0x2a7a6f
movq 0x8(%rcx), %rcx
jmp 0x2a7a66
movl $0x1, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq