// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: pushDownWhereTerms
static int pushDownWhereTerms(
  Parse *pParse,        /* Parse context (for malloc() and error reporting) */
  Select *pSubq,        /* The subquery whose WHERE clause is to be augmented */
  Expr *pWhere,         /* The WHERE clause of the outer query */
  int iCursor,          /* Cursor number of the subquery */
  int isLeftJoin        /* True if pSubq is the right term of a LEFT JOIN */
){
  Expr *pNew;
  int nChng = 0;
  Select *pSel;
  if( pWhere==0 ) return 0;
  if( pSubq->selFlags & SF_Recursive ) return 0;  /* restriction (2) */

#ifndef SQLITE_OMIT_WINDOWFUNC
  for(pSel=pSubq; pSel; pSel=pSel->pPrior){
    if( pSel->pWin ) return 0;    /* restriction (6) */
  }
#endif

#ifdef SQLITE_DEBUG
  /* Only the first term of a compound can have a WITH clause.  But make
  ** sure no other terms are marked SF_Recursive in case something changes
  ** in the future.
  */
  {
    Select *pX;
    for(pX=pSubq; pX; pX=pX->pPrior){
      assert( (pX->selFlags & (SF_Recursive))==0 );
    }
  }
#endif

  if( pSubq->pLimit!=0 ){
    return 0; /* restriction (3) */
  }
  while( pWhere->op==TK_AND ){
    nChng += pushDownWhereTerms(pParse, pSubq, pWhere->pRight,
                                iCursor, isLeftJoin);
    pWhere = pWhere->pLeft;
  }
  if( isLeftJoin
   && (ExprHasProperty(pWhere,EP_FromJoin)==0
         || pWhere->iRightJoinTable!=iCursor)
  ){
    return 0; /* restriction (4) */
  }
  if( ExprHasProperty(pWhere,EP_FromJoin) && pWhere->iRightJoinTable!=iCursor ){
    return 0; /* restriction (5) */
  }
  if( sqlite3ExprIsTableConstant(pWhere, iCursor) ){
    nChng++;
    while( pSubq ){
      SubstContext x;
      pNew = sqlite3ExprDup(pParse->db, pWhere, 0);
      unsetJoinExpr(pNew, -1);
      x.pParse = pParse;
      x.iTable = iCursor;
      x.iNewTable = iCursor;
      x.isLeftJoin = 0;
      x.pEList = pSubq->pEList;
      pNew = substExpr(&x, pNew);
      if( pSubq->selFlags & SF_Aggregate ){
        pSubq->pHaving = sqlite3ExprAnd(pParse, pSubq->pHaving, pNew);
      }else{
        pSubq->pWhere = sqlite3ExprAnd(pParse, pSubq->pWhere, pNew);
      }
      pSubq = pSubq->pPrior;
    }
  }
  return nChng;
}

// Assembly:
xorl %eax, %eax
testq %rdx, %rdx
je 0x2cdc2a
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
testb $0x20, 0x5(%rsi)
jne 0x2cdc1c
movl %r8d, %ebp
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r12
movq %r15, %rcx
cmpq $0x0, 0x70(%rcx)
jne 0x2cdc1c
movq 0x50(%rcx), %rcx
testq %rcx, %rcx
jne 0x2cdc05
cmpq $0x0, 0x60(%r15)
je 0x2cdc2b
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
cmpb $0x2c, (%r14)
jne 0x2cdc58
xorl %r13d, %r13d
movq 0x18(%r14), %rdx
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl %ebp, %r8d
callq 0x2cdbd9
addl %eax, %r13d
movq 0x10(%r14), %r14
cmpb $0x2c, (%r14)
je 0x2cdc37
movl 0x4(%r14), %ecx
testl %ebp, %ebp
je 0x2cdc72
xorl %eax, %eax
testb $0x1, %cl
je 0x2cdc1c
movswl 0x34(%r14), %ecx
cmpl %ebx, %ecx
jne 0x2cdc1c
jmp 0x2cdc77
testb $0x1, %cl
je 0x2cdc82
movswl 0x34(%r14), %ecx
xorl %eax, %eax
cmpl %ebx, %ecx
jne 0x2cdc1c
leaq 0x8(%rsp), %rbp
movw $0x3, 0x24(%rbp)
leaq -0xd30d(%rip), %rax     # 0x2c0987
movq %rax, 0x8(%rbp)
leaq -0xd21f(%rip), %rax     # 0x2c0a80
movq %rax, 0x10(%rbp)
movl %ebx, 0x28(%rbp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2c0a8c
cmpw $0x0, 0x24(%rbp)
je 0x2cdd2b
incl %r13d
movq (%r12), %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2c2864
movq %rax, %rbp
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2cb9c2
movq %r12, 0x8(%rsp)
movl %ebx, 0x10(%rsp)
movl %ebx, 0x14(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x20(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x8(%rsp), %rdi
movq %rbp, %rsi
callq 0x2d2efa
movl 0x4(%r15), %ebp
andl $0x8, %ebp
movq 0x30(%r15,%rbp,2), %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x2b6b0e
movq %rax, 0x30(%r15,%rbp,2)
movq 0x50(%r15), %r15
testq %r15, %r15
jne 0x2cdcbb
movl %r13d, %eax
jmp 0x2cdc1c