// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::store_flattened_struct(spirv_cross::SPIRVariable&, unsigned int)
void CompilerGLSL::store_flattened_struct(SPIRVariable &var, uint32_t value)
{
	// We're trying to store a structure which has been flattened.
	// Need to copy members one by one.
	auto rhs = to_expression(value);

	// Store result locally.
	// Since we're declaring a variable potentially multiple times here,
	// store the variable in an isolated scope.
	begin_scope();
	statement(variable_decl_function_local(var), " = ", rhs, ";");

	auto &type = get<SPIRType>(var.basetype);
	for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++)
	{
		// Flatten the varyings.
		// Apply name transformation for flattened I/O blocks.

		auto lhs = sanitize_underscores(join(to_name(var.self), "_", to_member_name(type, i)));
		rhs = join(to_name(var.self), ".", to_member_name(type, i));
		statement(lhs, " = ", rhs, ";");
	}
	end_scope();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rsi
movq %rsi, -0x160(%rbp)
movl -0x14(%rbp), %edx
leaq -0x38(%rbp), %rdi
callq 0x71b50
movq -0x160(%rbp), %rdi
callq 0x5c200
jmp 0x8732b
movq -0x160(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x87650
jmp 0x87341
movq -0x160(%rbp), %rdi
leaq 0xc1cc0(%rip), %rdx     # 0x14900f
leaq 0xc1d50(%rip), %r8      # 0x1490a6
leaq -0x68(%rbp), %rsi
leaq -0x38(%rbp), %rcx
callq 0xa4750
jmp 0x87365
leaq -0x68(%rbp), %rdi
callq 0x7708
movq -0x160(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x168(%rbp)
jmp 0x8738a
movq -0x168(%rbp), %rax
movq %rax, -0x70(%rbp)
movl $0x0, -0x74(%rbp)
movl -0x74(%rbp), %eax
movl %eax, -0x16c(%rbp)
movq -0x70(%rbp), %rdi
addq $0x68, %rdi
callq 0x8650
movq %rax, %rcx
movl -0x16c(%rbp), %eax
cmpl %ecx, %eax
jae 0x87611
movq -0x160(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xd8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x873e8
movq -0x160(%rbp), %rsi
movq -0x70(%rbp), %rdx
movl -0x74(%rbp), %ecx
leaq -0xf8(%rbp), %rdi
callq 0x62230
jmp 0x87404
leaq 0xc1113(%rip), %rdx     # 0x14851e
leaq -0xb8(%rbp), %rdi
leaq -0xd8(%rbp), %rsi
leaq -0xf8(%rbp), %rcx
callq 0xa4670
jmp 0x87427
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x577c0
jmp 0x8743c
leaq -0xb8(%rbp), %rdi
callq 0x7708
leaq -0xf8(%rbp), %rdi
callq 0x7708
leaq -0xd8(%rbp), %rdi
callq 0x7708
movq -0x160(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x138(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x87485
movq -0x160(%rbp), %rsi
movq -0x70(%rbp), %rdx
movl -0x74(%rbp), %ecx
leaq -0x158(%rbp), %rdi
callq 0x62230
jmp 0x874a1
leaq 0xbd885(%rip), %rdx     # 0x144d2d
leaq -0x118(%rbp), %rdi
leaq -0x138(%rbp), %rsi
leaq -0x158(%rbp), %rcx
callq 0xa4670
jmp 0x874c4
leaq -0x38(%rbp), %rdi
movq %rdi, -0x178(%rbp)
leaq -0x118(%rbp), %rsi
movq %rsi, -0x180(%rbp)
callq 0x7430
movq -0x180(%rbp), %rdi
callq 0x7708
leaq -0x158(%rbp), %rdi
callq 0x7708
leaq -0x138(%rbp), %rdi
callq 0x7708
movq -0x160(%rbp), %rdi
movq -0x178(%rbp), %rcx
leaq 0xc1af4(%rip), %rdx     # 0x14900f
leaq 0xc1b84(%rip), %r8      # 0x1490a6
leaq -0x98(%rbp), %rsi
callq 0xa4890
jmp 0x87530
leaq -0x98(%rbp), %rdi
callq 0x7708
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x8739c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x87631
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x7708
jmp 0x87631
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x875b5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x875a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
leaq -0xf8(%rbp), %rdi
callq 0x7708
leaq -0xd8(%rbp), %rdi
callq 0x7708
jmp 0x87631
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x87603
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x875f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x7708
leaq -0x138(%rbp), %rdi
callq 0x7708
leaq -0x98(%rbp), %rdi
callq 0x7708
jmp 0x87631
movq -0x160(%rbp), %rdi
callq 0x876c0
jmp 0x8761f
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x40(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)