// File: /workspace/github_c_makefile_star2_O0/shifengbin[P]bishe/Output/../Persistence/sqlite3.c
// Function: allocateIndexInfo
static sqlite3_index_info *allocateIndexInfo(
  Parse *pParse,
  WhereClause *pWC,
  Bitmask mUnusable,              /* Ignore terms with these prereqs */
  struct SrcList_item *pSrc,
  ExprList *pOrderBy
){
  int i, j;
  int nTerm;
  struct sqlite3_index_constraint *pIdxCons;
  struct sqlite3_index_orderby *pIdxOrderBy;
  struct sqlite3_index_constraint_usage *pUsage;
  WhereTerm *pTerm;
  int nOrderBy;
  sqlite3_index_info *pIdxInfo;

  /* Count the number of possible WHERE clause constraints referring
  ** to this virtual table */
  for(i=nTerm=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
    if( pTerm->leftCursor != pSrc->iCursor ) continue;
    if( pTerm->prereqRight & mUnusable ) continue;
    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
    testcase( pTerm->eOperator & WO_IN );
    testcase( pTerm->eOperator & WO_ISNULL );
    testcase( pTerm->eOperator & WO_IS );
    testcase( pTerm->eOperator & WO_ALL );
    if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue;
    if( pTerm->wtFlags & TERM_VNULL ) continue;
    assert( pTerm->u.leftColumn>=(-1) );
    nTerm++;
  }

  /* If the ORDER BY clause contains only columns in the current 
  ** virtual table then allocate space for the aOrderBy part of
  ** the sqlite3_index_info structure.
  */
  nOrderBy = 0;
  if( pOrderBy ){
    int n = pOrderBy->nExpr;
    for(i=0; i<n; i++){
      Expr *pExpr = pOrderBy->a[i].pExpr;
      if( pExpr->op!=TK_COLUMN || pExpr->iTable!=pSrc->iCursor ) break;
    }
    if( i==n){
      nOrderBy = n;
    }
  }

  /* Allocate the sqlite3_index_info structure
  */
  pIdxInfo = sqlite3DbMallocZero(pParse->db, sizeof(*pIdxInfo)
                           + (sizeof(*pIdxCons) + sizeof(*pUsage))*nTerm
                           + sizeof(*pIdxOrderBy)*nOrderBy );
  if( pIdxInfo==0 ){
    sqlite3ErrorMsg(pParse, "out of memory");
    return 0;
  }

  /* Initialize the structure.  The sqlite3_index_info structure contains
  ** many fields that are declared "const" to prevent xBestIndex from
  ** changing them.  We have to do some funky casting in order to
  ** initialize those fields.
  */
  pIdxCons = (struct sqlite3_index_constraint*)&pIdxInfo[1];
  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
  *(int*)&pIdxInfo->nConstraint = nTerm;
  *(int*)&pIdxInfo->nOrderBy = nOrderBy;
  *(struct sqlite3_index_constraint**)&pIdxInfo->aConstraint = pIdxCons;
  *(struct sqlite3_index_orderby**)&pIdxInfo->aOrderBy = pIdxOrderBy;
  *(struct sqlite3_index_constraint_usage**)&pIdxInfo->aConstraintUsage =
                                                                   pUsage;

  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
    u8 op;
    if( pTerm->leftCursor != pSrc->iCursor ) continue;
    if( pTerm->prereqRight & mUnusable ) continue;
    assert( IsPowerOfTwo(pTerm->eOperator & ~WO_EQUIV) );
    testcase( pTerm->eOperator & WO_IN );
    testcase( pTerm->eOperator & WO_IS );
    testcase( pTerm->eOperator & WO_ISNULL );
    testcase( pTerm->eOperator & WO_ALL );
    if( (pTerm->eOperator & ~(WO_ISNULL|WO_EQUIV|WO_IS))==0 ) continue;
    if( pTerm->wtFlags & TERM_VNULL ) continue;
    assert( pTerm->u.leftColumn>=(-1) );
    pIdxCons[j].iColumn = pTerm->u.leftColumn;
    pIdxCons[j].iTermOffset = i;
    op = (u8)pTerm->eOperator & WO_ALL;
    if( op==WO_IN ) op = WO_EQ;
    if( op==WO_MATCH ){
      op = pTerm->eMatchOp;
    }
    pIdxCons[j].op = op;
    /* The direct assignment in the previous line is possible only because
    ** the WO_ and SQLITE_INDEX_CONSTRAINT_ codes are identical.  The
    ** following asserts verify this fact. */
    assert( WO_EQ==SQLITE_INDEX_CONSTRAINT_EQ );
    assert( WO_LT==SQLITE_INDEX_CONSTRAINT_LT );
    assert( WO_LE==SQLITE_INDEX_CONSTRAINT_LE );
    assert( WO_GT==SQLITE_INDEX_CONSTRAINT_GT );
    assert( WO_GE==SQLITE_INDEX_CONSTRAINT_GE );
    assert( WO_MATCH==SQLITE_INDEX_CONSTRAINT_MATCH );
    assert( pTerm->eOperator & (WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_MATCH) );
    j++;
  }
  for(i=0; i<nOrderBy; i++){
    Expr *pExpr = pOrderBy->a[i].pExpr;
    pIdxOrderBy[i].iColumn = pExpr->iColumn;
    pIdxOrderBy[i].desc = pOrderBy->a[i].sortOrder;
  }

  return pIdxInfo;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x8b251
