// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: whereLoopAddOr
static int whereLoopAddOr(
  WhereLoopBuilder *pBuilder,
  Bitmask mPrereq,
  Bitmask mUnusable
){
  WhereInfo *pWInfo = pBuilder->pWInfo;
  WhereClause *pWC;
  WhereLoop *pNew;
  WhereTerm *pTerm, *pWCEnd;
  int rc = SQLITE_OK;
  int iCur;
  WhereClause tempWC;
  WhereLoopBuilder sSubBuild;
  WhereOrSet sSum, sCur;
  struct SrcList_item *pItem;

  pWC = pBuilder->pWC;
  pWCEnd = pWC->a + pWC->nTerm;
  pNew = pBuilder->pNew;
  memset(&sSum, 0, sizeof(sSum));
  pItem = pWInfo->pTabList->a + pNew->iTab;
  iCur = pItem->iCursor;

  for(pTerm=pWC->a; pTerm<pWCEnd && rc==SQLITE_OK; pTerm++){
    if( (pTerm->eOperator & WO_OR)!=0
     && (pTerm->u.pOrInfo->indexable & pNew->maskSelf)!=0
    ){
      WhereClause * const pOrWC = &pTerm->u.pOrInfo->wc;
      WhereTerm * const pOrWCEnd = &pOrWC->a[pOrWC->nTerm];
      WhereTerm *pOrTerm;
      int once = 1;
      int i, j;

      sSubBuild = *pBuilder;
      sSubBuild.pOrderBy = 0;
      sSubBuild.pOrSet = &sCur;

      WHERETRACE(0x200, ("Begin processing OR-clause %p\n", pTerm));
      for(pOrTerm=pOrWC->a; pOrTerm<pOrWCEnd; pOrTerm++){
        if( (pOrTerm->eOperator & WO_AND)!=0 ){
          sSubBuild.pWC = &pOrTerm->u.pAndInfo->wc;
        }else if( pOrTerm->leftCursor==iCur ){
          tempWC.pWInfo = pWC->pWInfo;
          tempWC.pOuter = pWC;
          tempWC.op = TK_AND;
          tempWC.nTerm = 1;
          tempWC.a = pOrTerm;
          sSubBuild.pWC = &tempWC;
        }else{
          continue;
        }
        sCur.n = 0;
#ifdef WHERETRACE_ENABLED
        WHERETRACE(0x200, ("OR-term %d of %p has %d subterms:\n",
                   (int)(pOrTerm-pOrWC->a), pTerm, sSubBuild.pWC->nTerm));
        if( sqlite3WhereTrace & 0x400 ){
          sqlite3WhereClausePrint(sSubBuild.pWC);
        }
#endif
#ifndef SQLITE_OMIT_VIRTUALTABLE
        if( IsVirtual(pItem->pTab) ){
          rc = whereLoopAddVirtual(&sSubBuild, mPrereq, mUnusable);
        }else
#endif
        {
          rc = whereLoopAddBtree(&sSubBuild, mPrereq);
        }
        if( rc==SQLITE_OK ){
          rc = whereLoopAddOr(&sSubBuild, mPrereq, mUnusable);
        }
        assert( rc==SQLITE_OK || rc==SQLITE_DONE || sCur.n==0 );
        testcase( rc==SQLITE_DONE );
        if( sCur.n==0 ){
          sSum.n = 0;
          break;
        }else if( once ){
          whereOrMove(&sSum, &sCur);
          once = 0;
        }else{
          WhereOrSet sPrev;
          whereOrMove(&sPrev, &sSum);
          sSum.n = 0;
          for(i=0; i<sPrev.n; i++){
            for(j=0; j<sCur.n; j++){
              whereOrInsert(&sSum, sPrev.a[i].prereq | sCur.a[j].prereq,
                            sqlite3LogEstAdd(sPrev.a[i].rRun, sCur.a[j].rRun),
                            sqlite3LogEstAdd(sPrev.a[i].nOut, sCur.a[j].nOut));
            }
          }
        }
      }
      pNew->nLTerm = 1;
      pNew->aLTerm[0] = pTerm;
      pNew->wsFlags = WHERE_MULTI_OR;
      pNew->rSetup = 0;
      pNew->iSortIdx = 0;
      memset(&pNew->u, 0, sizeof(pNew->u));
      for(i=0; rc==SQLITE_OK && i<sSum.n; i++){
        /* TUNING: Currently sSum.a[i].rRun is set to the sum of the costs
        ** of all sub-scans required by the OR-scan. However, due to rounding
        ** errors, it may be that the cost of the OR-scan is equal to its
        ** most expensive sub-scan. Add the smallest possible penalty
        ** (equivalent to multiplying the cost by 1.07) to ensure that
        ** this does not happen. Otherwise, for WHERE clauses such as the
        ** following where there is an index on "y":
        **
        **     WHERE likelihood(x=?, 0.99) OR y=?
        **
        ** the planner may elect to "OR" together a full-table scan and an
        ** index lookup. And other similarly odd results.  */
        pNew->rRun = sSum.a[i].rRun + 1;
        pNew->nOut = sSum.a[i].nOut;
        pNew->prereq = sSum.a[i].prereq;
        rc = whereLoopInsert(pBuilder, pNew);
      }
      WHERETRACE(0x200, ("End processing OR-clause %p\n", pTerm));
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x390, %rsp            # imm = 0x390
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0x2d8(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x19360
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x8, %rax
movq -0x30(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
movslq %ecx, %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x318(%rbp)
movq -0x318(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
xorl %eax, %eax
cmpq -0x40(%rbp), %rcx
movb %al, -0x379(%rbp)
jae 0x451d3c
cmpl $0x0, -0x44(%rbp)
sete %al
movb %al, -0x379(%rbp)
movb -0x379(%rbp), %al
testb $0x1, %al
jne 0x451d4b
jmp 0x452202
movq -0x38(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x4521ef
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x228(%rax), %rax
movq -0x30(%rbp), %rcx
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
je 0x4521ef
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x320(%rbp)
movq -0x320(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x320(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movq %rax, -0x328(%rbp)
movl $0x1, -0x334(%rbp)
movq -0x8(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
movl $0x30, %edx
callq 0x19610
movq $0x0, -0x290(%rbp)
leaq -0x310(%rbp), %rax
movq %rax, -0x280(%rbp)
movq -0x320(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x330(%rbp)
movq -0x330(%rbp), %rax
cmpq -0x328(%rbp), %rax
jae 0x4520cd
movq -0x330(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x400, %eax            # imm = 0x400
cmpl $0x0, %eax
je 0x451e3c
movq -0x330(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x298(%rbp)
jmp 0x451e9a
movq -0x330(%rbp), %rax
movl 0x1c(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x451e93
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x270(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x268(%rbp)
movb $0x2c, -0x260(%rbp)
movl $0x1, -0x25c(%rbp)
movq -0x330(%rbp), %rax
movq %rax, -0x250(%rbp)
leaq -0x270(%rbp), %rax
movq %rax, -0x298(%rbp)
jmp 0x451e98
jmp 0x4520b6
jmp 0x451e9a
movw $0x0, -0x310(%rbp)
movq -0x318(%rbp), %rax
movq 0x20(%rax), %rax
cmpl $0x0, 0x54(%rax)
je 0x451ecd
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x450df0
movl %eax, -0x44(%rbp)
jmp 0x451ee0
movq -0x10(%rbp), %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x4511d0
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
jne 0x451efd
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
leaq -0x2a0(%rbp), %rdi
callq 0x451c70
movl %eax, -0x44(%rbp)
movzwl -0x310(%rbp), %eax
cmpl $0x0, %eax
jne 0x451f17
movw $0x0, -0x2d8(%rbp)
jmp 0x4520cd
cmpl $0x0, -0x334(%rbp)
je 0x451f42
leaq -0x2d8(%rbp), %rdi
leaq -0x310(%rbp), %rsi
callq 0x455010
movl $0x0, -0x334(%rbp)
jmp 0x4520b2
leaq -0x378(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
callq 0x455010
movw $0x0, -0x2d8(%rbp)
movl $0x0, -0x338(%rbp)
movl -0x338(%rbp), %eax
movzwl -0x378(%rbp), %ecx
cmpl %ecx, %eax
jge 0x4520b0
movl $0x0, -0x33c(%rbp)
movl -0x33c(%rbp), %eax
movzwl -0x310(%rbp), %ecx
cmpl %ecx, %eax
jge 0x45209a
leaq -0x378(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
leaq -0x310(%rbp), %rcx
addq $0x8, %rcx
movslq -0x33c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
orq (%rcx), %rax
movq %rax, -0x388(%rbp)
leaq -0x378(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0x8(%rax), %cx
leaq -0x310(%rbp), %rax
addq $0x8, %rax
movslq -0x33c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movswl %cx, %edi
movswl 0x8(%rax), %esi
callq 0x447b70
movw %ax, -0x37c(%rbp)
leaq -0x378(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0xa(%rax), %cx
leaq -0x310(%rbp), %rax
addq $0x8, %rax
movslq -0x33c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movswl %cx, %edi
movswl 0xa(%rax), %esi
callq 0x447b70
movq -0x388(%rbp), %rsi
movw -0x37c(%rbp), %cx
leaq -0x2d8(%rbp), %rdi
movswl %cx, %edx
movswl %ax, %ecx
callq 0x453250
movl -0x33c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x33c(%rbp)
jmp 0x451f87
jmp 0x45209c
movl -0x338(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x338(%rbp)
jmp 0x451f68
jmp 0x4520b2
jmp 0x4520b4
jmp 0x4520b6
movq -0x330(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x330(%rbp)
jmp 0x451dff
movq -0x30(%rbp), %rax
movw $0x1, 0x2c(%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rcx, (%rax)
movq -0x30(%rbp), %rax
movl $0x2000, 0x28(%rax)     # imm = 0x2000
movq -0x30(%rbp), %rax
movw $0x0, 0x12(%rax)
movq -0x30(%rbp), %rax
movb $0x0, 0x11(%rax)
movq -0x30(%rbp), %rdi
addq $0x18, %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x19360
movl $0x0, -0x338(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x44(%rbp)
movb %al, -0x389(%rbp)
jne 0x452147
movl -0x338(%rbp), %eax
movzwl -0x2d8(%rbp), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x389(%rbp)
movb -0x389(%rbp), %al
testb $0x1, %al
jne 0x452156
jmp 0x4521ed
leaq -0x2d8(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movswl 0x8(%rax), %eax
addl $0x1, %eax
movw %ax, %cx
movq -0x30(%rbp), %rax
movw %cx, 0x14(%rax)
leaq -0x2d8(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0xa(%rax), %cx
movq -0x30(%rbp), %rax
movw %cx, 0x16(%rax)
leaq -0x2d8(%rbp), %rax
addq $0x8, %rax
movslq -0x338(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x452f50
movl %eax, -0x44(%rbp)
movl -0x338(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x338(%rbp)
jmp 0x452121
jmp 0x4521ef
jmp 0x4521f1
movq -0x38(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x38(%rbp)
jmp 0x451d1d
movl -0x44(%rbp), %eax
addq $0x390, %rsp            # imm = 0x390
popq %rbp
retq
nop