// File: /workspace/github_c_makefile_star2_O0/barabo[P]advanced-shell-history/src/sqlite3.c
// Function: whereLoopAddOr
static int whereLoopAddOr(WhereLoopBuilder *pBuilder, Bitmask mExtra){
  WhereInfo *pWInfo = pBuilder->pWInfo;
  WhereClause *pWC;
  WhereLoop *pNew;
  WhereTerm *pTerm, *pWCEnd;
  int rc = SQLITE_OK;
  int iCur;
  WhereClause tempWC;
  WhereLoopBuilder sSubBuild;
  WhereOrSet sSum, sCur, sPrev;
  struct SrcList_item *pItem;
  
  pWC = pBuilder->pWC;
  if( pWInfo->wctrlFlags & WHERE_AND_ONLY ) return SQLITE_OK;
  pWCEnd = pWC->a + pWC->nTerm;
  pNew = pBuilder->pNew;
  memset(&sSum, 0, sizeof(sSum));

  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;
    
      pItem = pWInfo->pTabList->a + pNew->iTab;
      iCur = pItem->iCursor;
      sSubBuild = *pBuilder;
      sSubBuild.pOrderBy = 0;
      sSubBuild.pOrSet = &sCur;

      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;
#ifndef SQLITE_OMIT_VIRTUALTABLE
        if( IsVirtual(pItem->pTab) ){
          rc = whereLoopAddVirtual(&sSubBuild);
          for(i=0; i<sCur.n; i++) sCur.a[i].prereq |= mExtra;
        }else
#endif
        {
          rc = whereLoopAddBtree(&sSubBuild, mExtra);
        }
        assert( rc==SQLITE_OK || sCur.n==0 );
        if( sCur.n==0 ){
          sSum.n = 0;
          break;
        }else if( once ){
          whereOrMove(&sSum, &sCur);
          once = 0;
        }else{
          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,
                            whereCostAdd(sPrev.a[i].rRun, sCur.a[j].rRun),
                            whereCostAdd(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: Multiple by 3.5 for the secondary table lookup */
        pNew->rRun = sSum.a[i].rRun + 18;
        pNew->nOut = sSum.a[i].nOut;
        pNew->prereq = sSum.a[i].prereq;
        rc = whereLoopInsert(pBuilder, pNew);
      }
    }
  }
  return rc;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x340, %rsp            # imm = 0x340
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x44(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movzwl 0x32(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x7868f
movl $0x0, -0x4(%rbp)
jmp 0x78c22
movq -0x28(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x14(%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
leaq -0x290(%rbp), %rdi
xorl %esi, %esi
movl $0x38, %edx
callq 0x8200
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, -0x32d(%rbp)
jae 0x786f4
cmpl $0x0, -0x44(%rbp)
sete %al
movb %al, -0x32d(%rbp)
movb -0x32d(%rbp), %al
testb $0x1, %al
jne 0x78703
jmp 0x78c1c
movq -0x38(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x78c09
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq 0x1e8(%rax), %rax
movq -0x30(%rbp), %rcx
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
je 0x78c09
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x310(%rbp)
movq -0x310(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x310(%rbp), %rcx
movslq 0x14(%rcx), %rcx
imulq $0x38, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x318(%rbp)
movl $0x1, -0x324(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x8, %rax
movq -0x30(%rbp), %rcx
movzbl 0x10(%rcx), %ecx
movslq %ecx, %rcx
imulq $0x68, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x308(%rbp)
movq -0x308(%rbp), %rax
movl 0x3c(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x10(%rbp), %rsi
leaq -0x258(%rbp), %rdi
movl $0x28, %edx
callq 0x82f0
movq $0x0, -0x248(%rbp)
leaq -0x2c8(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x310(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x320(%rbp)
movq -0x320(%rbp), %rax
cmpq -0x318(%rbp), %rax
jae 0x78ae7
movq -0x320(%rbp), %rax
movzwl 0x18(%rax), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x78826
movq -0x320(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x250(%rbp)
jmp 0x78884
movq -0x320(%rbp), %rax
movl 0xc(%rax), %eax
cmpl -0x48(%rbp), %eax
jne 0x7887d
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x230(%rbp)
movq -0x28(%rbp), %rax
movq %rax, -0x228(%rbp)
movb $0x45, -0x220(%rbp)
movl $0x1, -0x21c(%rbp)
movq -0x320(%rbp), %rax
movq %rax, -0x210(%rbp)
leaq -0x230(%rbp), %rax
movq %rax, -0x250(%rbp)
jmp 0x78882
jmp 0x78ad0
jmp 0x78884
movw $0x0, -0x2c8(%rbp)
movq -0x308(%rbp), %rax
movq 0x20(%rax), %rax
movzbl 0x46(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x78904
leaq -0x258(%rbp), %rdi
callq 0x778f0
movl %eax, -0x44(%rbp)
movl $0x0, -0x328(%rbp)
movl -0x328(%rbp), %eax
movzwl -0x2c8(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78902
movq -0x18(%rbp), %rcx
leaq -0x2c8(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
orq (%rax), %rcx
movq %rcx, (%rax)
movl -0x328(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x328(%rbp)
jmp 0x788bd
jmp 0x78917
movq -0x18(%rbp), %rsi
leaq -0x258(%rbp), %rdi
callq 0x77f50
movl %eax, -0x44(%rbp)
movzwl -0x2c8(%rbp), %eax
cmpl $0x0, %eax
jne 0x78931
movw $0x0, -0x290(%rbp)
jmp 0x78ae7
cmpl $0x0, -0x324(%rbp)
je 0x7895c
leaq -0x290(%rbp), %rdi
leaq -0x2c8(%rbp), %rsi
callq 0x7a570
movl $0x0, -0x324(%rbp)
jmp 0x78acc
leaq -0x300(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x7a570
movw $0x0, -0x290(%rbp)
movl $0x0, -0x328(%rbp)
movl -0x328(%rbp), %eax
movzwl -0x300(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78aca
movl $0x0, -0x32c(%rbp)
movl -0x32c(%rbp), %eax
movzwl -0x2c8(%rbp), %ecx
cmpl %ecx, %eax
jge 0x78ab4
leaq -0x300(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
leaq -0x2c8(%rbp), %rcx
addq $0x8, %rcx
movslq -0x32c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rcx
orq (%rcx), %rax
movq %rax, -0x338(%rbp)
leaq -0x300(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0x8(%rax), %cx
leaq -0x2c8(%rbp), %rax
addq $0x8, %rax
movslq -0x32c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movzwl %cx, %edi
movzwl 0x8(%rax), %esi
callq 0x79a10
movw %ax, -0x330(%rbp)
leaq -0x300(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0xa(%rax), %cx
leaq -0x2c8(%rbp), %rax
addq $0x8, %rax
movslq -0x32c(%rbp), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movzwl %cx, %edi
movzwl 0xa(%rax), %esi
callq 0x79a10
movq -0x338(%rbp), %rsi
movw -0x330(%rbp), %cx
leaq -0x290(%rbp), %rdi
movzwl %cx, %edx
movzwl %ax, %ecx
callq 0x795a0
movl -0x32c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x32c(%rbp)
jmp 0x789a1
jmp 0x78ab6
movl -0x328(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x328(%rbp)
jmp 0x78982
jmp 0x78acc
jmp 0x78ace
jmp 0x78ad0
movq -0x320(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x320(%rbp)
jmp 0x787e9
movq -0x30(%rbp), %rax
movw $0x1, 0x2c(%rax)
movq -0x38(%rbp), %rcx
movq -0x30(%rbp), %rax
movq 0x30(%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 0x8200
movl $0x0, -0x328(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x44(%rbp)
movb %al, -0x339(%rbp)
jne 0x78b61
movl -0x328(%rbp), %eax
movzwl -0x290(%rbp), %ecx
cmpl %ecx, %eax
setl %al
movb %al, -0x339(%rbp)
movb -0x339(%rbp), %al
testb $0x1, %al
jne 0x78b70
jmp 0x78c07
leaq -0x290(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movzwl 0x8(%rax), %eax
addl $0x12, %eax
movw %ax, %cx
movq -0x30(%rbp), %rax
movw %cx, 0x14(%rax)
leaq -0x290(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movw 0xa(%rax), %cx
movq -0x30(%rbp), %rax
movw %cx, 0x16(%rax)
leaq -0x290(%rbp), %rax
addq $0x8, %rax
movslq -0x328(%rbp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x79260
movl %eax, -0x44(%rbp)
movl -0x328(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x328(%rbp)
jmp 0x78b3b
jmp 0x78c09
jmp 0x78c0b
movq -0x38(%rbp), %rax
addq $0x38, %rax
movq %rax, -0x38(%rbp)
jmp 0x786d5
movl -0x44(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x340, %rsp            # imm = 0x340
popq %rbp
retq
nop