// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: whereScanNext
static WhereTerm *whereScanNext(WhereScan *pScan){
  int iCur;            /* The cursor on the LHS of the term */
  i16 iColumn;         /* The column on the LHS of the term.  -1 for IPK */
  Expr *pX;            /* An expression being tested */
  WhereClause *pWC;    /* Shorthand for pScan->pWC */
  WhereTerm *pTerm;    /* The term being tested */
  int k = pScan->k;    /* Where to start scanning */

  assert( pScan->iEquiv<=pScan->nEquiv );
  pWC = pScan->pWC;
  while(1){
    iColumn = pScan->aiColumn[pScan->iEquiv-1];
    iCur = pScan->aiCur[pScan->iEquiv-1];
    assert( pWC!=0 );
    do{
      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
        if( pTerm->leftCursor==iCur
         && pTerm->u.leftColumn==iColumn
         && (iColumn!=XN_EXPR
             || sqlite3ExprCompareSkip(pTerm->pExpr->pLeft,
                                       pScan->pIdxExpr,iCur)==0)
         && (pScan->iEquiv<=1 || !ExprHasProperty(pTerm->pExpr, EP_FromJoin))
        ){
          if( (pTerm->eOperator & WO_EQUIV)!=0
           && pScan->nEquiv<ArraySize(pScan->aiCur)
           && (pX = sqlite3ExprSkipCollateAndLikely(pTerm->pExpr->pRight))->op
               ==TK_COLUMN
          ){
            int j;
            for(j=0; j<pScan->nEquiv; j++){
              if( pScan->aiCur[j]==pX->iTable
               && pScan->aiColumn[j]==pX->iColumn ){
                  break;
              }
            }
            if( j==pScan->nEquiv ){
              pScan->aiCur[j] = pX->iTable;
              pScan->aiColumn[j] = pX->iColumn;
              pScan->nEquiv++;
            }
          }
          if( (pTerm->eOperator & pScan->opMask)!=0 ){
            /* Verify the affinity and collating sequence match */
            if( pScan->zCollName && (pTerm->eOperator & WO_ISNULL)==0 ){
              CollSeq *pColl;
              Parse *pParse = pWC->pWInfo->pParse;
              pX = pTerm->pExpr;
              if( !sqlite3IndexAffinityOk(pX, pScan->idxaff) ){
                continue;
              }
              assert(pX->pLeft);
              pColl = sqlite3ExprCompareCollSeq(pParse, pX);
              if( pColl==0 ) pColl = pParse->db->pDfltColl;
              if( sqlite3StrICmp(pColl->zName, pScan->zCollName) ){
                continue;
              }
            }
            if( (pTerm->eOperator & (WO_EQ|WO_IS))!=0
             && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
             && pX->iTable==pScan->aiCur[0]
             && pX->iColumn==pScan->aiColumn[0]
            ){
              testcase( pTerm->eOperator & WO_IS );
              continue;
            }
            pScan->pWC = pWC;
            pScan->k = k+1;
            return pTerm;
          }
        }
      }
      pWC = pWC->pOuter;
      k = 0;
    }while( pWC!=0 );
    if( pScan->iEquiv>=pScan->nEquiv ) break;
    pWC = pScan->pOrigWC;
    k = 0;
    pScan->iEquiv++;
  }
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x28(%rdi), %r15d
movq 0x8(%rdi), %r13
movb 0x22(%rdi), %al
movzbl %al, %eax
movswl 0x56(%rbx,%rax,2), %r9d
movl 0x28(%rbx,%rax,4), %ebp
movl %r9d, 0xc(%rsp)
cmpl 0x14(%r13), %r15d
jge 0x2d9ea5
movslq %r15d, %r14
shlq $0x6, %r14
addq 0x20(%r13), %r14
cmpl %ebp, 0x1c(%r14)
jne 0x2d9e94
cmpl %r9d, 0x28(%r14)
jne 0x2d9e94
cmpw $-0x2, %r9w
jne 0x2d9d10
movq (%r14), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbx), %rsi
movl %ebp, %edx
callq 0x2d9af8
movl 0xc(%rsp), %r9d
testl %eax, %eax
jne 0x2d9e94
cmpb $0x2, 0x22(%rbx)
jb 0x2d9d23
movq (%r14), %rax
testb $0x1, 0x4(%rax)
jne 0x2d9e94
movl 0x14(%r14), %eax
btl $0xb, %eax
jae 0x2d9db4
movzbl 0x21(%rbx), %ecx
cmpl $0xa, %ecx
ja 0x2d9db4
movq (%r14), %rdx
movq 0x18(%rdx), %rdx
movl 0x4(%rdx), %esi
testl $0x41000, %esi          # imm = 0x41000
je 0x2d9d65
btl $0x12, %esi
jb 0x2d9d58
addq $0x10, %rdx
jmp 0x2d9d60
movq 0x20(%rdx), %rdx
addq $0x8, %rdx
movq (%rdx), %rdx
jmp 0x2d9d41
cmpb $-0x5c, (%rdx)
jne 0x2d9db4
testq %rcx, %rcx
je 0x2d9d91
movl 0x2c(%rdx), %edi
xorl %esi, %esi
cmpl %edi, 0x2c(%rbx,%rsi,4)
jne 0x2d9d87
movzwl 0x58(%rbx,%rsi,2), %r8d
cmpw 0x30(%rdx), %r8w
je 0x2d9d93
incq %rsi
cmpq %rsi, %rcx
jne 0x2d9d74
jmp 0x2d9d97
xorl %esi, %esi
cmpl %ecx, %esi
jne 0x2d9db4
movl 0x2c(%rdx), %eax
movl %ecx, %esi
movl %eax, 0x2c(%rbx,%rsi,4)
movzwl 0x30(%rdx), %eax
movw %ax, 0x58(%rbx,%rsi,2)
leal 0x1(%rcx), %eax
movb %al, 0x21(%rbx)
movzwl 0x14(%r14), %eax
movzwl %ax, %ecx
testl %ecx, 0x24(%rbx)
je 0x2d9e94
btl $0x8, %ecx
jb 0x2d9e72
cmpq $0x0, 0x10(%rbx)
je 0x2d9e72
movq (%r13), %rax
movq (%rax), %rax
movq %rax, 0x10(%rsp)
movq (%r14), %r12
movsbl 0x20(%rbx), %esi
movq %r12, %rdi
callq 0x2d9f08
movl 0xc(%rsp), %r9d
testl %eax, %eax
je 0x2d9e94
xorl %eax, %eax
movl 0x4(%r12), %ecx
movl $0x200, %edx            # imm = 0x200
andl %edx, %ecx
sete %al
shrl $0x6, %ecx
movq 0x10(%r12,%rcx), %rsi
movq 0x10(%r12,%rax,8), %rdx
movq 0x10(%rsp), %r12
movq %r12, %rdi
callq 0x2a9634
testq %rax, %rax
jne 0x2d9e35
movq (%r12), %rax
movq 0x10(%rax), %rax
movq (%rax), %rax
movq 0x10(%rbx), %rcx
xorl %edx, %edx
leaq 0xf749b(%rip), %r8      # 0x3d12e0
movl 0xc(%rsp), %r9d
movzbl (%rax,%rdx), %esi
movzbl (%rcx,%rdx), %edi
cmpb %dil, %sil
jne 0x2d9e5e
testq %rsi, %rsi
jne 0x2d9e68
jmp 0x2d9e6d
movb (%rsi,%r8), %sil
cmpb (%rdi,%r8), %sil
jne 0x2d9e94
incq %rdx
jmp 0x2d9e4a
movzwl 0x14(%r14), %eax
testb $-0x7e, %al
je 0x2d9ecd
movq (%r14), %rax
movq 0x18(%rax), %rax
cmpb $-0x5c, (%rax)
jne 0x2d9ecd
movl 0x2c(%rax), %ecx
cmpl 0x2c(%rbx), %ecx
jne 0x2d9ecd
movzwl 0x30(%rax), %eax
cmpw 0x58(%rbx), %ax
jne 0x2d9ecd
incl %r15d
addq $0x40, %r14
cmpl 0x14(%r13), %r15d
jl 0x2d9cd6
movq 0x8(%r13), %r13
xorl %r15d, %r15d
testq %r13, %r13
jne 0x2d9cc1
movb 0x22(%rbx), %al
cmpb 0x21(%rbx), %al
jae 0x2d9eea
movq (%rbx), %r13
incb %al
movb %al, 0x22(%rbx)
xorl %r15d, %r15d
jmp 0x2d9caf
movq %r13, 0x8(%rbx)
incl %r15d
movl %r15d, 0x28(%rbx)
movq %r14, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x2d9ed8