// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: whereScanNext
static WhereTerm *whereScanNext(WhereScan *pScan){
  int iCur;            /* The cursor on the LHS of the term */
  int 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->aEquiv[pScan->iEquiv-2];
    iColumn = pScan->aEquiv[pScan->iEquiv-1];
    while( (pWC = pScan->pWC)!=0 ){
      for(pTerm=pWC->a+k; k<pWC->nTerm; k++, pTerm++){
        if( pTerm->leftCursor==iCur && pTerm->u.leftColumn==iColumn ){
          if( (pTerm->eOperator & WO_EQUIV)!=0
           && pScan->nEquiv<ArraySize(pScan->aEquiv)
          ){
            int j;
            pX = sqlite3ExprSkipCollate(pTerm->pExpr->pRight);
            assert( pX->op==TK_COLUMN );
            for(j=0; j<pScan->nEquiv; j+=2){
              if( pScan->aEquiv[j]==pX->iTable
               && pScan->aEquiv[j+1]==pX->iColumn ){
                  break;
              }
            }
            if( j==pScan->nEquiv ){
              pScan->aEquiv[j] = pX->iTable;
              pScan->aEquiv[j+1] = pX->iColumn;
              pScan->nEquiv += 2;
            }
          }
          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)!=0
             && (pX = pTerm->pExpr->pRight)->op==TK_COLUMN
             && pX->iTable==pScan->aEquiv[0]
             && pX->iColumn==pScan->aEquiv[1]
            ){
              continue;
            }
            pScan->k = k+1;
            return pTerm;
          }
        }
      }
      pScan->pWC = pScan->pWC->pOuter;
      k = 0;
    }
    pScan->pWC = pScan->pOrigWC;
    k = 0;
    pScan->iEquiv += 2;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1a(%rax), %eax
movq -0x10(%rbp), %rcx
movzbl 0x19(%rcx), %ecx
cmpl %ecx, %eax
jg 0x77865
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movzbl 0x1a(%rcx), %ecx
subl $0x2, %ecx
movslq %ecx, %rcx
movl 0x24(%rax,%rcx,4), %eax
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq -0x10(%rbp), %rcx
movzbl 0x1a(%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl 0x24(%rax,%rcx,4), %eax
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
je 0x7783c
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x34(%rbp), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movl -0x34(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x7781c
movq -0x30(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x14(%rbp), %eax
jne 0x77800
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
cmpl -0x18(%rbp), %eax
jne 0x77800
movq -0x30(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x776da
movq -0x10(%rbp), %rax
movzbl 0x19(%rax), %eax
cmpl $0x16, %eax
jge 0x776da
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
callq 0x648b0
movq %rax, -0x20(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl 0x19(%rcx), %ecx
cmpl %ecx, %eax
jge 0x7768f
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl 0x24(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
cmpl 0x2c(%rcx), %eax
jne 0x77682
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl 0x24(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x30(%rcx), %ecx
cmpl %ecx, %eax
jne 0x77682
jmp 0x7768f
jmp 0x77684
movl -0x38(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x38(%rbp)
jmp 0x7763f
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movzbl 0x19(%rcx), %ecx
cmpl %ecx, %eax
jne 0x776d8
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %edx
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, 0x24(%rax,%rcx,4)
movq -0x20(%rbp), %rax
movswl 0x30(%rax), %edx
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, 0x24(%rax,%rcx,4)
movq -0x10(%rbp), %rax
movzbl 0x19(%rax), %ecx
addl $0x2, %ecx
movb %cl, 0x19(%rax)
jmp 0x776da
movq -0x30(%rbp), %rax
movzwl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
andl 0x1c(%rcx), %eax
cmpl $0x0, %eax
je 0x777fe
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7779b
movq -0x30(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
jne 0x7779b
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movsbl 0x18(%rax), %esi
callq 0x6b210
cmpl $0x0, %eax
jne 0x7774b
jmp 0x77802
movq -0x48(%rbp), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x20(%rbp), %rax
movq 0x18(%rax), %rdx
callq 0x6aa80
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x7777e
movq -0x48(%rbp), %rax
movq (%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0xc970
cmpl $0x0, %eax
je 0x77799
jmp 0x77802
jmp 0x7779b
movq -0x30(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x777e7
movq -0x30(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x20(%rbp)
movzbl (%rax), %eax
cmpl $0x98, %eax
jne 0x777e7
movq -0x20(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x777e7
movq -0x20(%rbp), %rax
movswl 0x30(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jne 0x777e7
jmp 0x77802
movl -0x34(%rbp), %ecx
addl $0x1, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x7786d
jmp 0x77800
jmp 0x77802
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x30(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x30(%rbp)
jmp 0x775cd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x34(%rbp)
jmp 0x775a0
movq -0x10(%rbp), %rax
movq (%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
movzbl 0x1a(%rax), %ecx
addl $0x2, %ecx
movb %cl, 0x1a(%rax)
jmp 0x77556
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)