// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: allocateIndexInfo
static sqlite3_index_info *allocateIndexInfo(
  Parse *pParse,                  /* The parsing context */
  WhereClause *pWC,               /* The WHERE clause being analyzed */
  Bitmask mUnusable,              /* Ignore terms with these prereqs */
  struct SrcList_item *pSrc,      /* The FROM clause term that is the vtab */
  ExprList *pOrderBy,             /* The ORDER BY clause */
  u16 *pmNoOmit                   /* Mask of terms not to omit */
){
  int i, j;
  int nTerm;
  struct sqlite3_index_constraint *pIdxCons;
  struct sqlite3_index_orderby *pIdxOrderBy;
  struct sqlite3_index_constraint_usage *pUsage;
  struct HiddenIndexInfo *pHidden;
  WhereTerm *pTerm;
  int nOrderBy;
  sqlite3_index_info *pIdxInfo;
  u16 mNoOmit = 0;

  /* 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_EQUIV))==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( pOrderBy->a[i].sortFlags & KEYINFO_ORDER_BIGNULL ) 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 + sizeof(*pHidden) );
  if( pIdxInfo==0 ){
    sqlite3ErrorMsg(pParse, "out of memory");
    return 0;
  }
  pHidden = (struct HiddenIndexInfo*)&pIdxInfo[1];
  pIdxCons = (struct sqlite3_index_constraint*)&pHidden[1];
  pIdxOrderBy = (struct sqlite3_index_orderby*)&pIdxCons[nTerm];
  pUsage = (struct sqlite3_index_constraint_usage*)&pIdxOrderBy[nOrderBy];
  pIdxInfo->nOrderBy = nOrderBy;
  pIdxInfo->aConstraint = pIdxCons;
  pIdxInfo->aOrderBy = pIdxOrderBy;
  pIdxInfo->aConstraintUsage = pUsage;
  pHidden->pWC = pWC;
  pHidden->pParse = pParse;
  for(i=j=0, pTerm=pWC->a; i<pWC->nTerm; i++, pTerm++){
    u16 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_EQUIV))==0 ) continue;
    if( pTerm->wtFlags & TERM_VNULL ) continue;

    /* tag-20191211-002: WHERE-clause constraints are not useful to the
    ** right-hand table of a LEFT JOIN.  See tag-20191211-001 for the
    ** equivalent restriction for ordinary tables. */
    if( (pSrc->fg.jointype & JT_LEFT)!=0
     && !ExprHasProperty(pTerm->pExpr, EP_FromJoin)
    ){
      continue;
    }
    assert( pTerm->u.leftColumn>=(-1) );
    pIdxCons[j].iColumn = pTerm->u.leftColumn;
    pIdxCons[j].iTermOffset = i;
    op = pTerm->eOperator & WO_ALL;
    if( op==WO_IN ) op = WO_EQ;
    if( op==WO_AUX ){
      pIdxCons[j].op = pTerm->eMatchOp;
    }else if( op & (WO_ISNULL|WO_IS) ){
      if( op==WO_ISNULL ){
        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_ISNULL;
      }else{
        pIdxCons[j].op = SQLITE_INDEX_CONSTRAINT_IS;
      }
    }else{
      pIdxCons[j].op = (u8)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( pTerm->eOperator&(WO_IN|WO_EQ|WO_LT|WO_LE|WO_GT|WO_GE|WO_AUX) );

      if( op & (WO_LT|WO_LE|WO_GT|WO_GE)
       && sqlite3ExprIsVector(pTerm->pExpr->pRight)
      ){
        testcase( j!=i );
        if( j<16 ) mNoOmit |= (1 << j);
        if( op==WO_LT ) pIdxCons[j].op = WO_LE;
        if( op==WO_GT ) pIdxCons[j].op = WO_GE;
      }
    }

    j++;
  }
  pIdxInfo->nConstraint = j;
  for(i=0; i<nOrderBy; i++){
    Expr *pExpr = pOrderBy->a[i].pExpr;
    pIdxOrderBy[i].iColumn = pExpr->iColumn;
    pIdxOrderBy[i].desc = pOrderBy->a[i].sortFlags & KEYINFO_ORDER_DESC;
  }

  *pmNoOmit = mNoOmit;
  return pIdxInfo;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movw $0x0, -0x82(%rbp)
movl $0x0, -0x44(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movl -0x3c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x45232e
movq -0x70(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x40(%rcx), %eax
je 0x4522d4
jmp 0x452317
movq -0x70(%rbp), %rax
movq 0x30(%rax), %rax
andq -0x20(%rbp), %rax
cmpq $0x0, %rax
je 0x4522e8
jmp 0x452317
movq -0x70(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
cmpl $0x0, %eax
jne 0x4522fc
jmp 0x452317
movq -0x70(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0x0, %eax
cmpl $0x0, %eax
je 0x45230e
jmp 0x452317
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x70(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x70(%rbp)
jmp 0x4522b6
movl $0x0, -0x74(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x4523e5
movq -0x30(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x88(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x88(%rbp), %eax
jge 0x4523cf
movq -0x30(%rbp), %rax
addq $0x8, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xa4, %eax
jne 0x45239f
movq -0x90(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x40(%rcx), %eax
je 0x4523a1
jmp 0x4523cf
movq -0x30(%rbp), %rax
addq $0x8, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4523c2
jmp 0x4523cf
jmp 0x4523c4
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x452353
movl -0x3c(%rbp), %eax
cmpl -0x88(%rbp), %eax
jne 0x4523e3
movl -0x88(%rbp), %eax
movl %eax, -0x74(%rbp)
jmp 0x4523e5
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movslq -0x44(%rbp), %rax
imulq $0x14, %rax, %rsi
addq $0x60, %rsi
movslq -0x74(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
addq $0x10, %rsi
callq 0x3c9520
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
jne 0x452436
movq -0x10(%rbp), %rdi
leaq 0xf412e(%rip), %rsi     # 0x546550
movb $0x0, %al
callq 0x3cb660
movq $0x0, -0x8(%rbp)
jmp 0x45278a
movq -0x80(%rbp), %rax
addq $0x60, %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
addq $0x10, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movslq -0x74(%rbp), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, -0x60(%rbp)
movl -0x74(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x50(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x60(%rbp), %rcx
movq -0x80(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x18(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rcx
movq -0x68(%rbp), %rax
movq %rcx, 0x8(%rax)
movl $0x0, -0x40(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x70(%rbp)
movl -0x3c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0x14(%rcx), %eax
jge 0x4526f6
movq -0x70(%rbp), %rax
movl 0x1c(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl 0x40(%rcx), %eax
je 0x4524f8
jmp 0x4526dc
movq -0x70(%rbp), %rax
movq 0x30(%rax), %rax
andq -0x20(%rbp), %rax
cmpq $0x0, %rax
je 0x45250f
jmp 0x4526dc
movq -0x70(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
cmpl $0x0, %eax
jne 0x452526
jmp 0x4526dc
movq -0x70(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0x0, %eax
cmpl $0x0, %eax
je 0x45253b
jmp 0x4526dc
movq -0x28(%rbp), %rax
movzbl 0x3c(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x452562
movq -0x70(%rbp), %rax
movq (%rax), %rax
movl 0x4(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x452562
jmp 0x4526dc
movq -0x70(%rbp), %rax
movl 0x28(%rax), %ecx
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movl %ecx, 0x8(%rax)
movq -0x70(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x1fff, %eax           # imm = 0x1FFF
movw %ax, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x1, %eax
jne 0x4525b8
movw $0x2, -0x92(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x40, %eax
jne 0x4525e2
movq -0x70(%rbp), %rax
movb 0x17(%rax), %cl
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x4(%rax)
jmp 0x4526d3
movzwl -0x92(%rbp), %eax
andl $0x180, %eax            # imm = 0x180
cmpl $0x0, %eax
je 0x45262e
movzwl -0x92(%rbp), %eax
cmpl $0x100, %eax            # imm = 0x100
jne 0x452616
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb $0x47, 0x4(%rax)
jmp 0x452629
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb $0x48, 0x4(%rax)
jmp 0x4526d1
movw -0x92(%rbp), %ax
movb %al, %cl
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rax
movb %cl, 0x4(%rax)
movzwl -0x92(%rbp), %eax
andl $0x3c, %eax
cmpl $0x0, %eax
je 0x4526cf
movq -0x70(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdi
callq 0x42c210
cmpl $0x0, %eax
je 0x4526cf
cmpl $0x10, -0x40(%rbp)
jge 0x45268f
movl -0x40(%rbp), %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, %ecx
movzwl -0x82(%rbp), %eax
orl %ecx, %eax
movw %ax, -0x82(%rbp)
movzwl -0x92(%rbp), %eax
cmpl $0x10, %eax
jne 0x4526ae
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb $0x8, 0x4(%rax)
movzwl -0x92(%rbp), %eax
cmpl $0x4, %eax
jne 0x4526cd
movq -0x50(%rbp), %rax
movslq -0x40(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movb $0x20, 0x4(%rax)
jmp 0x4526cf
jmp 0x4526d1
jmp 0x4526d3
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
movq -0x70(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x70(%rbp)
jmp 0x4524d3
movl -0x40(%rbp), %ecx
movq -0x80(%rbp), %rax
movl %ecx, (%rax)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x74(%rbp), %eax
jge 0x452774
movq -0x30(%rbp), %rax
addq $0x8, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rax
movswl 0x30(%rax), %edx
movq -0x58(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
movq -0x30(%rbp), %rax
addq $0x8, %rax
movslq -0x3c(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movzbl 0x10(%rax), %eax
andl $0x1, %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movb %dl, 0x4(%rax,%rcx,8)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x452706
movw -0x82(%rbp), %cx
movq -0x38(%rbp), %rax
movw %cx, (%rax)
movq -0x80(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw (%rax,%rax)