movq -0x60(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x44(%rcx), %eax
je 0x8b1f7
jmp 0x8b23a
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rax
andq -0x20(%rbp), %rax
cmpq $0x0, %rax
je 0x8b20b
jmp 0x8b23a
movq -0x60(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0xfffff67f, %eax       # imm = 0xFFFFF67F
cmpl $0x0, %eax
jne 0x8b21f
jmp 0x8b23a
movq -0x60(%rbp), %rax
movzwl 0x1c(%rax), %eax
andl $0x0, %eax
cmpl $0x0, %eax
je 0x8b231
jmp 0x8b23a
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x60(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x60(%rbp)
jmp 0x8b1d9
movl $0x0, -0x64(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x8b2ce
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x74(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x8b2be
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movzbl (%rax), %eax
cmpl $0x98, %eax
jne 0x8b2af
movq -0x80(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x44(%rcx), %eax
je 0x8b2b1
jmp 0x8b2be
jmp 0x8b2b3
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8b26f
movl -0x34(%rbp), %eax
cmpl -0x74(%rbp), %eax
jne 0x8b2cc
movl -0x74(%rbp), %eax
movl %eax, -0x64(%rbp)
jmp 0x8b2ce
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x3c(%rbp), %rax
imulq $0x14, %rax, %rsi
addq $0x60, %rsi
movslq -0x64(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x15b80
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x8b31b
movq -0x10(%rbp), %rdi
leaq 0x1aa49(%rip), %rsi     # 0xa5d50
movb $0x0, %al
callq 0x17840
movq $0x0, -0x8(%rbp)
jmp 0x8b527
movq -0x70(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movslq -0x3c(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x64(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, (%rax)
movl -0x64(%rbp), %ecx
movq -0x70(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x48(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x50(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x58(%rbp), %rcx
movq -0x70(%rbp), %rax
movq %rcx, 0x20(%rax)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x60(%rbp)
movl -0x34(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x8b4b0
movq -0x60(%rbp), %rax
movl 0xc(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x44(%rcx), %eax
je 0x8b3c3
jmp 0x8b496
movq -0x60(%rbp), %rax
movq 0x28(%rax), %rax
andq -0x20(%rbp), %rax
cmpq $0x0, %rax
je 0x8b3da
jmp 0x8b496
movq -0x60(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0xfffff67f, %eax       # imm = 0xFFFFF67F
cmpl $0x0, %eax
jne 0x8b3f1
jmp 0x8b496
movq -0x60(%rbp), %rax
movzwl 0x1c(%rax), %eax
andl $0x0, %eax
cmpl $0x0, %eax
je 0x8b406
jmp 0x8b496
movq -0x60(%rbp), %rax
movl 0x10(%rax), %ecx
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %ecx
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x60(%rbp), %rax
movw 0x1a(%rax), %ax
movzbl %al, %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movb %al, -0x81(%rbp)
movzbl -0x81(%rbp), %eax
cmpl $0x1, %eax
jne 0x8b45c
movb $0x2, -0x81(%rbp)
movzbl -0x81(%rbp), %eax
cmpl $0x40, %eax
jne 0x8b475
movq -0x60(%rbp), %rax
movb 0x1f(%rax), %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %cl
movq -0x48(%rbp), %rax
movslq -0x38(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x4(%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x60(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x60(%rbp)
jmp 0x8b39e
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x64(%rbp), %eax
jge 0x8b51f
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movswl 0x30(%rax), %edx
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x34(%rbp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movb 0x18(%rax), %dl
movq -0x50(%rbp), %rax
movslq -0x34(%rbp), %rcx
movb %dl, 0x4(%rax,%rcx,8)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x8b4b7
movq -0x70(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)