// File: /workspace/github_c_makefile_star2_O3/shifengbin[P]bishe/Output/../Persistence/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 */

  while( pScan->iEquiv<=pScan->nEquiv ){
    iCur = pScan->aiCur[pScan->iEquiv-1];
    iColumn = pScan->aiColumn[pScan->iEquiv-1];
    if( iColumn==XN_EXPR && pScan->pIdxExpr==0 ) return 0;
    while( (pWC = pScan->pWC)!=0 ){
      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
        if( pTerm->leftCursor==iCur
         && pTerm->u.leftColumn==iColumn
         && (iColumn!=XN_EXPR
             || sqlite3ExprCompare(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 = sqlite3ExprSkipCollate(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 = sqlite3BinaryCompareCollSeq(pParse,
                                                  pX->pLeft, pX->pRight);
              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->k = k+1;
            return pTerm;
          }
        }
      }
      pScan->pWC = pScan->pWC->pOuter;
      k = 0;
    }
    pScan->pWC = pScan->pOrigWC;
    k = 0;
    pScan->iEquiv++;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movb 0x21(%rdi), %al
movb 0x22(%rdi), %cl
cmpb %al, %cl
jbe 0x65c19
xorl %r15d, %r15d
jmp 0x65e48
movq %rdi, %rbx
movl 0x28(%rdi), %r12d
movzbl %cl, %edx
movl 0x28(%rbx,%rdx,4), %r14d
movswl 0x56(%rbx,%rdx,2), %r9d
cmpl $-0x2, %r9d
jne 0x65c3b
cmpq $0x0, 0x18(%rbx)
je 0x65c11
movq 0x8(%rbx), %r13
testq %r13, %r13
je 0x65e25
movl %r9d, -0x30(%rbp)
cmpl 0x14(%r13), %r12d
jge 0x65e0b
movslq %r12d, %rax
imulq $0x38, %rax, %r15
addq 0x20(%r13), %r15
cmpl %r14d, 0xc(%r15)
jne 0x65df6
cmpl %r9d, 0x10(%r15)
jne 0x65df6
cmpw $-0x2, %r9w
jne 0x65c9b
movq (%r15), %rax
movq 0x10(%rax), %rdi
movq 0x18(%rbx), %rsi
movl %r14d, %edx
callq 0x532d3
movl -0x30(%rbp), %r9d
testl %eax, %eax
jne 0x65df6
cmpb $0x2, 0x22(%rbx)
jb 0x65cae
movq (%r15), %rax
testb $0x1, 0x4(%rax)
jne 0x65df6
movzwl 0x1a(%r15), %eax
btl $0xb, %eax
jae 0x65d3e
movzbl 0x21(%rbx), %ecx
cmpl $0xa, %ecx
ja 0x65d3e
movq (%r15), %rdx
movq 0x18(%rdx), %rdx
movl 0x4(%rdx), %esi
btl $0xc, %esi
jae 0x65cef
btl $0x12, %esi
jb 0x65ce2
addq $0x10, %rdx
jmp 0x65cea
movq 0x20(%rdx), %rdx
movq 0x8(%rdx), %rdx
movq (%rdx), %rdx
jmp 0x65ccd
cmpb $-0x68, (%rdx)
jne 0x65d3e
testq %rcx, %rcx
je 0x65d1b
movl 0x2c(%rdx), %edi
xorl %esi, %esi
cmpl %edi, 0x2c(%rbx,%rsi,4)
jne 0x65d11
movzwl 0x58(%rbx,%rsi,2), %r8d
cmpw 0x30(%rdx), %r8w
je 0x65d1d
incq %rsi
cmpq %rsi, %rcx
jne 0x65cfe
jmp 0x65d21
xorl %esi, %esi
cmpl %ecx, %esi
jne 0x65d3e
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 0x1a(%r15), %eax
movzwl %ax, %ecx
testl %ecx, 0x24(%rbx)
je 0x65df6
btl $0x8, %ecx
jb 0x65dd4
cmpq $0x0, 0x10(%rbx)
je 0x65dd4
movq (%r13), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq (%r15), %rdi
movb 0x20(%rbx), %al
movb %al, -0x29(%rbp)
movq %rdi, -0x40(%rbp)
callq 0x547f7
movl -0x30(%rbp), %r9d
cmpb $0x41, %al
je 0x65d96
movzbl %al, %eax
cmpl $0x42, %eax
jne 0x65d90
cmpb $0x42, -0x29(%rbp)
je 0x65d96
jmp 0x65df6
cmpb $0x42, -0x29(%rbp)
jle 0x65df6
movq -0x40(%rbp), %rax
movq 0x10(%rax), %rsi
movq 0x18(%rax), %rdx
movq -0x38(%rbp), %rdi
callq 0x54122
testq %rax, %rax
jne 0x65dbb
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq 0x10(%rbx), %rsi
callq 0xa400
testl %eax, %eax
movl -0x30(%rbp), %r9d
jne 0x65df6
movzwl 0x1a(%r15), %eax
testb $-0x7e, %al
je 0x65e41
movq (%r15), %rax
movq 0x18(%rax), %rax
cmpb $-0x68, (%rax)
jne 0x65e41
movl 0x2c(%rax), %ecx
cmpl 0x2c(%rbx), %ecx
jne 0x65e41
movzwl 0x30(%rax), %eax
cmpw 0x58(%rbx), %ax
jne 0x65e41
incl %r12d
addq $0x38, %r15
cmpl 0x14(%r13), %r12d
jl 0x65c61
movq 0x8(%rbx), %r13
movq 0x8(%r13), %r13
movq %r13, 0x8(%rbx)
xorl %r12d, %r12d
testq %r13, %r13
jne 0x65c4c
movb 0x21(%rbx), %al
movb 0x22(%rbx), %cl
movq (%rbx), %rdx
movq %rdx, 0x8(%rbx)
incb %cl
movb %cl, 0x22(%rbx)
xorl %r12d, %r12d
cmpb %al, %cl
jbe 0x65c20
jmp 0x65c11
incl %r12d
movl %r12d, 0x28(%rbx)
movq %r15, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq