// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/external/sqlite-3.33.0/sqlite3.c
// Function: substExpr
static Expr *substExpr(
  SubstContext *pSubst,  /* Description of the substitution */
  Expr *pExpr            /* Expr in which substitution occurs */
){
  if( pExpr==0 ) return 0;
  if( ExprHasProperty(pExpr, EP_FromJoin)
   && pExpr->iRightJoinTable==pSubst->iTable
  ){
    pExpr->iRightJoinTable = pSubst->iNewTable;
  }
  if( pExpr->op==TK_COLUMN
   && pExpr->iTable==pSubst->iTable
   && !ExprHasProperty(pExpr, EP_FixedCol)
  ){
    if( pExpr->iColumn<0 ){
      pExpr->op = TK_NULL;
    }else{
      Expr *pNew;
      Expr *pCopy = pSubst->pEList->a[pExpr->iColumn].pExpr;
      Expr ifNullRow;
      assert( pSubst->pEList!=0 && pExpr->iColumn<pSubst->pEList->nExpr );
      assert( pExpr->pRight==0 );
      if( sqlite3ExprIsVector(pCopy) ){
        sqlite3VectorErrorMsg(pSubst->pParse, pCopy);
      }else{
        sqlite3 *db = pSubst->pParse->db;
        if( pSubst->isLeftJoin && pCopy->op!=TK_COLUMN ){
          memset(&ifNullRow, 0, sizeof(ifNullRow));
          ifNullRow.op = TK_IF_NULL_ROW;
          ifNullRow.pLeft = pCopy;
          ifNullRow.iTable = pSubst->iNewTable;
          ifNullRow.flags = EP_Skip;
          pCopy = &ifNullRow;
        }
        testcase( ExprHasProperty(pCopy, EP_Subquery) );
        pNew = sqlite3ExprDup(db, pCopy, 0);
        if( pNew && pSubst->isLeftJoin ){
          ExprSetProperty(pNew, EP_CanBeNull);
        }
        if( pNew && ExprHasProperty(pExpr,EP_FromJoin) ){
          pNew->iRightJoinTable = pExpr->iRightJoinTable;
          ExprSetProperty(pNew, EP_FromJoin);
        }
        sqlite3ExprDelete(db, pExpr);
        pExpr = pNew;

        /* Ensure that the expression now has an implicit collation sequence,
        ** just as it did when it was a column of a view or sub-query. */
        if( pExpr ){
          if( pExpr->op!=TK_COLUMN && pExpr->op!=TK_COLLATE ){
            CollSeq *pColl = sqlite3ExprCollSeq(pSubst->pParse, pExpr);
            pExpr = sqlite3ExprAddCollateString(pSubst->pParse, pExpr,
                (pColl ? pColl->zName : "BINARY")
            );
          }
          ExprClearProperty(pExpr, EP_Collate);
        }
      }
    }
  }else{
    if( pExpr->op==TK_IF_NULL_ROW && pExpr->iTable==pSubst->iTable ){
      pExpr->iTable = pSubst->iNewTable;
    }
    pExpr->pLeft = substExpr(pSubst, pExpr->pLeft);
    pExpr->pRight = substExpr(pSubst, pExpr->pRight);
    if( ExprHasProperty(pExpr, EP_xIsSelect) ){
      substSelect(pSubst, pExpr->x.pSelect, 1);
    }else{
      substExprList(pSubst, pExpr->x.pList);
    }
#ifndef SQLITE_OMIT_WINDOWFUNC
    if( ExprHasProperty(pExpr, EP_WinFunc) ){
      Window *pWin = pExpr->y.pWin;
      pWin->pFilter = substExpr(pSubst, pWin->pFilter);
      substExprList(pSubst, pWin->pPartition);
      substExprList(pSubst, pWin->pOrderBy);
    }
#endif
  }
  return pExpr;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
testq %rsi, %rsi
je 0x2d318e
movq %rsi, %rbx
movq %rdi, %r14
movl 0x4(%rsi), %eax
testb $0x1, %al
je 0x2d2f31
movswl 0x34(%rbx), %ecx
cmpl %ecx, 0x8(%r14)
jne 0x2d2f31
movzwl 0xc(%r14), %ecx
movw %cx, 0x34(%rbx)
movzbl (%rbx), %ecx
cmpl $0xb0, %ecx
je 0x2d306b
cmpl $0xa4, %ecx
jne 0x2d307b
testb $0x8, %al
jne 0x2d307b
movl 0x8(%r14), %eax
cmpl %eax, 0x2c(%rbx)
jne 0x2d307b
movswq 0x30(%rbx), %rax
testq %rax, %rax
js 0x2d3174
movq 0x18(%r14), %rcx
leaq (%rax,%rax,2), %rax
movq 0x8(%rcx,%rax,8), %rsi
movb (%rsi), %al
movl %eax, %ecx
cmpb $-0x53, %al
jne 0x2d2f87
movb 0x2(%rsi), %cl
movq %rsi, %rdx
cmpb $-0x52, %cl
je 0x2d2f9e
movzbl %cl, %ecx
cmpl $0x88, %ecx
jne 0x2d2fab
movq 0x20(%rsi), %rdx
movq 0x20(%rdx), %rcx
cmpl $0x2, (%rcx)
jge 0x2d3179
movq (%r14), %rcx
movq (%rcx), %r12
cmpb $-0x5c, %al
je 0x2d2ff1
cmpl $0x0, 0x10(%r14)
je 0x2d2ff1
xorps %xmm0, %xmm0
movq %rsp, %rax
movaps %xmm0, (%rax)
movaps %xmm0, 0x10(%rax)
movaps %xmm0, 0x30(%rax)
movaps %xmm0, 0x20(%rax)
movq $0x0, 0x40(%rax)
movb $-0x50, (%rax)
movq %rsi, 0x10(%rax)
movl 0xc(%r14), %ecx
movl %ecx, 0x2c(%rax)
movl $0x1000, 0x4(%rax)      # imm = 0x1000
movq %rax, %rsi
movq %r12, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x2c2864
testq %rax, %rax
je 0x2d3183
movq %rax, %r15
cmpl $0x0, 0x10(%r14)
je 0x2d3015
orb $0x10, 0x6(%r15)
testb $0x1, 0x4(%rbx)
je 0x2d3029
movzwl 0x34(%rbx), %eax
movw %ax, 0x34(%r15)
orb $0x1, 0x4(%r15)
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2a6164
movzbl (%r15), %eax
cmpl $0x6f, %eax
je 0x2d31b4
cmpl $0xa4, %eax
je 0x2d31b4
movq (%r14), %rdi
movq %r15, %rsi
callq 0x2a9678
movq (%r14), %rdi
testq %rax, %rax
je 0x2d31a2
movq (%rax), %rdx
jmp 0x2d31a9
movl 0x2c(%rbx), %eax
cmpl 0x8(%r14), %eax
jne 0x2d307b
movl 0xc(%r14), %eax
movl %eax, 0x2c(%rbx)
movq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, 0x10(%rbx)
movq 0x18(%rbx), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, 0x18(%rbx)
testb $0x8, 0x5(%rbx)
movq 0x20(%rbx), %r15
jne 0x2d30d8
testq %r15, %r15
je 0x2d30e8
cmpl $0x0, (%r15)
jle 0x2d30e8
leaq 0x8(%r15), %r12
xorl %r13d, %r13d
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, (%r12)
incq %r13
movslq (%r15), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x2d30b7
jmp 0x2d30e8
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0x2d2d2a
testb $0x1, 0x7(%rbx)
je 0x2d3190
movq 0x40(%rbx), %r15
movq 0x48(%r15), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, 0x48(%r15)
movq 0x10(%r15), %r12
testq %r12, %r12
je 0x2d313d
cmpl $0x0, (%r12)
jle 0x2d313d
leaq 0x8(%r12), %r13
xorl %ebp, %ebp
movq (%r13), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, (%r13)
incq %rbp
movslq (%r12), %rax
addq $0x18, %r13
cmpq %rax, %rbp
jl 0x2d311d
movq 0x18(%r15), %r15
testq %r15, %r15
je 0x2d3190
cmpl $0x0, (%r15)
jle 0x2d3190
leaq 0x8(%r15), %r12
xorl %r13d, %r13d
movq (%r12), %rsi
movq %r14, %rdi
callq 0x2d2efa
movq %rax, (%r12)
incq %r13
movslq (%r15), %rax
addq $0x18, %r12
cmpq %rax, %r13
jl 0x2d3153
jmp 0x2d3190
movb $0x77, (%rbx)
jmp 0x2d3190
movq (%r14), %rdi
callq 0x2c26ad
jmp 0x2d3190
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2a6164
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfe9b7(%rip), %rdx     # 0x3d1b60
movq %r15, %rsi
callq 0x2c6cde
movq %rax, %r15
andb $-0x2, 0x5(%r15)
movq %r15, %rbx
jmp 0x2d3190