// File: /workspace/github_c_makefile_star2_O1/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: sqlite3FindInIndex
SQLITE_PRIVATE int sqlite3FindInIndex(Parse *pParse, Expr *pX, u32 inFlags, int *prRhsHasNull){
  Select *p;                            /* SELECT to the right of IN operator */
  int eType = 0;                        /* Type of RHS table. IN_INDEX_* */
  int iTab = pParse->nTab++;            /* Cursor of the RHS table */
  int mustBeUnique;                     /* True if RHS must be unique */
  Vdbe *v = sqlite3GetVdbe(pParse);     /* Virtual machine being coded */

  assert( pX->op==TK_IN );
  mustBeUnique = (inFlags & IN_INDEX_LOOP)!=0;

  /* Check to see if an existing table or index can be used to
  ** satisfy the query.  This is preferable to generating a new 
  ** ephemeral table.
  */
  p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
  if( pParse->nErr==0 && isCandidateForInOpt(p) ){
    sqlite3 *db = pParse->db;              /* Database connection */
    Table *pTab;                           /* Table <table>. */
    Expr *pExpr;                           /* Expression <column> */
    i16 iCol;                              /* Index of column <column> */
    i16 iDb;                               /* Database idx for pTab */

    assert( p );                        /* Because of isCandidateForInOpt(p) */
    assert( p->pEList!=0 );             /* Because of isCandidateForInOpt(p) */
    assert( p->pEList->a[0].pExpr!=0 ); /* Because of isCandidateForInOpt(p) */
    assert( p->pSrc!=0 );               /* Because of isCandidateForInOpt(p) */
    pTab = p->pSrc->a[0].pTab;
    pExpr = p->pEList->a[0].pExpr;
    iCol = (i16)pExpr->iColumn;
   
    /* Code an OP_Transaction and OP_TableLock for <table>. */
    iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
    sqlite3CodeVerifySchema(pParse, iDb);
    sqlite3TableLock(pParse, iDb, pTab->tnum, 0, pTab->zName);

    /* This function is only called from two places. In both cases the vdbe
    ** has already been allocated. So assume sqlite3GetVdbe() is always
    ** successful here.
    */
    assert(v);
    if( iCol<0 ){
      int iAddr = sqlite3CodeOnce(pParse);
      VdbeCoverage(v);

      sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);
      eType = IN_INDEX_ROWID;

      sqlite3VdbeJumpHere(v, iAddr);
    }else{
      Index *pIdx;                         /* Iterator variable */

      /* The collation sequence used by the comparison. If an index is to
      ** be used in place of a temp-table, it must be ordered according
      ** to this collation sequence.  */
      CollSeq *pReq = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pExpr);

      /* Check that the affinity that will be used to perform the 
      ** comparison is the same as the affinity of the column. If
      ** it is not, it is not possible to use any index.
      */
      int affinity_ok = sqlite3IndexAffinityOk(pX, pTab->aCol[iCol].affinity);

      for(pIdx=pTab->pIndex; pIdx && eType==0 && affinity_ok; pIdx=pIdx->pNext){
        if( (pIdx->aiColumn[0]==iCol)
         && sqlite3FindCollSeq(db, ENC(db), pIdx->azColl[0], 0)==pReq
         && (!mustBeUnique || (pIdx->nKeyCol==1 && IsUniqueIndex(pIdx)))
        ){
          int iAddr = sqlite3CodeOnce(pParse); VdbeCoverage(v);
          sqlite3VdbeAddOp3(v, OP_OpenRead, iTab, pIdx->tnum, iDb);
          sqlite3VdbeSetP4KeyInfo(pParse, pIdx);
          VdbeComment((v, "%s", pIdx->zName));
          assert( IN_INDEX_INDEX_DESC == IN_INDEX_INDEX_ASC+1 );
          eType = IN_INDEX_INDEX_ASC + pIdx->aSortOrder[0];

          if( prRhsHasNull && !pTab->aCol[iCol].notNull ){
            *prRhsHasNull = ++pParse->nMem;
            sqlite3SetHasNullFlag(v, iTab, *prRhsHasNull);
          }
          sqlite3VdbeJumpHere(v, iAddr);
        }
      }
    }
  }

  /* If no preexisting index is available for the IN clause
  ** and IN_INDEX_NOOP is an allowed reply
  ** and the RHS of the IN operator is a list, not a subquery
  ** and the RHS is not contant or has two or fewer terms,
  ** then it is not worth creating an ephemeral table to evaluate
  ** the IN operator so return IN_INDEX_NOOP.
  */
  if( eType==0
   && (inFlags & IN_INDEX_NOOP_OK)
   && !ExprHasProperty(pX, EP_xIsSelect)
   && (!sqlite3InRhsIsConstant(pX) || pX->x.pList->nExpr<=2)
  ){
    eType = IN_INDEX_NOOP;
  }
     

  if( eType==0 ){
    /* Could not find an existing table or index to use as the RHS b-tree.
    ** We will have to generate an ephemeral table to do the job.
    */
    u32 savedNQueryLoop = pParse->nQueryLoop;
    int rMayHaveNull = 0;
    eType = IN_INDEX_EPH;
    if( inFlags & IN_INDEX_LOOP ){
      pParse->nQueryLoop = 0;
      if( pX->pLeft->iColumn<0 && !ExprHasProperty(pX, EP_xIsSelect) ){
        eType = IN_INDEX_ROWID;
      }
    }else if( prRhsHasNull ){
      *prRhsHasNull = rMayHaveNull = ++pParse->nMem;
    }
    sqlite3CodeSubselect(pParse, pX, rMayHaveNull, eType==IN_INDEX_ROWID);
    pParse->nQueryLoop = savedNQueryLoop;
  }else{
    pX->iTable = iTab;
  }
  return eType;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, -0x68(%rbp)
