// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/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_FORCE_TABLE ) return 0;
  assert( pWInfo->pTabList->nSrc>=1 );
  pItem = pWInfo->pTabList->a;
  pTab = pItem->pTab;
  if( IsVirtual(pTab) ) return 0;
  if( pItem->zIndex ) return 0;
  iCur = pItem->iCursor;
  pWC = &pWInfo->sWC;
  pLoop = pBuilder->pNew;
  pLoop->wsFlags = 0;
  pTerm = findTerm(pWC, iCur, -1, 0, WO_EQ, 0);
  if( pTerm ){
    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==whereCost(10) */
  }else{
    for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
      assert( pLoop->aLTermSpace==pLoop->aLTerm );
      assert( ArraySize(pLoop->aLTermSpace)==4 );
      if( pIdx->onError==OE_None 
       || pIdx->pPartIdxWhere!=0 
       || pIdx->nColumn>ArraySize(pLoop->aLTermSpace) 
      ) continue;
      for(j=0; j<pIdx->nColumn; j++){
        pTerm = findTerm(pWC, iCur, pIdx->aiColumn[j], 0, WO_EQ, pIdx);
        if( pTerm==0 ) break;
        pLoop->aLTerm[j] = pTerm;
      }
      if( j!=pIdx->nColumn ) continue;
      pLoop->wsFlags = WHERE_COLUMN_EQ|WHERE_ONEROW|WHERE_INDEXED;
      if( (pItem->colUsed & ~columnsInIndex(pIdx))==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==whereCost(15) */
      break;
    }
  }
  if( pLoop->wsFlags ){
    pLoop->nOut = (WhereCost)1;
    pWInfo->a[0].pWLoop = pLoop;
    pLoop->maskSelf = getMask(&pWInfo->sMaskSet, iCur);
    pWInfo->a[0].iTabCur = iCur;
    pWInfo->nRowOut = 1;
    if( pWInfo->pOrderBy ) pWInfo->bOBSat =  1;
    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 0x32(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x71ff3
movl $0x0, -0x4(%rbp)
jmp 0x722b0
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
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x7202b
movl $0x0, -0x4(%rbp)
jmp 0x722b0
movq -0x20(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0x72042
movl $0x0, -0x4(%rbp)
jmp 0x722b0
movq -0x20(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x3c(%rbp)
movq -0x18(%rbp), %rax
addq $0x150, %rax            # imm = 0x150
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 -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %eax, %eax
movl %eax, %r9d
movl $0x2, %r8d
movq %r9, %rcx
callq 0x77230
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x720d9
movq -0x38(%rbp), %rax
movl $0x1101, 0x28(%rax)     # imm = 0x1101
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movq %rcx, (%rax)
movq -0x38(%rbp), %rax
movw $0x1, 0x2c(%rax)
movq -0x38(%rbp), %rax
movl $0x1, 0x18(%rax)
movq -0x38(%rbp), %rax
movw $0x21, 0x14(%rax)
jmp 0x7221a
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x72218
movq -0x50(%rbp), %rax
movzbl 0x56(%rax), %eax
cmpl $0x0, %eax
je 0x72115
movq -0x50(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x72115
movq -0x50(%rbp), %rax
movzwl 0x54(%rax), %eax
cmpl $0x4, %eax
jle 0x7211a
jmp 0x72207
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
movzwl 0x54(%rcx), %ecx
cmpl %ecx, %eax
jge 0x72185
movq -0x28(%rbp), %rdi
movl -0x3c(%rbp), %esi
movq -0x50(%rbp), %rax
movq 0x8(%rax), %rax
movslq -0x40(%rbp), %rcx
movl (%rax,%rcx,4), %edx
movq -0x50(%rbp), %r9
xorl %eax, %eax
movl %eax, %ecx
movl $0x2, %r8d
callq 0x77230
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x72166
jmp 0x72185
movq -0x30(%rbp), %rdx
movq -0x38(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x40(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x72121
movl -0x40(%rbp), %eax
movq -0x50(%rbp), %rcx
movzwl 0x54(%rcx), %ecx
cmpl %ecx, %eax
je 0x72196
jmp 0x72207
movq -0x38(%rbp), %rax
movl $0x1201, 0x28(%rax)     # imm = 0x1201
movq -0x20(%rbp), %rax
movq 0x50(%rax), %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
callq 0x77880
movq %rax, %rcx
movq -0x58(%rbp), %rax
xorq $-0x1, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
jne 0x721d7
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), %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x50(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x38(%rbp), %rax
movw $0x27, 0x14(%rax)
jmp 0x72218
movq -0x50(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x720e5
jmp 0x7221a
movq -0x38(%rbp), %rax
cmpl $0x0, 0x28(%rax)
je 0x722a9
movq -0x38(%rbp), %rax
movw $0x1, 0x16(%rax)
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x378(%rax)
movq -0x18(%rbp), %rdi
addq $0x4c, %rdi
movl -0x3c(%rbp), %esi
callq 0x72c50
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x3c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x33c(%rax)
movq -0x18(%rbp), %rax
movw $0x1, 0x30(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x72286
movq -0x18(%rbp), %rax
movb $0x1, 0x34(%rax)
movq -0x18(%rbp), %rax
movzwl 0x32(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x722a0
movq -0x18(%rbp), %rax
movb $0x1, 0x37(%rax)
movl $0x1, -0x4(%rbp)
jmp 0x722b0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)