// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_flattened_io_block(spirv_cross::SPIRVariable const&, char const*)
void CompilerGLSL::emit_flattened_io_block(const SPIRVariable &var, const char *qual)
{
	auto &type = get<SPIRType>(var.basetype);
	if (!type.array.empty())
		SPIRV_CROSS_THROW("Array of varying structs cannot be flattened to legacy-compatible varyings.");

	auto old_flags = ir.meta[type.self].decoration.decoration_flags;
	// Emit the members as if they are part of a block to get all qualifiers.
	ir.meta[type.self].decoration.decoration_flags.set(DecorationBlock);

	type.member_name_cache.clear();

	uint32_t i = 0;
	for (auto &member : type.member_types)
	{
		add_member_name(type, i);
		auto &membertype = get<SPIRType>(member);

		if (membertype.basetype == SPIRType::Struct)
			SPIRV_CROSS_THROW("Cannot flatten struct inside structs in I/O variables.");

		// Pass in the varying qualifier here so it will appear in the correct declaration order.
		// Replace member name while emitting it so it encodes both struct name and member name.
		// Sanitize underscores because joining the two identifiers might create more than 1 underscore in a row,
		// which is not allowed.
		auto backup_name = get_member_name(type.self, i);
		auto member_name = to_member_name(type, i);
		set_member_name(type.self, i, sanitize_underscores(join(to_name(var.self), "_", member_name)));
		emit_struct_member(type, member, i, qual);
		// Restore member name.
		set_member_name(type.self, i, member_name);
		i++;
	}

	ir.meta[type.self].decoration.decoration_flags = old_flags;

	// Treat this variable as flattened from now on.
	flattened_structs.insert(var.self);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, 0x28(%rsp)
movq %rsi, %r13
movq %rdi, %rbp
movl 0xc(%rsi), %esi
callq 0x90a4
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq 0x28(%r15), %rax
jne 0x25bb3
movl 0x8(%r15), %eax
movq 0x38(%rbp), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
leaq (%rcx,%rax), %rsi
addq $0x60, %rsi
leaq 0x78(%rsp), %rdi
callq 0x934a
movl 0x8(%r15), %eax
movq 0x38(%rbp), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
orq $0x4, 0x60(%rcx,%rax)
movq %r15, %rdi
addq $0xa0, %rdi
callq 0xb854
movq 0x68(%r15), %rcx
movq 0x70(%r15), %rax
movq %rax, 0x30(%rsp)
addq $0x8, %r13
movl $0x0, 0xc(%rsp)
leaq 0xf8(%rsp), %r12
movq %r15, 0x10(%rsp)
movq %r13, 0x20(%rsp)
movq %rcx, 0x18(%rsp)
cmpq 0x30(%rsp), %rcx
je 0x25b16
movq %rbp, %rdi
movq %r15, %rsi
movl 0xc(%rsp), %ebx
movl %ebx, %edx
callq 0x22d40
movq 0x18(%rsp), %rax
movl (%rax), %esi
movq %rbp, %rdi
callq 0x90a4
cmpl $0xc, 0xc(%rax)
je 0x25b68
movl 0x8(%r15), %esi
movq %rbp, %rdi
movl %ebx, %edx
callq 0x11ee2
leaq 0x38(%rsp), %rdi
movq %rax, %rsi
callq 0x63c0
leaq 0x58(%rsp), %rdi
movq %rbp, %rsi
movq 0x10(%rsp), %r15
movq %r15, %rdx
movl %ebx, %ecx
callq 0x25cca
movl 0x8(%r15), %r15d
movq 0x20(%rsp), %rax
movl (%rax), %edx
movq (%rbp), %rax
movq %r12, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rcx
callq *0x38(%rax)
leaq 0xb8(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
leaq 0x7351c(%rip), %rdx     # 0x98f47
leaq 0x58(%rsp), %rcx
callq 0x42137
leaq 0xd8(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
callq 0x20bb0
movq %rbp, %r14
movq %rbp, %rdi
movl %r15d, %esi
movl %ebx, %edx
movq %r13, %rcx
callq 0x11ed8
movq %r13, %rdi
callq 0x6548
leaq 0xb8(%rsp), %rbp
movq %rbp, %rdi
callq 0x6548
movq %r12, %rbx
movq %r12, %rdi
callq 0x6548
movq 0x18(%rsp), %rax
movl (%rax), %r15d
movq %r13, %rdi
movq 0x28(%rsp), %rsi
movq %rbp, %rdx
callq 0x6100
movq %r14, %rbp
movq (%r14), %rax
movq %r14, %rdi
movq 0x10(%rsp), %r12
movq %r12, %rsi
movl %r15d, %edx
movl 0xc(%rsp), %r15d
movl %r15d, %ecx
movq %r13, %r8
xorl %r9d, %r9d
callq *0xa8(%rax)
movq %r13, %rdi
callq 0x6548
movl 0x8(%r12), %esi
movq %rbp, %rdi
movl %r15d, %edx
leaq 0x58(%rsp), %r12
movq %r12, %rcx
callq 0x11ed8
movq 0x20(%rsp), %r13
incl %r15d
movl %r15d, 0xc(%rsp)
movq %r12, %rdi
callq 0x6548
leaq 0x38(%rsp), %rdi
callq 0x6548
movq 0x18(%rsp), %rcx
addq $0x4, %rcx
movq 0x10(%rsp), %r15
movq %rbx, %r12
movq %r14, %rbp
jmp 0x2598f
movl 0x8(%r15), %eax
movq 0x38(%rbp), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
leaq (%rcx,%rax), %rdi
addq $0x60, %rdi
leaq 0x78(%rsp), %rsi
callq 0x19146
addq $0x6b0, %rbp            # imm = 0x6B0
movq %rbp, %rdi
movq %r13, %rsi
callq 0x1af30
leaq 0x80(%rsp), %rdi
callq 0xb51c
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x6c55d(%rip), %rsi     # 0x920d7
leaq 0x38(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x38(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xc121e(%rip), %rsi     # 0xe6dc0
movq 0xc2437(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x25bfc
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x6c4c6(%rip), %rsi     # 0x9208b
leaq 0x78(%rsp), %rdi
leaq 0x38(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x78(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xc11d3(%rip), %rsi     # 0xe6dc0
movq 0xc23ec(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x25c16
jmp 0x25cc2
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x25cc2
jmp 0x25cb2
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x25c3f
jmp 0x25cb5
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x25cb5
jmp 0x25c61
jmp 0x25cb2
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
jmp 0x25c95
jmp 0x25c61
movq %rax, %rbx
jmp 0x25ca4
movq %rax, %rbx
jmp 0x25c9a
movq %rax, %rbx
jmp 0x25c8d
movq %rax, %rbx
jmp 0x25c80
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x6548
leaq 0xb8(%rsp), %rdi
callq 0x6548
leaq 0xf8(%rsp), %rdi
callq 0x6548
leaq 0x58(%rsp), %rdi
callq 0x6548
leaq 0x38(%rsp), %rdi
callq 0x6548
jmp 0x25cb5
jmp 0x25cb2
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xb51c
movq %rbx, %rdi
callq 0x64b0