// File: /workspace/github_c_makefile_star2_O3/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, -0x50(%rbp)
movl %edx, -0x34(%rbp)
movq %rdi, %r13
movq (%rdi), %rbx
movq 0x10(%rdi), %rdi
movq %rsi, -0x48(%rbp)
movq 0x40(%rsi), %rax
movl 0x18(%rax), %r15d
movq %rax, -0x68(%rbp)
movq 0x20(%rax), %rsi
movl 0x58(%r13), %r14d
addl %r15d, %ecx
movq %rcx, -0x58(%rbp)
leal (%r14,%rcx), %eax
movl %eax, 0x58(%r13)
movq %rdi, -0x40(%rbp)
callq 0x4c9e0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x101fc
movq %rax, -0x30(%rbp)
testq %rax, %rax
jne 0x5b46e
movq (%r13), %rax
movb $0x1, 0x50(%rax)
incl %r14d
testl %r15d, %r15d
jle 0x5b585
movq %r15, -0x60(%rbp)
xorl %r15d, %r15d
movq -0x68(%rbp), %rax
movq 0x30(%rax), %rax
movq (%rax,%r15,8), %rbx
leal (%r14,%r15), %r12d
movq %r13, %rdi
movq %rbx, %rsi
movq -0x48(%rbp), %rdx
movl %r15d, %ecx
movl -0x34(%rbp), %r8d
movl %r12d, %r9d
callq 0x5b1ec
cmpl %r12d, %eax
je 0x5b50c
cmpl $0x1, -0x58(%rbp)
jne 0x5b4eb
testl %r14d, %r14d
je 0x5b509
movzbl 0x1f(%r13), %ecx
cmpq $0x7, %rcx
ja 0x5b509
xorl %edx, %edx
cmpl %r14d, 0x84(%r13,%rdx)
je 0x5b503
addq $0x18, %rdx
cmpl $0xf0, %edx
jne 0x5b4c7
leal 0x1(%rcx), %edx
movb %dl, 0x1f(%r13)
movl %r14d, 0x28(%r13,%rcx,4)
jmp 0x5b509
movq -0x40(%rbp), %rdi
movl $0x1d, %esi
movl %eax, %edx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0x45f15
jmp 0x5b50c
movb $0x1, 0x7c(%r13,%rdx)
movl %eax, %r14d
testb $-0x7f, 0x18(%rbx)
je 0x5b521
incq %r15
cmpq -0x60(%rbp), %r15
jne 0x5b481
jmp 0x5b585
movq (%rbx), %rax
movq 0x18(%rax), %rbx
leal (%r14,%r15), %edx
movq -0x48(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x40(%rbp), %rdi
movq %rbx, %rsi
callq 0x5b5a2
cmpq $0x0, -0x30(%rbp)
je 0x5b512
movq -0x30(%rbp), %rax
movb (%rax,%r15), %r12b
movsbl %r12b, %esi
movq %rbx, %rdi
callq 0x4ef70
cmpb $0x62, %al
jne 0x5b56a
movq -0x30(%rbp), %rax
movb $0x62, (%rax,%r15)
movb $0x62, %r12b
movsbl %r12b, %esi
movq %rbx, %rdi
callq 0x5b5f6
testl %eax, %eax
je 0x5b512
movq -0x30(%rbp), %rax
movb $0x62, (%rax,%r15)
jmp 0x5b512
movq -0x50(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq