// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: whereShortCut
static int whereShortCut(WhereLoopBuilder *pBuilder){
  WhereInfo *pWInfo;
  struct SrcList_item *pItem;
  WhereClause *pWC;
  WhereTerm *pTerm;
  WhereLoop *pLoop;
  int iCur;
  int j;
  Table *pTab;
  Index *pIdx;

  pWInfo = pBuilder->pWInfo;
  if( pWInfo->wctrlFlags & WHERE_OR_SUBCLAUSE ) return 0;
  assert( pWInfo->pTabList->nSrc>=1 );
  pItem = pWInfo->pTabList->a;
  pTab = pItem->pTab;
  if( IsVirtual(pTab) ) return 0;
  if( pItem->fg.isIndexedBy ) return 0;
  iCur = pItem->iCursor;
  pWC = &pWInfo->sWC;
  pLoop = pBuilder->pNew;
  pLoop->wsFlags = 0;
  pLoop->nSkip = 0;
  pTerm = sqlite3WhereFindTerm(pWC, iCur, -1, 0, WO_EQ|WO_IS, 0);
  if( pTerm ){
    testcase( pTerm->eOperator & WO_IS );
    pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_IPK|WHERE_ONEROW;
    pLoop->aLTerm[0] = pTerm;
    pLoop->nLTerm = 1;
    pLoop->u.btree.nEq = 1;
    /* TUNING: Cost of a rowid lookup is 10 */
    pLoop->rRun = 33;  /* 33==sqlite3LogEst(10) */
  }else{
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      int opMask;
      assert( pLoop->aLTermSpace==pLoop->aLTerm );
      if( !IsUniqueIndex(pIdx)
       || pIdx->pPartIdxWhere!=0
       || pIdx->nKeyCol>ArraySize(pLoop->aLTermSpace)
      ) continue;
      opMask = pIdx->uniqNotNull ? (WO_EQ|WO_IS) : WO_EQ;
      for(j=0; j<pIdx->nKeyCol; j++){
        pTerm = sqlite3WhereFindTerm(pWC, iCur, j, 0, opMask, pIdx);
        if( pTerm==0 ) break;
        testcase( pTerm->eOperator & WO_IS );
        pLoop->aLTerm[j] = pTerm;
      }
      if( j!=pIdx->nKeyCol ) continue;
      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
      if( pIdx->isCovering || (pItem->colUsed & pIdx->colNotIdxed)==0 ){
        pLoop->wsFlags |= WHERE_IDX_ONLY;
      }
      pLoop->nLTerm = j;
      pLoop->u.btree.nEq = j;
      pLoop->u.btree.pIndex = pIdx;
      /* TUNING: Cost of a unique index lookup is 15 */
      pLoop->rRun = 39;  /* 39==sqlite3LogEst(15) */
      break;
    }
  }
  if( pLoop->wsFlags ){
    pLoop->nOut = (LogEst)1;
    pWInfo->a[0].pWLoop = pLoop;
    assert( pWInfo->sMaskSet.n==1 && iCur==pWInfo->sMaskSet.ix[0] );
    pLoop->maskSelf = 1; /* sqlite3WhereGetMask(&pWInfo->sMaskSet, iCur); */
    pWInfo->a[0].iTabCur = iCur;
    pWInfo->nRowOut = 1;
    if( pWInfo->pOrderBy ) pWInfo->nOBSat =  pWInfo->pOrderBy->nExpr;
    if( pWInfo->wctrlFlags & WHERE_WANT_DISTINCT ){
      pWInfo->eDistinct = WHERE_DISTINCT_UNIQUE;
    }
#ifdef SQLITE_DEBUG
    pLoop->cId = '0';
#endif
    return 1;
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movzwl 0x3c(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x448e33
movl $0x0, -0x4(%rbp)
jmp 0x449112
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x8, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpl $0x0, 0x54(%rax)
je 0x448e65
movl $0x0, -0x4(%rbp)
jmp 0x449112
movq -0x20(%rbp), %rax
movb 0x3d(%rax), %al
shrb %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x448e84
movl $0x0, -0x4(%rbp)
jmp 0x449112
movq -0x20(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x38(%rbp), %rax
movw $0x0, 0x2e(%rax)
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %r9d
movl $0x82, %r8d
movq %r9, %rcx
callq 0x450560
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x448f22
movq -0x38(%rbp), %rax
movl $0x1101, 0x28(%rax)     # imm = 0x1101
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movw $0x1, 0x2c(%rax)
movq -0x38(%rbp), %rax
movw $0x1, 0x18(%rax)
movq -0x38(%rbp), %rax
movw $0x21, 0x14(%rax)
jmp 0x449084
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x449082
movq -0x50(%rbp), %rax
movzbl 0x62(%rax), %eax
cmpl $0x0, %eax
je 0x448f5e
movq -0x50(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x448f5e
movq -0x50(%rbp), %rax
movzwl 0x5e(%rax), %eax
cmpl $0x3, %eax
jle 0x448f63
jmp 0x449071
movq -0x50(%rbp), %rax
movw 0x63(%rax), %ax
shrw $0x3, %ax
andw $0x1, %ax
movzwl %ax, %edx
movl $0x2, %eax
movl $0x82, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x54(%rbp)
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
movzwl 0x5e(%rcx), %ecx
cmpl %ecx, %eax
jge 0x448fe6
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl -0x40(%rbp), %edx
movl -0x54(%rbp), %r8d
movq -0x50(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
callq 0x450560
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x448fc7
jmp 0x448fe6
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x448f90
movl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
movzwl 0x5e(%rcx), %ecx
cmpl %ecx, %eax
je 0x448ff7
jmp 0x449071
movq -0x38(%rbp), %rax
movl $0x1201, 0x28(%rax)     # imm = 0x1201
movq -0x50(%rbp), %rax
movw 0x63(%rax), %ax
shrw $0x5, %ax
andw $0x1, %ax
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x449030
movq -0x20(%rbp), %rax
movq 0x58(%rax), %rax
movq -0x50(%rbp), %rcx
andq 0x68(%rcx), %rax
cmpq $0x0, %rax
jne 0x44903d
movq -0x38(%rbp), %rax
movl 0x28(%rax), %ecx
orl $0x40, %ecx
movl %ecx, 0x28(%rax)
movl -0x40(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x2c(%rax)
movl -0x40(%rbp), %eax
movw %ax, %cx
movq -0x38(%rbp), %rax
movw %cx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movw $0x27, 0x14(%rax)
jmp 0x449082
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x448f2e
jmp 0x449084
movq -0x38(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x44910b
movq -0x38(%rbp), %rax
movw $0x1, 0x16(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x3e8(%rax)
movq -0x38(%rbp), %rax
movq $0x1, 0x8(%rax)
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x39c(%rax)
movq -0x18(%rbp), %rax
movw $0x1, 0x46(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4490e8
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movl (%rax), %eax
movb %al, %cl
movq -0x18(%rbp), %rax
movb %cl, 0x41(%rax)
movq -0x18(%rbp), %rax
movzwl 0x3c(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x449102
movq -0x18(%rbp), %rax
movb $0x1, 0x43(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x449112
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax,%rax)