// File: /workspace/github_c_makefile_star2_O1/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: codeAllEqualityTerms
static int codeAllEqualityTerms(
  Parse *pParse,        /* Parsing context */
  WhereLevel *pLevel,   /* Which nested loop of the FROM we are coding */
  int bRev,             /* Reverse the order of IN operators */
  int nExtraReg,        /* Number of extra registers to allocate */
  char **pzAff          /* OUT: Set to point to affinity string */
){
  int nEq;                      /* The number of == or IN constraints to code */
  Vdbe *v = pParse->pVdbe;      /* The vm under construction */
  Index *pIdx;                  /* The index being used for this loop */
  WhereTerm *pTerm;             /* A single constraint term */
  WhereLoop *pLoop;             /* The WhereLoop object */
  int j;                        /* Loop counter */
  int regBase;                  /* Base register */
  int nReg;                     /* Number of registers to allocate */
  char *zAff;                   /* Affinity string to return */

  /* This module is only called on query plans that use an index. */
  pLoop = pLevel->pWLoop;
  assert( (pLoop->wsFlags & WHERE_VIRTUALTABLE)==0 );
  nEq = pLoop->u.btree.nEq;
  pIdx = pLoop->u.btree.pIndex;
  assert( pIdx!=0 );

  /* Figure out how many memory cells we will need then allocate them.
  */
  regBase = pParse->nMem + 1;
  nReg = pLoop->u.btree.nEq + nExtraReg;
  pParse->nMem += nReg;

  zAff = sqlite3DbStrDup(pParse->db, sqlite3IndexAffinityStr(v, pIdx));
  if( !zAff ){
    pParse->db->mallocFailed = 1;
  }

  /* Evaluate the equality constraints
  */
  assert( zAff==0 || strlen(zAff)>=nEq );
  for(j=0; j<nEq; j++){
    int r1;
    pTerm = pLoop->aLTerm[j];
    assert( pTerm!=0 );
    /* The following true for indices with redundant columns. 
    ** Ex: CREATE INDEX i1 ON t1(a,b,a); SELECT * FROM t1 WHERE a=0 AND b=0; */
    testcase( (pTerm->wtFlags & TERM_CODED)!=0 );
    testcase( pTerm->wtFlags & TERM_VIRTUAL );
    r1 = codeEqualityTerm(pParse, pTerm, pLevel, j, bRev, regBase+j);
    if( r1!=regBase+j ){
      if( nReg==1 ){
        sqlite3ReleaseTempReg(pParse, regBase);
        regBase = r1;
      }else{
        sqlite3VdbeAddOp2(v, OP_SCopy, r1, regBase+j);
      }
    }
    testcase( pTerm->eOperator & WO_ISNULL );
    testcase( pTerm->eOperator & WO_IN );
    if( (pTerm->eOperator & (WO_ISNULL|WO_IN))==0 ){
      Expr *pRight = pTerm->pExpr->pRight;
      sqlite3ExprCodeIsNullJump(v, pRight, regBase+j, pLevel->addrBrk);
      if( zAff ){
        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_NONE ){
          zAff[j] = SQLITE_AFF_NONE;
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
          zAff[j] = SQLITE_AFF_NONE;
        }
      }
    }
  }
  *pzAff = zAff;
  return regBase;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, -0x58(%rbp)
movl %edx, -0x3c(%rbp)
movq %rdi, %rdx
movq (%rdi), %rbx
movq 0x10(%rdi), %rdi
movq %rsi, -0x50(%rbp)
movq 0x40(%rsi), %rax
movl 0x18(%rax), %r12d
movq %rax, -0x68(%rbp)
movq 0x20(%rax), %rsi
movl 0x58(%rdx), %r14d
addl %r12d, %ecx
movq %rcx, -0x60(%rbp)
leal (%r14,%rcx), %eax
movq %rdx, -0x30(%rbp)
movl %eax, 0x58(%rdx)
movq %rdi, -0x48(%rbp)
callq 0x4c8b2
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1010d
movq %rax, %r13
testq %rax, %rax
jne 0x5b4d6
movq -0x30(%rbp), %rax
movq (%rax), %rax
movb $0x1, 0x50(%rax)
incl %r14d
testl %r12d, %r12d
movq %r14, %rsi
jle 0x5b634
xorl %r15d, %r15d
movq %r13, -0x38(%rbp)
movq %r12, %r13
movq -0x68(%rbp), %rax
movq 0x30(%rax), %rax
movq (%rax,%r15,8), %rbx
movq %rsi, %r14
leal (%rsi,%r15), %r12d
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
movq -0x50(%rbp), %rdx
movl %r15d, %ecx
movl -0x3c(%rbp), %r8d
movl %r12d, %r9d
callq 0x5b250
cmpl %r12d, %eax
je 0x5b593
cmpl $0x1, -0x60(%rbp)
jne 0x5b57d
testl %r14d, %r14d
je 0x5b612
movq -0x30(%rbp), %rcx
movzbl 0x1f(%rcx), %ecx
cmpq $0x7, %rcx
movq %r13, %r12
ja 0x5b619
xorl %edx, %edx
movq -0x38(%rbp), %r13
movq -0x30(%rbp), %rsi
cmpl %r14d, 0x84(%rsi,%rdx)
je 0x5b624
addq $0x18, %rdx
cmpl $0xf0, %edx
jne 0x5b54b
leal 0x1(%rcx), %edx
movq -0x30(%rbp), %rsi
movb %dl, 0x1f(%rsi)
movl %r14d, 0x28(%rsi,%rcx,4)
jmp 0x5b62d
movq -0x48(%rbp), %rdi
movl $0x1d, %esi
movl %eax, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x45b9e
movq %r13, %r12
movq -0x38(%rbp), %r13
movq %r14, %rsi
testb $-0x7f, 0x18(%rbx)
je 0x5b5b4
incq %r15
cmpq %r12, %r15
jne 0x5b4ec
jmp 0x5b634
movq (%rbx), %rax
movq 0x18(%rax), %rbx
leal (%rsi,%r15), %edx
movq -0x50(%rbp), %rax
movl 0xc(%rax), %ecx
movq %rsi, %r14
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
callq 0x5b64c
movq %r14, %rsi
testq %r13, %r13
je 0x5b5a3
movsbl (%r13,%r15), %esi
movq %rbx, %rdi
callq 0x4eee9
cmpb $0x62, %al
jne 0x5b5f5
movb $0x62, (%r13,%r15)
movsbl (%r13,%r15), %esi
movq %rbx, %rdi
callq 0x5b6a0
testl %eax, %eax
movq %r14, %rsi
je 0x5b5a3
movb $0x62, (%r13,%r15)
jmp 0x5b5a3
movl %eax, %esi
movq %r13, %r12
jmp 0x5b61b
movl %eax, %esi
movq -0x38(%rbp), %r13
jmp 0x5b59d
movq -0x30(%rbp), %rcx
movb $0x1, 0x7c(%rcx,%rdx)
movl %eax, %esi
jmp 0x5b59d
movq -0x58(%rbp), %rax
movq %r13, (%rax)
movl %esi, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq