// File: rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::inherit_expression_dependencies(unsigned int, unsigned int)
void Compiler::inherit_expression_dependencies(uint32_t dst, uint32_t source_expression)
{
	// Don't inherit any expression dependencies if the expression in dst
	// is not a forwarded temporary.
	if (forwarded_temporaries.find(dst) == end(forwarded_temporaries) ||
	    forced_temporaries.find(dst) != end(forced_temporaries))
	{
		return;
	}

	auto &e = get<SPIRExpression>(dst);
	auto *phi = maybe_get<SPIRVariable>(source_expression);
	if (phi && phi->phi_variable)
	{
		// We have used a phi variable, which can change at the end of the block,
		// so make sure we take a dependency on this phi variable.
		phi->dependees.push_back(dst);
	}

	auto *s = maybe_get<SPIRExpression>(source_expression);
	if (!s)
		return;

	auto &e_deps = e.expression_dependencies;
	auto &s_deps = s->expression_dependencies;

	// If we depend on a expression, we also depend on all sub-dependencies from source.
	e_deps.push_back(source_expression);
	e_deps.insert(end(e_deps), begin(s_deps), end(s_deps));

	// Eliminate duplicated dependencies.
	sort(begin(e_deps), end(e_deps));
	e_deps.erase(unique(begin(e_deps), end(e_deps)), end(e_deps));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
addq $0x260, %rdi            # imm = 0x260
leaq -0xc(%rbp), %rsi
callq 0x2ff00
movq -0xd8(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x260, %rdi            # imm = 0x260
callq 0x2ff30
movq %rax, -0x20(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x2eb30
movb %al, %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xc9(%rbp)
jne 0x255ac
movq -0xd8(%rbp), %rdi
addq $0x228, %rdi            # imm = 0x228
leaq -0xc(%rbp), %rsi
callq 0x2ff00
movq -0xd8(%rbp), %rdi
movq %rax, -0x28(%rbp)
addq $0x228, %rdi            # imm = 0x228
callq 0x2ff30
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2fed0
movb %al, -0xc9(%rbp)
movb -0xc9(%rbp), %al
testb $0x1, %al
jne 0x255b8
jmp 0x255bd
jmp 0x25773
movq -0xd8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x2e850
movq -0xd8(%rbp), %rdi
movq %rax, -0x38(%rbp)
movl -0x10(%rbp), %esi
callq 0x116b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x25605
movq -0x40(%rbp), %rax
testb $0x1, 0x5a(%rax)
je 0x25605
movq -0x40(%rbp), %rdi
addq $0x40, %rdi
leaq -0xc(%rbp), %rsi
callq 0x88f0
movq -0xd8(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x2e790
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x25624
jmp 0x25773
movq -0x38(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x58(%rbp)
movq -0x50(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x88f0
movq -0x50(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x50(%rbp), %rdi
callq 0x8600
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x30240
movq -0x58(%rbp), %rdi
callq 0x85d0
movq %rax, -0x70(%rbp)
movq -0x58(%rbp), %rdi
callq 0x8600
movq -0xe8(%rbp), %rdi
movq %rax, -0x78(%rbp)
movq -0x60(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x78(%rbp), %rcx
callq 0x30190
movq %rax, -0x80(%rbp)
movq -0x50(%rbp), %rdi
callq 0x85d0
movq %rax, -0x88(%rbp)
movq -0x50(%rbp), %rdi
callq 0x8600
movq %rax, -0x90(%rbp)
movq -0x88(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x30280
movq -0x50(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x50(%rbp), %rdi
callq 0x85d0
movq %rax, -0xa8(%rbp)
movq -0x50(%rbp), %rdi
callq 0x8600
movq %rax, -0xb0(%rbp)
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x30350
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x30240
movq -0x50(%rbp), %rdi
callq 0x8600
movq %rax, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x30240
movq -0xe0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xb8(%rbp), %rdx
callq 0x302c0
movq %rax, -0xc8(%rbp)
addq $0xf0, %rsp
popq %rbp
retq
nopl (%rax)