// File: /workspace/github_c_makefile_star2_O0/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
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movl 0x18(%rax), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x54(%rbp)
movl -0x54(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0x58(%rax), %ecx
movl %ecx, 0x58(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x67d80
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x11720
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x7b47c
movq -0x8(%rbp), %rax
movq (%rax), %rax
movb $0x1, 0x50(%rax)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x7b5af
movq -0x48(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x10(%rbp), %rdx
movl -0x4c(%rbp), %ecx
movl -0x14(%rbp), %r8d
movl -0x50(%rbp), %r9d
addl -0x4c(%rbp), %r9d
callq 0x7b0a0
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
je 0x7b506
cmpl $0x1, -0x54(%rbp)
jne 0x7b4ed
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x66ac0
movl -0x64(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x7b504
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movl $0x1d, %esi
callq 0x5e0c0
jmp 0x7b506
movq -0x40(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x81, %eax
cmpl $0x0, %eax
jne 0x7b59f
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x30(%rbp), %rdi
movq -0x70(%rbp), %rsi
movl -0x50(%rbp), %edx
addl -0x4c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
callq 0x7b5d0
cmpq $0x0, -0x60(%rbp)
je 0x7b59d
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x6ab70
movsbl %al, %eax
cmpl $0x62, %eax
jne 0x7b575
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x62, (%rax,%rcx)
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x7b610
cmpl $0x0, %eax
je 0x7b59b
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x62, (%rax,%rcx)
jmp 0x7b59d
jmp 0x7b59f
jmp 0x7b5a1
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x7b483
movq -0x60(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x50(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)