// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: whereLoopOutputAdjust
static void whereLoopOutputAdjust(
  WhereClause *pWC,      /* The WHERE clause */
  WhereLoop *pLoop,      /* The loop to adjust downward */
  LogEst nRow            /* Number of rows in the entire table */
){
  WhereTerm *pTerm, *pX;
  Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf);
  int i, j;
  LogEst iReduce = 0;    /* pLoop->nOut should not exceed nRow-iReduce */

  assert( (pLoop->wsFlags & WHERE_AUTO_INDEX)==0 );
  for(i=pWC->nTerm, pTerm=pWC->a; i>0; i--, pTerm++){
    assert( pTerm!=0 );
    if( (pTerm->wtFlags & TERM_VIRTUAL)!=0 ) break;
    if( (pTerm->prereqAll & pLoop->maskSelf)==0 ) continue;
    if( (pTerm->prereqAll & notAllowed)!=0 ) continue;
    for(j=pLoop->nLTerm-1; j>=0; j--){
      pX = pLoop->aLTerm[j];
      if( pX==0 ) continue;
      if( pX==pTerm ) break;
      if( pX->iParent>=0 && (&pWC->a[pX->iParent])==pTerm ) break;
    }
    if( j<0 ){
      if( pTerm->truthProb<=0 ){
        /* If a truth probability is specified using the likelihood() hints,
        ** then use the probability provided by the application. */
        pLoop->nOut += pTerm->truthProb;
      }else{
        /* In the absence of explicit truth probabilities, use heuristics to
        ** guess a reasonable truth probability. */
        pLoop->nOut--;
        if( (pTerm->eOperator&(WO_EQ|WO_IS))!=0
         && (pTerm->wtFlags & TERM_HIGHTRUTH)==0  /* tag-20200224-1 */
        ){
          Expr *pRight = pTerm->pExpr->pRight;
          int k = 0;
          testcase( pTerm->pExpr->op==TK_IS );
          if( sqlite3ExprIsInteger(pRight, &k) && k>=(-1) && k<=1 ){
            k = 10;
          }else{
            k = 20;
          }
          if( iReduce<k ){
            pTerm->wtFlags |= TERM_HEURTRUTH;
            iReduce = k;
          }
        }
      }
    }
  }
  if( pLoop->nOut > nRow-iReduce )  pLoop->nOut = nRow - iReduce;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movw %dx, %ax
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movw %ax, -0x12(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq -0x10(%rbp), %rcx
orq 0x8(%rcx), %rax
xorq $-0x1, %rax
movq %rax, -0x30(%rbp)
movw $0x0, -0x3a(%rbp)
movq -0x8(%rbp), %rax
movl 0x14(%rax), %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
cmpl $0x0, -0x34(%rbp)
jle 0x453f0a
movq -0x20(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x453d79
jmp 0x453f0a
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
movq -0x10(%rbp), %rcx
andq 0x8(%rcx), %rax
cmpq $0x0, %rax
jne 0x453d94
jmp 0x453ef0
movq -0x20(%rbp), %rax
movq 0x38(%rax), %rax
andq -0x30(%rbp), %rax
cmpq $0x0, %rax
je 0x453dab
jmp 0x453ef0
movq -0x10(%rbp), %rax
movzwl 0x2c(%rax), %eax
subl $0x1, %eax
movl %eax, -0x38(%rbp)
cmpl $0x0, -0x38(%rbp)
jl 0x453e1e
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movslq -0x38(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x453ddc
jmp 0x453e13
movq -0x28(%rbp), %rax
cmpq -0x20(%rbp), %rax
jne 0x453de8
jmp 0x453e1e
movq -0x28(%rbp), %rax
cmpl $0x0, 0x18(%rax)
jl 0x453e11
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x28(%rbp), %rcx
movslq 0x18(%rcx), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
cmpq -0x20(%rbp), %rax
jne 0x453e11
jmp 0x453e1e
jmp 0x453e13
movl -0x38(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x453db9
cmpl $0x0, -0x38(%rbp)
jge 0x453eee
movq -0x20(%rbp), %rax
movswl 0x10(%rax), %eax
cmpl $0x0, %eax
jg 0x453e50
movq -0x20(%rbp), %rax
movswl 0x10(%rax), %edx
movq -0x10(%rbp), %rax
movswl 0x16(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x16(%rax)
jmp 0x453eec
movq -0x10(%rbp), %rax
movw 0x16(%rax), %cx
addw $-0x1, %cx
movw %cx, 0x16(%rax)
movq -0x20(%rbp), %rax
movzwl 0x14(%rax), %eax
andl $0x82, %eax
cmpl $0x0, %eax
je 0x453eea
movq -0x20(%rbp), %rax
movzwl 0x12(%rax), %eax
andl $0x0, %eax
cmpl $0x0, %eax
jne 0x453eea
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movq -0x48(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x43bf50
cmpl $0x0, %eax
je 0x453ebf
cmpl $-0x1, -0x4c(%rbp)
jl 0x453ebf
cmpl $0x1, -0x4c(%rbp)
jg 0x453ebf
movl $0xa, -0x4c(%rbp)
jmp 0x453ec6
movl $0x14, -0x4c(%rbp)
movswl -0x3a(%rbp), %eax
cmpl -0x4c(%rbp), %eax
jge 0x453ee8
movq -0x20(%rbp), %rax
movzwl 0x12(%rax), %ecx
orl $0x2000, %ecx           # imm = 0x2000
movw %cx, 0x12(%rax)
movl -0x4c(%rbp), %eax
movw %ax, -0x3a(%rbp)
jmp 0x453eea
jmp 0x453eec
jmp 0x453eee
jmp 0x453ef0
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x20(%rbp)
jmp 0x453d5a
movq -0x10(%rbp), %rax
movswl 0x16(%rax), %eax
movswl -0x12(%rbp), %ecx
movswl -0x3a(%rbp), %edx
subl %edx, %ecx
cmpl %ecx, %eax
jle 0x453f35
movswl -0x12(%rbp), %eax
movswl -0x3a(%rbp), %ecx
subl %ecx, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x16(%rax)
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)