// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/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->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(pParse->db,pIdx));
  assert( zAff!=0 || pParse->db->mallocFailed );

  if( nSkip ){
    int iIdxCur = pLevel->iIdxCur;
    sqlite3VdbeAddOp1(v, (bRev?OP_Last:OP_Rewind), iIdxCur);
    VdbeCoverageIf(v, bRev==0);
    VdbeCoverageIf(v, bRev!=0);
    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);
    VdbeCoverageIf(v, bRev==0);
    VdbeCoverageIf(v, bRev!=0);
    sqlite3VdbeJumpHere(v, j);
    for(j=0; j<nSkip; j++){
      sqlite3VdbeAddOp3(v, OP_Column, iIdxCur, j, regBase+j);
      testcase( pIdx->aiColumn[j]==XN_EXPR );
      VdbeComment((v, "%s", explainIndexColumnName(pIdx, j)));
    }
  }

  /* 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);
      }
    }
    if( pTerm->eOperator & WO_IN ){
      if( pTerm->pExpr->flags & EP_xIsSelect ){
        /* No affinity ever needs to be (or should be) applied to a value
        ** from the RHS of an "? IN (SELECT ...)" expression. The
        ** sqlite3FindInIndex() routine has already ensured that the
        ** affinity of the comparison has been applied to the value.  */
        if( zAff ) zAff[j] = SQLITE_AFF_BLOB;
      }
    }else if( (pTerm->eOperator & WO_ISNULL)==0 ){
      Expr *pRight = pTerm->pExpr->pRight;
      if( (pTerm->wtFlags & TERM_IS)==0 && sqlite3ExprCanBeNull(pRight) ){
        sqlite3VdbeAddOp2(v, OP_IsNull, regBase+j, pLevel->addrBrk);
        VdbeCoverage(v);
      }
      if( zAff ){
        if( sqlite3CompareAffinity(pRight, zAff[j])==SQLITE_AFF_BLOB ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
        if( sqlite3ExprNeedsNoAffinityChange(pRight, zAff[j]) ){
          zAff[j] = SQLITE_AFF_BLOB;
        }
      }
    }
  }
  *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 0x50(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movw 0x18(%rax), %ax
movw %ax, -0x22(%rbp)
movq -0x48(%rbp), %rax
movw 0x2e(%rax), %ax
movw %ax, -0x24(%rbp)
movq -0x48(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rax
movl 0x38(%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 0x38(%rax), %ecx
movl %ecx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x43def0
movq -0x78(%rbp), %rdi
movq %rax, %rsi
callq 0x3c91a0
movq %rax, -0x60(%rbp)
cmpw $0x0, -0x24(%rbp)
je 0x45688b
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x64(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x25, %esi
movl $0x21, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl -0x64(%rbp), %edx
callq 0x42ba70
movq -0x30(%rbp), %rdi
movl $0xb, %esi
callq 0x429a40
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rdi
movl -0x14(%rbp), %ecx
movl $0x19, %esi
movl $0x16, %eax
cmpl $0x0, %ecx
cmovnel %eax, %esi
movl -0x64(%rbp), %edx
movl -0x50(%rbp), %r8d
movzwl -0x24(%rbp), %r9d
xorl %ecx, %ecx
callq 0x3cb970
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x30(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x429a70
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x24(%rbp), %ecx
cmpl %ecx, %eax
jge 0x456889
movq -0x30(%rbp), %rdi
movl -0x64(%rbp), %edx
movl -0x4c(%rbp), %ecx
movl -0x50(%rbp), %r8d
addl -0x4c(%rbp), %r8d
movl $0x59, %esi
callq 0x410130
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x456857
jmp 0x45688b
movzwl -0x24(%rbp), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x22(%rbp), %ecx
cmpl %ecx, %eax
jge 0x456a22
movq -0x48(%rbp), %rax
movq 0x38(%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 0x456030
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
cmpl %ecx, %eax
je 0x456918
cmpl $0x1, -0x54(%rbp)
jne 0x4568ff
movq -0x8(%rbp), %rdi
movl -0x50(%rbp), %esi
callq 0x42e560
movl -0x68(%rbp), %eax
movl %eax, -0x50(%rbp)
jmp 0x456916
movq -0x30(%rbp), %rdi
movl -0x68(%rbp), %edx
movl -0x50(%rbp), %ecx
addl -0x4c(%rbp), %ecx
movl $0x4e, %esi
callq 0x410100
jmp 0x456918
movq -0x40(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x456956
movq -0x40(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x456951
cmpq $0x0, -0x60(%rbp)
je 0x45694f
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x41, (%rax,%rcx)
jmp 0x456951
jmp 0x456a12
movq -0x40(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
jne 0x456a10
movq -0x40(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
movq -0x40(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x4569b6
movq -0x70(%rbp), %rdi
callq 0x431630
cmpl $0x0, %eax
je 0x4569b6
movq -0x30(%rbp), %rdi
movl -0x50(%rbp), %edx
addl -0x4c(%rbp), %edx
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movl $0x32, %esi
callq 0x410100
cmpq $0x0, -0x60(%rbp)
je 0x456a0e
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x42f370
movsbl %al, %eax
cmpl $0x41, %eax
jne 0x4569e6
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x41, (%rax,%rcx)
movq -0x70(%rbp), %rdi
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x4572d0
cmpl $0x0, %eax
je 0x456a0c
movq -0x60(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movb $0x41, (%rax,%rcx)
jmp 0x456a0e
jmp 0x456a10
jmp 0x456a12
jmp 0x456a14
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x456892
movq -0x60(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movl -0x50(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)