// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_io_block(spirv_cross::SPIRVariable const&)
void CompilerHLSL::emit_io_block(const SPIRVariable &var)
{
	auto &type = get<SPIRType>(var.basetype);
	add_resource_name(type.self);

	statement("struct ", to_name(type.self));
	begin_scope();
	type.member_name_cache.clear();

	uint32_t base_location = get_decoration(var.self, DecorationLocation);

	for (uint32_t i = 0; i < uint32_t(type.member_types.size()); i++)
	{
		string semantic;
		if (has_member_decoration(type.self, i, DecorationLocation))
		{
			uint32_t location = get_member_decoration(type.self, i, DecorationLocation);
			semantic = join(" : ", to_semantic(location));
		}
		else
		{
			// If the block itself has a location, but not its members, use the implicit location.
			// There could be a conflict if the block members partially specialize the locations.
			// It is unclear how SPIR-V deals with this. Assume this does not happen for now.
			uint32_t location = base_location + i;
			semantic = join(" : ", to_semantic(location));
		}

		add_member_name(type, i);

		auto &membertype = get<SPIRType>(type.member_types[i]);
		statement(to_interpolation_qualifiers(get_member_decoration_bitset(type.self, i)),
		          variable_decl(membertype, to_member_name(type, i)), semantic, ";");
	}

	end_scope_decl();
	statement("");

	statement("static ", variable_decl(var), ";");
	statement("");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x198(%rbp)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x198(%rbp), %rdi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
movq -0x198(%rbp), %rsi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x38(%rbp), %rdi
movq %rdi, -0x190(%rbp)
movl $0x1, %ecx
callq *%rax
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rdx
leaq 0x83a9e(%rip), %rsi     # 0x140f3b
callq 0xd7500
jmp 0xbd4a4
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x198(%rbp), %rdi
callq 0x5c200
movq -0x18(%rbp), %rdi
addq $0xa0, %rdi
callq 0x9e1e0
movq -0x198(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x1e, %edx
callq 0x23520
movl %eax, -0x48(%rbp)
movl $0x0, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movl %eax, -0x19c(%rbp)
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
callq 0x8650
movq %rax, %rcx
movl -0x19c(%rbp), %eax
cmpl %ecx, %eax
jae 0xbd84f
leaq -0x70(%rbp), %rdi
callq 0x7530
movq -0x198(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x4c(%rbp), %edx
movl $0x1e, %ecx
callq 0x21f90
movb %al, -0x19d(%rbp)
jmp 0xbd53e
movb -0x19d(%rbp), %al
testb $0x1, %al
jne 0xbd54d
jmp 0xbd622
movq -0x198(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x4c(%rbp), %edx
movl $0x1e, %ecx
callq 0x231b0
movl %eax, -0x1a4(%rbp)
jmp 0xbd570
movq -0x198(%rbp), %rsi
movl -0x1a4(%rbp), %eax
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %edx
leaq -0xb8(%rbp), %rdi
callq 0xbd370
jmp 0xbd591
leaq 0x80dc1(%rip), %rsi     # 0x13e359
leaq -0x98(%rbp), %rdi
leaq -0xb8(%rbp), %rdx
callq 0xa7430
jmp 0xbd5ad
leaq -0x70(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x7430
leaq -0x98(%rbp), %rdi
callq 0x7708
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xbd6ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7708
jmp 0xbd8ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xbd841
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0xbd841
movq -0x198(%rbp), %rsi
movl -0x48(%rbp), %eax
movl -0x4c(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xbc(%rbp)
movl -0xbc(%rbp), %edx
leaq -0x100(%rbp), %rdi
callq 0xbd370
jmp 0xbd64b
leaq 0x80d07(%rip), %rsi     # 0x13e359
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0xa7430
jmp 0xbd667
leaq -0x70(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x7430
leaq -0xe0(%rbp), %rdi
callq 0x7708
leaq -0x100(%rbp), %rdi
callq 0x7708
jmp 0xbd6ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x7708
jmp 0xbd841
movq -0x198(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x4c(%rbp), %edx
callq 0x5c240
jmp 0xbd6c3
movq -0x18(%rbp), %rdi
addq $0x68, %rdi
movl -0x4c(%rbp), %eax
movl %eax, %esi
callq 0x8630
movq -0x198(%rbp), %rdi
movl (%rax), %esi
callq 0xea90
movq %rax, -0x1b0(%rbp)
jmp 0xbd6ec
movq -0x198(%rbp), %rdi
movq -0x1b0(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x18(%rbp), %rax
movl 0x8(%rax), %esi
movl -0x4c(%rbp), %edx
callq 0x23220
movq %rax, -0x1b8(%rbp)
jmp 0xbd719
movq -0x1b8(%rbp), %rdx
movq -0x198(%rbp), %rsi
movq (%rsi), %rax
movq 0x140(%rax), %rax
leaq -0x128(%rbp), %rdi
callq *%rax
jmp 0xbd73c
movq -0x198(%rbp), %rsi
movq -0x108(%rbp), %rax
movq %rax, -0x1c0(%rbp)
movq -0x18(%rbp), %rdx
movl -0x4c(%rbp), %ecx
leaq -0x168(%rbp), %rdi
callq 0x62230
jmp 0xbd766
movq -0x1c0(%rbp), %rdx
movq -0x198(%rbp), %rsi
movq (%rsi), %rax
movq 0xc8(%rax), %rax
leaq -0x148(%rbp), %rdi
leaq -0x168(%rbp), %rcx
xorl %r8d, %r8d
callq *%rax
jmp 0xbd793
movq -0x198(%rbp), %rdi
leaq 0x8b905(%rip), %r8      # 0x1490a6
leaq -0x128(%rbp), %rsi
leaq -0x148(%rbp), %rdx
leaq -0x70(%rbp), %rcx
callq 0xd7620
jmp 0xbd7ba
leaq -0x148(%rbp), %rdi
callq 0x7708
leaq -0x168(%rbp), %rdi
callq 0x7708
leaq -0x128(%rbp), %rdi
callq 0x7708
leaq -0x70(%rbp), %rdi
callq 0x7708
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0xbd4eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xbd835
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xbd829
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x7708
leaq -0x168(%rbp), %rdi
callq 0x7708
leaq -0x128(%rbp), %rdi
callq 0x7708
leaq -0x70(%rbp), %rdi
callq 0x7708
jmp 0xbd8ef
movq -0x198(%rbp), %rdi
callq 0x5c350
movq -0x198(%rbp), %rdi
leaq 0x81035(%rip), %rsi     # 0x13e89e
callq 0xedf0
movq -0x198(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x188(%rbp), %rdi
movq %rdi, -0x1c8(%rbp)
callq 0x62d60
movq -0x198(%rbp), %rdi
movq -0x1c8(%rbp), %rdx
leaq 0x8870d(%rip), %rsi     # 0x145fae
leaq 0x8b7fe(%rip), %rcx     # 0x1490a6
callq 0xa8cb0
jmp 0xbd8af
leaq -0x188(%rbp), %rdi
callq 0x7708
movq -0x198(%rbp), %rdi
leaq 0x80fd5(%rip), %rsi     # 0x13e89e
callq 0xedf0
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x188(%rbp), %rdi
callq 0x7708
movq -0x40(%rbp), %rdi
callq 0x7640
nopl (%rax,%rax)