movl %edx, -0x34(%rbp)
movq %rsi, %r14
movq %rdi, %rbx
movl 0x50(%rdi), %r13d
leal 0x1(%r13), %eax
movl %eax, 0x50(%rdi)
callq 0x507bf
xorl %r15d, %r15d
testb $0x8, 0x5(%r14)
jne 0x555ad
xorl %esi, %esi
jmp 0x555b1
movq 0x20(%r14), %rsi
cmpl $0x0, 0x4c(%rbx)
setne %cl
testq %rsi, %rsi
sete %dl
orb %cl, %dl
jne 0x555f1
cmpq $0x0, 0x50(%rsi)
jne 0x555f1
testb $0x9, 0xa(%rsi)
jne 0x555f1
cmpq $0x0, 0x60(%rsi)
jne 0x555f1
cmpq $0x0, 0x30(%rsi)
jne 0x555f1
movq 0x28(%rsi), %rcx
cmpl $0x1, (%rcx)
jne 0x555f1
cmpq $0x0, 0x30(%rcx)
je 0x55728
testl %r15d, %r15d
jne 0x55689
xorl %r15d, %r15d
testb $0x1, -0x34(%rbp)
je 0x55689
testb $0x8, 0x5(%r14)
jne 0x55689
movq 0x10(%r14), %rax
movq %rax, -0x30(%rbp)
movq $0x0, 0x10(%r14)
xorps %xmm0, %xmm0
leaq -0xb0(%rbp), %r12
movaps %xmm0, 0x20(%r12)
movaps %xmm0, (%r12)
movaps %xmm0, 0x10(%r12)
movb $0x1, 0x24(%r12)
leaq -0xf0f(%rip), %rax      # 0x54737
movq %rax, (%r12)
leaq -0xea4(%rip), %rax      # 0x547ad
movq %rax, 0x8(%r12)
movl $0x0, 0x28(%r12)
movq %r12, %rdi
movq %r14, %rsi
callq 0x547bc
cmpb $0x0, 0x24(%r12)
movq -0x30(%rbp), %rax
movq %rax, 0x10(%r14)
je 0x55683
movq 0x20(%r14), %rax
cmpl $0x2, (%rax)
jg 0x55689
movl $0x5, %r15d
testl %r15d, %r15d
je 0x55694
movl %r13d, 0x2c(%r14)
jmp 0x55713
movl 0x1d4(%rbx), %r12d
testb $0x4, -0x34(%rbp)
jne 0x556be
movl $0x2, %r15d
xorl %ecx, %ecx
movq -0x68(%rbp), %rax
testq %rax, %rax
je 0x556df
movl 0x54(%rbx), %edx
incl %edx
movl %edx, 0x54(%rbx)
movl %edx, (%rax)
jmp 0x55701
movl $0x0, 0x1d4(%rbx)
movq 0x10(%r14), %rax
movl $0x2, %r15d
xorl %edx, %edx
cmpw $0x0, 0x30(%rax)
js 0x556e3
xorl %ecx, %ecx
jmp 0x55701
xorl %edx, %edx
jmp 0x55701
movl $0x800, %eax            # imm = 0x800
andl 0x4(%r14), %eax
movl %eax, %ecx
shrl $0xb, %ecx
xorl $0x1, %ecx
cmpl $0x1, %eax
movl $0x2, %r15d
sbbl $0x0, %r15d
movq %rbx, %rdi
movq %r14, %rsi
callq 0x52ec1
movl %r12d, 0x1d4(%rbx)
movl %r15d, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x28(%rcx), %rcx
testq %rcx, %rcx
je 0x555f1
testb $0x10, 0x46(%rcx)
jne 0x555f1
movq (%rsi), %rcx
cmpl $0x1, (%rcx)
jne 0x555f1
movq %rax, -0x40(%rbp)
movq 0x8(%rcx), %rcx
movq (%rcx), %rcx
cmpb $-0x68, (%rcx)
jne 0x555f1
movq (%rbx), %rdi
movq (%rsi), %rcx
movq 0x28(%rsi), %rax
movq 0x28(%rax), %r12
movq 0x8(%rcx), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movzwl 0x30(%rax), %eax
movq %rax, -0x48(%rbp)
movq 0x68(%r12), %rcx
testq %rcx, %rcx
movq %rdi, -0x58(%rbp)
je 0x557b4
movl 0x28(%rdi), %edx
testl %edx, %edx
jle 0x557bb
movq 0x20(%rdi), %rsi
addq $0x18, %rsi
xorl %eax, %eax
cmpq %rcx, (%rsi)
je 0x557bd
incq %rax
addq $0x20, %rsi
cmpq %rax, %rdx
jne 0x5579f
movl %edx, %eax
jmp 0x557bd
movl $0xfff0bdc0, %eax       # imm = 0xFFF0BDC0
jmp 0x557bd
xorl %eax, %eax
movswl %ax, %r15d
movq %rbx, %rdi
movl %r15d, %esi
callq 0x55b4e
movl 0x38(%r12), %edx
movq (%r12), %r8
movq %rbx, %rdi
movl %r15d, -0x4c(%rbp)
movl %r15d, %esi
xorl %ecx, %ecx
callq 0x50be4
movq -0x48(%rbp), %r15
testw %r15w, %r15w
js 0x5583b
movq 0x10(%r14), %rsi
movq %rbx, %rdi
movq -0x30(%rbp), %rdx
callq 0x5530a
movq %rax, -0x80(%rbp)
movq %r12, -0x78(%rbp)
movq 0x8(%r12), %rax
leaq (%r15,%r15,2), %rcx
movq %rcx, -0x60(%rbp)
shll $0x4, %ecx
movb 0x29(%rax,%rcx), %r15b
movq %r14, %rdi
callq 0x55a85
cmpb $0x41, %al
je 0x558a2
movzbl %al, %eax
cmpl $0x42, %eax
jne 0x558a8
cmpb $0x42, %r15b
sete -0x30(%rbp)
jmp 0x558b0
movq %rbx, %rdi
callq 0x507bf
movl 0x5c(%rbx), %edx
leal 0x1(%rdx), %ecx
movl %ecx, 0x5c(%rbx)
movq %rax, %rdi
movl $0x2d, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, %r15d
movq %rbx, %rdi
movl %r13d, %esi
movl -0x4c(%rbp), %edx
movq %r12, %rcx
movl $0x37, %r8d
callq 0x50ae2
movq -0x40(%rbp), %rsi
movl 0x3c(%rsi), %eax
leal -0x1(%rax), %ecx
movq 0x30(%rsi), %rdx
movl %ecx, 0x68(%rdx)
movq (%rsi), %rdx
cmpb $0x0, 0x51(%rdx)
je 0x55a5d
leaq 0x3fc4b(%rip), %rcx     # 0x954e8
jmp 0x55a77
movb $0x1, -0x30(%rbp)
jmp 0x558b0
cmpb $0x43, %r15b
setge -0x30(%rbp)
movq -0x78(%rbp), %rax
movq 0x10(%rax), %r8
xorl %r15d, %r15d
testq %r8, %r8
je 0x555f1
cmpb $0x0, -0x30(%rbp)
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rdx
je 0x555f1
movq -0x60(%rbp), %rax
shll $0x4, %eax
movq %rax, -0x60(%rbp)
movq 0x8(%r8), %rax
movl $0x0, %r15d
cmpw %dx, (%rax)
jne 0x55a3d
movzbl 0x4e(%rdi), %esi
movq %r8, %r12
movq 0x40(%r8), %rax
movq (%rax), %rdx
xorl %r15d, %r15d
xorl %ecx, %ecx
callq 0x50e9b
cmpq -0x80(%rbp), %rax
je 0x55922
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq %r12, %r8
jmp 0x55a3d
testb $0x4, -0x34(%rbp)
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rdx
je 0x5594b
movq %r12, %r8
cmpw $0x1, 0x5e(%r12)
jne 0x55a3d
cmpb $0x0, 0x62(%r8)
je 0x55a3d
movq %rbx, %rdi
callq 0x507bf
movl 0x5c(%rbx), %edx
leal 0x1(%rdx), %ecx
movl %ecx, 0x5c(%rbx)
movq %rax, %rdi
movl $0x2d, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x3fa9e
movl %eax, -0x6c(%rbp)
movl 0x58(%r12), %ecx
movq -0x40(%rbp), %rdi
movl $0x37, %esi
movl %r13d, %edx
movl -0x4c(%rbp), %r8d
callq 0x3fa9e
movq 0x10(%rbx), %r15
movq %rbx, %rdi
movq %r12, %rsi
callq 0x50ceb
movq %r15, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movq %rax, %rdx
movl $0xfffffffa, %ecx       # imm = 0xFFFFFFFA
callq 0x14ab9
movq %r12, %r8
movq 0x38(%r12), %rax
movzbl (%rax), %r15d
cmpq $0x0, -0x68(%rbp)
je 0x559f2
movq -0x78(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x60(%rbp), %rcx
cmpb $0x0, 0x28(%rax,%rcx)
jne 0x559f2
movl 0x54(%rbx), %edx
incl %edx
movl %edx, 0x54(%rbx)
movq -0x68(%rbp), %rax
movl %edx, (%rax)
movq -0x40(%rbp), %rdi
movl %r13d, %esi
callq 0x554bc
movq %r12, %r8
movq -0x40(%rbp), %rsi
movl 0x3c(%rsi), %eax
leal -0x1(%rax), %edx
movq 0x30(%rsi), %rcx
movl %edx, 0x68(%rcx)
movq (%rsi), %rcx
cmpb $0x0, 0x51(%rcx)
leaq 0x3fad7(%rip), %rcx     # 0x954e8
jne 0x55a2e
movl -0x6c(%rbp), %ecx
testl %ecx, %ecx
cmovnsl %ecx, %edx
movslq %edx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
movq -0x40(%rbp), %rdx
addq 0x8(%rdx), %rcx
addl $0x3, %r15d
movl %eax, 0x8(%rcx)
movq -0x58(%rbp), %rdi
movq -0x48(%rbp), %rdx
movq 0x28(%r8), %r8
testq %r8, %r8
setne %al
testl %r15d, %r15d
sete %cl
andb %al, %cl
testb %cl, -0x30(%rbp)
jne 0x558e1
jmp 0x555f1
testl %r15d, %r15d
cmovnsl %r15d, %ecx
movslq %ecx, %rcx
leaq (%rcx,%rcx,2), %rcx
shlq $0x3, %rcx
movq -0x40(%rbp), %rdx
addq 0x8(%rdx), %rcx
movl %eax, 0x8(%rcx)
movl $0x1, %r15d
jmp 0x555f1