// File: /workspace/github_c_makefile_star2_O0/skeeto[P]flappy/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 */
){
  u16 nEq;                      /* The number of == or IN constraints to code */
  u16 nSkip;                    /* Number of left-most columns to skip */
  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;
  nSkip = pLoop->u.btree.nSkip;
  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;
  }

  if( nSkip ){
    int iIdxCur = pLevel->iIdxCur;
    sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
    VdbeComment((v, "begin skip-scan on %s", pIdx->zName));
    j = sqlite3VdbeAddOp0(v, OP_Goto);
    pLevel->addrSkip = sqlite3VdbeAddOp4Int(v, (bRev?OP_SeekLt:OP_SeekGt),
                            iIdxCur, 0, regBase, nSkip);
    sqlite3VdbeJumpHere(v, j);
    for(j=0; j<nSkip; j++){
      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);
      assert( pIdx->aiColumn[j]>=0 );
      VdbeComment((v, "%s", pIdx->pTable->aCol[pIdx->aiColumn[j]].zName));
    }
  }    

  /* Evaluate the equality constraints
  */
  assert( zAff==0 || (int)strlen(zAff)>=nEq );
  for(j=nSkip; j<nEq; j++){
    int r1;
    pTerm = pLoop->aLTerm[j];
    assert( pTerm!=0 );
    /* The following testcase is 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
movw 0x18(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x48(%rbp), %rax
movw 0x1a(%rax), %ax
movw %ax, -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
movzwl 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 0x72130
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x147b0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x8259b
movq -0x8(%rbp), %rax
movq (%rax), %rax
movb $0x1, 0x50(%rax)
cmpw $0x0, -0x24(%rbp)
je 0x8265a
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x67, %esi
movl $0x64, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl -0x64(%rbp), %edx
callq 0x66020
movq -0x30(%rbp), %rdi
movl $0x10, %esi
callq 0x63920
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x3c, %esi
movl $0x39, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl -0x64(%rbp), %edx
movl -0x50(%rbp), %r8d
movzwl -0x24(%rbp), %r9d
xorl %ecx, %ecx
callq 0x640a0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x63950
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x24(%rbp), %ecx
cmpl %ecx, %eax
jge 0x82658
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %r8d
addl -0x4c(%rbp), %r8d
movl $0x2b, %esi
callq 0x639b0
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x82626
jmp 0x8265a
movzwl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x82790
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 0x82190
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
je 0x826e7
cmpl $0x1, -0x54(%rbp)
jne 0x826ce
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x673a0
movl -0x68(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x826e5
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movl $0x1f, %esi
callq 0x63980
jmp 0x826e7
movq -0x40(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x81, %eax
cmpl $0x0, %eax
jne 0x82780
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 0x827b0
cmpq $0x0, -0x60(%rbp)
je 0x8277e
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x69a80
movsbl %al, %eax
cmpl $0x62, %eax
jne 0x82756
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 0x827f0
cmpl $0x0, %eax
je 0x8277c
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x62, (%rax,%rcx)
jmp 0x8277e
jmp 0x82780
jmp 0x82782
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x82661
movq -0x60(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x50(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw (%rax,%rax)