// File: /workspace/github_c_makefile_star2_O0/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
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x8(%rbp), %rcx
movl 0x50(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x50(%rcx)
movl %eax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x6bd00
movq %rax, -0x40(%rbp)
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
setne %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x34(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x72706
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0x72711
xorl %eax, %eax
movq %rax, -0x88(%rbp)
jmp 0x72711
movq -0x88(%rbp), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
jne 0x72996
movq -0x28(%rbp), %rdi
callq 0x72c50
cmpl $0x0, %eax
je 0x72996
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax), %rax
movq (%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movw 0x30(%rax), %ax
movw %ax, -0x5a(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x68(%rax), %rsi
callq 0x17ab0
movw %ax, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
movswl -0x5c(%rbp), %esi
callq 0x72d80
movq -0x8(%rbp), %rdi
movswl -0x5c(%rbp), %esi
movq -0x50(%rbp), %rax
movl 0x38(%rax), %edx
movq -0x50(%rbp), %rax
movq (%rax), %r8
xorl %ecx, %ecx
callq 0x6c340
movswl -0x5a(%rbp), %eax
cmpl $0x0, %eax
jge 0x727fb
movq -0x8(%rbp), %rdi
callq 0x724e0
movl %eax, -0x60(%rbp)
movq -0x8(%rbp), %rdi
movl -0x30(%rbp), %esi
movswl -0x5c(%rbp), %edx
movq -0x50(%rbp), %rcx
movl $0x37, %r8d
callq 0x6c1e0
movl $0x1, -0x2c(%rbp)
movq -0x40(%rbp), %rdi
movl -0x60(%rbp), %esi
callq 0x6be30
jmp 0x72994
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
movq -0x58(%rbp), %rdx
callq 0x721b0
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rdi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movswq -0x5a(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
movsbl 0x29(%rax), %esi
callq 0x72e50
movl %eax, -0x74(%rbp)
movq -0x50(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x68(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x68(%rbp)
movb %al, -0x89(%rbp)
je 0x7286e
xorl %eax, %eax
cmpl $0x0, -0x2c(%rbp)
movb %al, -0x89(%rbp)
jne 0x7286e
cmpl $0x0, -0x74(%rbp)
setne %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x7287d
jmp 0x72992
movq -0x68(%rbp), %rax
movq 0x8(%rax), %rax
movswl (%rax), %eax
movswl -0x5a(%rbp), %ecx
cmpl %ecx, %eax
jne 0x7297f
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rax
movb 0x4e(%rax), %al
movq -0x68(%rbp), %rcx
movq 0x40(%rcx), %rcx
movq (%rcx), %rdx
xorl %ecx, %ecx
movzbl %al, %esi
callq 0x6c7b0
cmpq -0x70(%rbp), %rax
jne 0x7297f
cmpl $0x0, -0x34(%rbp)
je 0x728e6
movq -0x68(%rbp), %rax
movzwl 0x5e(%rax), %eax
cmpl $0x1, %eax
jne 0x7297f
movq -0x68(%rbp), %rax
movzbl 0x62(%rax), %eax
cmpl $0x0, %eax
je 0x7297f
movq -0x8(%rbp), %rdi
callq 0x724e0
movl %eax, -0x78(%rbp)
movq -0x40(%rbp), %rdi
movl -0x30(%rbp), %edx
movq -0x68(%rbp), %rax
movl 0x58(%rax), %ecx
movswl -0x5c(%rbp), %r8d
movl $0x37, %esi
callq 0x56c10
movq -0x8(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x6c4e0
movq -0x68(%rbp), %rax
movq 0x38(%rax), %rax
movzbl (%rax), %eax
addl $0x3, %eax
movl %eax, -0x2c(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x72973
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movswq -0x5a(%rbp), %rcx
imulq $0x30, %rcx, %rcx
addq %rcx, %rax
cmpb $0x0, 0x28(%rax)
jne 0x72973
movq -0x8(%rbp), %rax
movl 0x54(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x54(%rax)
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rdi
movl -0x30(%rbp), %esi
movq -0x20(%rbp), %rax
movl (%rax), %edx
callq 0x72620
movq -0x40(%rbp), %rdi
movl -0x78(%rbp), %esi
callq 0x6be30
jmp 0x72981
movq -0x68(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x68(%rbp)
jmp 0x72844
jmp 0x72994
jmp 0x72996
cmpl $0x0, -0x2c(%rbp)
jne 0x729da
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x729da
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x729da
movq -0x10(%rbp), %rdi
callq 0x72ec0
cmpl $0x0, %eax
je 0x729d3
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
cmpl $0x2, (%rax)
jg 0x729da
movl $0x5, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x72a8d
movq -0x8(%rbp), %rax
movl 0x1d4(%rax), %eax
movl %eax, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
movl $0x2, -0x2c(%rbp)
movl -0x14(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x72a43
movq -0x8(%rbp), %rax
movl $0x0, 0x1d4(%rax)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movswl 0x30(%rax), %eax
cmpl $0x0, %eax
jge 0x72a41
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x72a41
movl $0x1, -0x2c(%rbp)
jmp 0x72a62
cmpq $0x0, -0x20(%rbp)
je 0x72a60
movq -0x8(%rbp), %rax
movl 0x54(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x54(%rax)
movl %ecx, -0x80(%rbp)
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
jmp 0x72a62
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x80(%rbp), %edx
cmpl $0x1, -0x2c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %ecx
callq 0x6ef40
movl -0x7c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x1d4(%rax)
jmp 0x72a97
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x2c(%rax)
movl -0x2c(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)