// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rdx, %rbx
movq %rdi, %r14
cmpl %esi, 0x34(%rdi)
je 0x29e263
movq 0x10(%r14), %r15
testq %r15, %r15
je 0x29e25f
leaq 0x28(%r14), %rbp
testb $0x1, 0x32(%r14)
movl %esi, 0x4(%rsp)
jne 0x29e17f
movq %r15, %rdi
callq 0x2a72c9
movq %rax, %r15
leaq 0x10(%r14), %rax
movq (%rbp), %r13
testq %r13, %r13
movq %rax, 0x8(%rsp)
je 0x29e216
leaq 0x20(%rsp), %r12
movq 0x10(%r13), %rdi
testq %rdi, %rdi
je 0x29e23f
leaq 0x8(%r13), %rbp
leaq 0x10(%rsp), %rsi
leaq 0x18(%rsp), %rdx
callq 0x2a746b
movq $0x0, 0x10(%r13)
movq 0x10(%rsp), %rax
movq %r12, %rcx
movq (%rax), %rdx
movq %r15, %rsi
movq %rsi, %r15
cmpq (%rsi), %rdx
jle 0x29e1ea
movq %r15, 0x8(%rcx)
movq 0x8(%r15), %rsi
movq %r15, %rcx
testq %rsi, %rsi
jne 0x29e1d0
jmp 0x29e1fe
jge 0x29e1f3
movq %rax, 0x8(%rcx)
movq %rax, %rcx
movq 0x8(%rax), %rax
testq %rax, %rax
jne 0x29e1ca
jmp 0x29e204
movq %r15, %rcx
movq %rax, %r15
movq %r15, 0x8(%rcx)
movq 0x28(%rsp), %r15
movq (%rbp), %r13
testq %r13, %r13
jne 0x29e19a
movq %r14, %rdi
callq 0x2a727e
movq %rax, (%rbp)
testq %rax, %rax
je 0x29e24b
movq %rax, %r12
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %r15, %rdi
callq 0x2a7409
movq %rax, 0x10(%r12)
jmp 0x29e24b
movq %r15, %rdi
callq 0x2a7409
movq %rax, 0x10(%r13)
xorps %xmm0, %xmm0
movq 0x8(%rsp), %rax
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 0x29e299
movq 0x10(%rcx), %rdx
testq %rdx, %rdx
je 0x29e28e
movl $0x8, %esi
cmpq %rbx, (%rdx)
jl 0x29e288
movl $0x10, %esi
jle 0x29e294
movq (%rdx,%rsi), %rdx
jmp 0x29e272
movq 0x8(%rcx), %rcx
jmp 0x29e269
movl $0x1, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq