// File: /workspace/github_c_makefile_star2_O1/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 0x2d740d
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r15
testb $0x20, 0x5(%rsi)
jne 0x2d73ff
movl %r8d, %ebp
movl %ecx, %ebx
movq %rdx, %r14
movq %rdi, %r12
testq %r15, %r15
je 0x2d73f8
movq %r15, %rcx
cmpq $0x0, 0x70(%rcx)
jne 0x2d73ff
movq 0x50(%rcx), %rcx
testq %rcx, %rcx
jne 0x2d73e8
cmpq $0x0, 0x60(%r15)
je 0x2d740e
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %r13d, %r13d
cmpb $0x2c, (%r14)
jne 0x2d743b
xorl %r13d, %r13d
movq 0x18(%r14), %rdx
movq %r12, %rdi
movq %r15, %rsi
movl %ebx, %ecx
movl %ebp, %r8d
callq 0x2d73b7
addl %eax, %r13d
movq 0x10(%r14), %r14
cmpb $0x2c, (%r14)
je 0x2d741a
testl %ebp, %ebp
je 0x2d7451
xorl %eax, %eax
testb $0x1, 0x4(%r14)
je 0x2d73ff
movswl 0x34(%r14), %ecx
cmpl %ebx, %ecx
jne 0x2d73ff
testb $0x1, 0x4(%r14)
je 0x2d7463
movswl 0x34(%r14), %ecx
xorl %eax, %eax
cmpl %ebx, %ecx
jne 0x2d73ff
leaq 0x8(%rsp), %rbp
movw $0x3, 0x24(%rbp)
leaq -0xd352(%rip), %rax     # 0x2ca123
movq %rax, 0x8(%rbp)
leaq -0xd27b(%rip), %rax     # 0x2ca205
movq %rax, 0x10(%rbp)
movl %ebx, 0x28(%rbp)
movq %rbp, %rdi
movq %r14, %rsi
callq 0x2ca211
cmpw $0x0, 0x24(%rbp)
je 0x2d750e
incl %r13d
testq %r15, %r15
je 0x2d750e
movq (%r12), %rdi
movq %r14, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2cbf97
movq %rax, %rbp
movq %rax, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x2d5323
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 0x2dc615
movl 0x4(%r15), %ebp
andl $0x8, %ebp
movq 0x30(%r15,%rbp,2), %rsi
movq %r12, %rdi
movq %rax, %rdx
callq 0x2c02f0
movq %rax, 0x30(%r15,%rbp,2)
movq 0x50(%r15), %r15
jmp 0x2d749c
movl %r13d, %eax
jmp 0x2d73ff