// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::to_expression[abi:cxx11](unsigned int)
string CompilerGLSL::to_expression(uint32_t id)
{
	auto itr = invalid_expressions.find(id);
	if (itr != end(invalid_expressions))
		handle_invalid_expression(id);

	if (ir.ids[id].get_type() == TypeExpression)
	{
		// We might have a more complex chain of dependencies.
		// A possible scenario is that we
		//
		// %1 = OpLoad
		// %2 = OpDoSomething %1 %1. here %2 will have a dependency on %1.
		// %3 = OpDoSomethingAgain %2 %2. Here %3 will lose the link to %1 since we don't propagate the dependencies like that.
		// OpStore %1 %foo // Here we can invalidate %1, and hence all expressions which depend on %1. Only %2 will know since it's part of invalid_expressions.
		// %4 = OpDoSomethingAnotherTime %3 %3 // If we forward all expressions we will see %1 expression after store, not before.
		//
		// However, we can propagate up a list of depended expressions when we used %2, so we can check if %2 is invalid when reading %3 after the store,
		// and see that we should not forward reads of the original variable.
		auto &expr = get<SPIRExpression>(id);
		for (uint32_t dep : expr.expression_dependencies)
			if (invalid_expressions.find(dep) != end(invalid_expressions))
				handle_invalid_expression(dep);
	}

	track_expression_read(id);

	switch (ir.ids[id].get_type())
	{
	case TypeExpression:
	{
		auto &e = get<SPIRExpression>(id);
		if (e.base_expression)
			return to_enclosed_expression(e.base_expression) + e.expression;
		else if (e.need_transpose)
		{
			bool is_packed = has_decoration(id, DecorationCPacked);
			return convert_row_major_matrix(e.expression, get<SPIRType>(e.expression_type), is_packed);
		}
		else
		{
			if (force_recompile)
			{
				// During first compilation phase, certain expression patterns can trigger exponential growth of memory.
				// Avoid this by returning dummy expressions during this phase.
				// Do not use empty expressions here, because those are sentinels for other cases.
				return "_";
			}
			else
				return e.expression;
		}
	}

	case TypeConstant:
	{
		auto &c = get<SPIRConstant>(id);
		auto &type = get<SPIRType>(c.constant_type);

		// WorkGroupSize may be a constant.
		auto &dec = ir.meta[c.self].decoration;
		if (dec.builtin)
			return builtin_to_glsl(dec.builtin_type, StorageClassGeneric);
		else if (c.specialization && options.vulkan_semantics)
			return to_name(id);
		else if (c.is_used_as_lut)
			return to_name(id);
		else if (type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
			return to_name(id);
		else if (!type.array.empty() && !backend.can_declare_arrays_inline)
			return to_name(id);
		else
			return constant_expression(c);
	}

	case TypeConstantOp:
		if (options.vulkan_semantics)
			return to_name(id);
		else
			return constant_op_expression(get<SPIRConstantOp>(id));

	case TypeVariable:
	{
		auto &var = get<SPIRVariable>(id);
		// If we try to use a loop variable before the loop header, we have to redirect it to the static expression,
		// the variable has not been declared yet.
		if (var.statically_assigned || (var.loop_variable && !var.loop_variable_enable))
			return to_expression(var.static_expression);
		else if (var.deferred_declaration)
		{
			var.deferred_declaration = false;
			return variable_decl(var);
		}
		else if (flattened_structs.count(id))
		{
			return load_flattened_struct(var);
		}
		else
		{
			auto &dec = ir.meta[var.self].decoration;
			if (dec.builtin)
				return builtin_to_glsl(dec.builtin_type, var.storage);
			else
				return to_name(id);
		}
	}

	case TypeCombinedImageSampler:
		// This type should never be taken the expression of directly.
		// The intention is that texture sampling functions will extract the image and samplers
		// separately and take their expressions as needed.
		// GLSL does not use this type because OpSampledImage immediately creates a combined image sampler
		// expression ala sampler2D(texture, sampler).
		SPIRV_CROSS_THROW("Combined image samplers have no default expression representation.");

	case TypeAccessChain:
		// We cannot express this type. They only have meaning in other OpAccessChains, OpStore or OpLoad.
		SPIRV_CROSS_THROW("Access chains have no default expression representation.");

	default:
		return to_name(id);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, %ecx
movq %rsi, %r14
movl %edx, 0x4(%rsp)
movl %edx, %eax
movq 0x198(%rsi), %r9
movq 0x1a0(%rsi), %r8
xorl %r10d, %r10d
xorl %edx, %edx
divq %r8
movq (%r9,%rdx,8), %rax
testq %rax, %rax
je 0x3465b
movq (%rax), %r9
movq %rax, %r10
cmpl %ecx, 0x8(%r9)
je 0x3465b
movq %rdx, %rsi
movq %r9, %r11
movq (%r9), %r9
testq %r9, %r9
je 0x34658
movl 0x8(%r9), %ebx
movq %rbx, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %r10d
cmpq %rsi, %rdx
jne 0x3465b
movq %r11, %r10
cmpl %ecx, %ebx
jne 0x3462d
jmp 0x3465b
xorl %r10d, %r10d
movq %rdi, 0x8(%rsp)
testq %r10, %r10
je 0x3468e
cmpq $0x0, (%r10)
je 0x3468e
leaq 0x14(%rsp), %rsi
movl %ecx, (%rsi)
leaq 0x228(%r14), %rdi
leaq 0x18(%rsp), %rdx
movq %rdi, (%rdx)
callq 0x1fc02
movb $0x1, 0x1d0(%r14)
movl 0x4(%rsp), %esi
movq 0x20(%r14), %rax
movq %rsi, %rcx
shlq $0x4, %rcx
cmpl $0x9, 0x8(%rax,%rcx)
jne 0x3476b
movq %r14, %rdi
callq 0x1ba86
movq 0x40(%rax), %rbp
movq 0x48(%rax), %rbx
cmpq %rbx, %rbp
je 0x3476b
leaq 0x228(%r14), %r15
leaq 0x14(%rsp), %r12
leaq 0x18(%rsp), %r13
movl (%rbp), %ecx
movq 0x198(%r14), %rdi
movq 0x1a0(%r14), %r8
movq %rcx, %rax
xorl %edx, %edx
divq %r8
movq %rdx, %rsi
movq (%rdi,%rdx,8), %rdx
movl $0x0, %eax
testq %rdx, %rdx
je 0x34734
movq (%rdx), %r9
movq %rdx, %rax
cmpl 0x8(%r9), %ecx
je 0x34734
movq %r9, %r10
movq (%r9), %r9
testq %r9, %r9
je 0x34732
movl 0x8(%r9), %edi
movq %rdi, %rax
xorl %edx, %edx
divq %r8
movl $0x0, %eax
cmpq %rsi, %rdx
jne 0x34734
movq %r10, %rax
cmpl %edi, %ecx
jne 0x34708
jmp 0x34734
xorl %eax, %eax
testq %rax, %rax
je 0x3475e
cmpq $0x0, (%rax)
je 0x3475e
movl %ecx, 0x14(%rsp)
movq %r15, 0x18(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
callq 0x1fc02
movb $0x1, 0x1d0(%r14)
addq $0x4, %rbp
cmpq %rbx, %rbp
jne 0x346d2
movl 0x4(%rsp), %esi
movq %r14, %rdi
callq 0x34fc8
movl 0x4(%rsp), %edx
movq 0x20(%r14), %rax
movq %rdx, %rcx
shlq $0x4, %rcx
movl 0x8(%rax,%rcx), %eax
addl $-0x2, %eax
cmpl $0xa, %eax
ja 0x348ac
leaq 0x81fd3(%rip), %rcx     # 0xb6770
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
movl %edx, %esi
callq 0xb40a
movq %rax, %r15
cmpb $0x0, 0x39(%rax)
movq 0x8(%rsp), %rbx
je 0x348bc
movl 0x3c(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x345e6
jmp 0x349f8
movq %r14, %rdi
movl %edx, %esi
callq 0x1ba86
movq %rax, %r15
movl 0xc(%rax), %edx
testl %edx, %edx
movq 0x8(%rsp), %rbx
je 0x3494a
leaq 0x18(%rsp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x34d0e
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
movq %r12, %rdi
callq 0x60b0
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x349c0
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x349c6
movq %r14, %rdi
movl %edx, %esi
callq 0x1c66e
movq %rax, %r15
movl 0xc(%rax), %esi
movq %r14, %rdi
callq 0xa426
movl 0x8(%r15), %edx
movq 0x38(%r14), %rcx
imulq $0x148, %rdx, %rdx      # imm = 0x148
cmpb $0x1, 0xcc(%rcx,%rdx)
movq 0x8(%rsp), %rbx
jne 0x348f1
addq %rdx, %rcx
movl 0xa0(%rcx), %edx
movq (%r14), %rax
movq %rbx, %rdi
movq %r14, %rsi
movl $0x8, %ecx
callq *0xa0(%rax)
jmp 0x349f8
cmpb $0x1, 0x43e(%r14)
movq 0x8(%rsp), %rbx
jne 0x3492d
movq (%r14), %rax
jmp 0x348b4
movq (%r14), %rax
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x34920
cmpb $0x1, 0x64(%r15)
jne 0x348ce
cmpb $0x0, 0x65(%r15)
je 0x347c2
cmpb $0x1, 0x59(%r15)
jne 0x34a2b
movb $0x0, 0x59(%r15)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2ce16
jmp 0x349f8
cmpb $0x1, 0x108(%r15)
jne 0x34905
cmpb $0x1, 0x43e(%r14)
je 0x34913
cmpb $0x1, 0x10a(%r15)
jne 0x34a51
movl 0x4(%rsp), %edx
movq (%r14), %rax
movq %rbx, %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
jmp 0x349f8
movq %r14, %rdi
movl %edx, %esi
callq 0x538ce
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x2d3f6
jmp 0x349f8
cmpb $0x1, 0x39(%r15)
jne 0x34a0a
movl 0x4(%rsp), %esi
movq %r14, %rdi
movl $0xa, %edx
callq 0x1299a
movl %eax, %ebp
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
leaq 0x38(%rsp), %rdi
callq 0xe480
movl 0x30(%r15), %esi
movq %r14, %rdi
callq 0xa426
movq (%r14), %r9
movzbl %bpl, %r8d
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rcx
callq *0x118(%r9)
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x349f8
movq 0x48(%rsp), %rsi
jmp 0x349f0
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x349f8
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x1, 0x1d0(%r14)
jne 0x34a90
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movw $0x5f, 0x10(%rbx)
movq $0x1, 0x8(%rbx)
jmp 0x349f8
leaq 0x6b0(%r14), %rdi
leaq 0x4(%rsp), %rsi
callq 0x1fbce
testq %rax, %rax
je 0x34aaf
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x35020
jmp 0x349f8
cmpl $0xc, 0xc(%rax)
jne 0x34a65
cmpb $0x0, 0x626(%r14)
je 0x34913
movq 0x20(%rax), %rcx
cmpq 0x28(%rax), %rcx
je 0x34a7d
cmpb $0x0, 0x627(%r14)
je 0x34913
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x2e53a
jmp 0x349f8
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xe480
jmp 0x349f8
movl 0x8(%r15), %ecx
movq 0x38(%r14), %rax
imulq $0x148, %rcx, %rcx      # imm = 0x148
cmpb $0x1, 0xcc(%rax,%rcx)
jne 0x34913
addq %rcx, %rax
movl 0xa0(%rax), %edx
movl 0x10(%r15), %ecx
movq (%r14), %rax
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x34889
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x8457d(%rip), %rsi     # 0xb9081
leaq 0x845ae(%rip), %rdx     # 0xb90b9
leaq 0x18(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc826c(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc8244(%rip), %rsi     # 0xfcd80
movq 0xc9495(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x34bb1
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x844d4(%rip), %rsi     # 0xb903e
leaq 0x8450f(%rip), %rdx     # 0xb9080
leaq 0x18(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc8206(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc81de(%rip), %rsi     # 0xfcd80
movq 0xc942f(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
je 0x34c18
movq 0x48(%rsp), %rsi
jmp 0x34c10
jmp 0x34bc9
jmp 0x34be5
movq %rax, %rbx
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x34beb
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x34beb
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x34c18
movq %r14, %rdi
callq 0x6200
jmp 0x34c18
movq %rax, %rbx
leaq 0x28(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x34c18
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0