// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_interface_block_in_struct(spirv_cross::SPIRVariable const&, std::unordered_set<unsigned int, std::hash<unsigned int>, std::equal_to<unsigned int>, std::allocator<unsigned int>>&)
void CompilerHLSL::emit_interface_block_in_struct(const SPIRVariable &var, unordered_set<uint32_t> &active_locations)
{
	auto &execution = get_entry_point();
	auto type = get<SPIRType>(var.basetype);

	string binding;
	bool use_location_number = true;
	bool legacy = hlsl_options.shader_model <= 30;
	if (execution.model == ExecutionModelFragment && var.storage == StorageClassOutput)
	{
		binding = join(legacy ? "COLOR" : "SV_Target", get_decoration(var.self, DecorationLocation));
		use_location_number = false;
		if (legacy) // COLOR must be a four-component vector on legacy shader model targets (HLSL ERR_COLOR_4COMP)
			type.vecsize = 4;
	}

	const auto get_vacant_location = [&]() -> uint32_t {
		for (uint32_t i = 0; i < 64; i++)
			if (!active_locations.count(i))
				return i;
		SPIRV_CROSS_THROW("All locations from 0 to 63 are exhausted.");
	};

	bool need_matrix_unroll = var.storage == StorageClassInput && execution.model == ExecutionModelVertex;

	auto &m = ir.meta[var.self].decoration;
	auto name = to_name(var.self);
	if (use_location_number)
	{
		uint32_t location_number;

		// If an explicit location exists, use it with TEXCOORD[N] semantic.
		// Otherwise, pick a vacant location.
		if (m.decoration_flags.get(DecorationLocation))
			location_number = m.location;
		else
			location_number = get_vacant_location();

		// Allow semantic remap if specified.
		auto semantic = to_semantic(location_number);

		if (need_matrix_unroll && type.columns > 1)
		{
			if (!type.array.empty())
				SPIRV_CROSS_THROW("Arrays of matrices used as input/output. This is not supported.");

			// Unroll matrices.
			for (uint32_t i = 0; i < type.columns; i++)
			{
				SPIRType newtype = type;
				newtype.columns = 1;
				statement(to_interpolation_qualifiers(get_decoration_bitset(var.self)),
				          variable_decl(newtype, join(name, "_", i)), " : ", semantic, "_", i, ";");
				active_locations.insert(location_number++);
			}
		}
		else
		{
			statement(to_interpolation_qualifiers(get_decoration_bitset(var.self)), variable_decl(type, name), " : ",
			          semantic, ";");

			// Structs and arrays should consume more locations.
			uint32_t consumed_locations = type_to_consumed_locations(type);
			for (uint32_t i = 0; i < consumed_locations; i++)
				active_locations.insert(location_number + i);
		}
	}
	else
		statement(variable_decl(type, name), " : ", binding, ";");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %r14
callq 0x12fa4
movq %rax, %rbx
movl 0xc(%r15), %esi
movq %r14, %rdi
callq 0x90a4
leaq 0x1b0(%rsp), %rdi
movq %rax, %rsi
callq 0x1a29c
leaq 0x88(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0xb8(%rbx), %eax
xorl $0x4, %eax
movl 0x10(%r15), %ecx
xorl $0x3, %ecx
orl %eax, %ecx
setne %bpl
movq %r15, 0x8(%rsp)
jne 0x51bb8
movl 0x788(%r14), %r12d
cmpl $0x1f, %r12d
leaq 0x44eac(%rip), %rax     # 0x969f9
leaq 0x44eab(%rip), %rcx     # 0x969ff
cmovbq %rax, %rcx
movq %rcx, 0x38(%rsp)
movl 0x8(%r15), %esi
pushq $0x1e
popq %rdx
movq %r14, %rdi
callq 0x12174
leaq 0x58(%rsp), %rdx
movl %eax, (%rdx)
leaq 0x98(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x5f1d9
leaq 0x78(%rsp), %rdi
leaq 0x98(%rsp), %r15
movq %r15, %rsi
callq 0x6320
movq %r15, %rdi
callq 0x6548
cmpl $0x1e, %r12d
movq 0x8(%rsp), %r15
ja 0x51bb8
movl $0x4, 0x1c4(%rsp)
movl 0x8(%r15), %edx
movl 0x10(%r15), %eax
xorl $0x1, %eax
orl 0xb8(%rbx), %eax
sete %r15b
imulq $0x148, %rdx, %rbx      # imm = 0x148
addq 0x38(%r14), %rbx
movq (%r14), %rax
leaq 0x38(%rsp), %rdi
pushq $0x1
popq %rcx
movq %r14, %rsi
callq *0x38(%rax)
testb %bpl, %bpl
je 0x51c2d
testb $0x40, 0x63(%rbx)
jne 0x51c81
xorl %ebp, %ebp
leaq 0x98(%rsp), %rbx
movl %ebp, 0x98(%rsp)
cmpl $0x3f, %ebp
ja 0x51ed3
movq %r13, %rdi
movq %rbx, %rsi
callq 0x1aeea
movl 0x98(%rsp), %ebp
testq %rax, %rax
je 0x51c87
incl %ebp
jmp 0x51c02
movq (%r14), %rax
leaq 0x98(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %r14, %rsi
xorl %r8d, %r8d
callq *0xc8(%rax)
leaq 0x3d6ea(%rip), %rdx     # 0x8f342
leaq 0x47e22(%rip), %r8      # 0x99a81
leaq 0x98(%rsp), %rsi
leaq 0x78(%rsp), %rcx
movq %r14, %rdi
callq 0x44b42
leaq 0x98(%rsp), %rdi
jmp 0x51e9b
movl 0xa4(%rbx), %ebp
leaq 0x58(%rsp), %rdi
movq %r14, %rsi
movl %ebp, %edx
callq 0x5175a
movl 0x1c8(%rsp), %eax
cmpl $0x2, %eax
setae %cl
andb %cl, %r15b
cmpb $0x1, %r15b
jne 0x51dda
movq %r13, 0x10(%rsp)
movq 0x1d0(%rsp), %rcx
cmpq 0x1d8(%rsp), %rcx
jne 0x51f22
xorl %ecx, %ecx
leaq 0x98(%rsp), %r12
leaq 0x18(%rsp), %r13
leaq 0x170(%rsp), %r15
leaq 0x190(%rsp), %rbx
movl %ecx, 0x4(%rsp)
cmpl %eax, %ecx
jae 0x51e96
movq %r12, %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x1a29c
movl $0x1, 0xb0(%rsp)
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x12156
movq (%r14), %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq *0x140(%rcx)
movq %r15, %rdi
leaq 0x38(%rsp), %rsi
leaq 0x47205(%rip), %rdx     # 0x98f47
leaq 0x4(%rsp), %rcx
callq 0x5f35f
movq (%r14), %rax
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq *0xc8(%rax)
movq %r14, %rdi
movq %r13, %rsi
movq %rbx, %rdx
leaq 0x3d5ce(%rip), %rcx     # 0x8f342
leaq 0x58(%rsp), %r8
leaq 0x471c7(%rip), %r9      # 0x98f47
leaq 0x47cfa(%rip), %rax     # 0x99a81
pushq %rax
leaq 0xc(%rsp), %rax
pushq %rax
callq 0x5f244
popq %rax
popq %rcx
movq %rbx, %rdi
callq 0x6548
movq %r15, %rdi
callq 0x6548
movq %r13, %rdi
callq 0x6548
movl %ebp, 0x18(%rsp)
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x650d6
incl %ebp
movq %r12, %rdi
callq 0x17a3e
movl 0x4(%rsp), %ecx
incl %ecx
movl 0x1c8(%rsp), %eax
jmp 0x51cea
movq 0x8(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x12156
movq (%r14), %rcx
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq *0x140(%rcx)
movq (%r14), %rax
leaq 0x18(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
leaq 0x38(%rsp), %rcx
movq %r14, %rsi
xorl %r8d, %r8d
callq *0xc8(%rax)
leaq 0x3d519(%rip), %rcx     # 0x8f342
leaq 0x47c51(%rip), %r9      # 0x99a81
leaq 0x98(%rsp), %rsi
leaq 0x18(%rsp), %rdx
leaq 0x58(%rsp), %r8
movq %r14, %rdi
callq 0x5f3da
leaq 0x18(%rsp), %rdi
callq 0x6548
leaq 0x98(%rsp), %rdi
callq 0x6548
leaq 0x1b0(%rsp), %rsi
movq %r14, %rdi
callq 0x515da
movl %eax, %ebx
leaq 0x98(%rsp), %r14
subl $0x1, %ebx
jb 0x51e96
movl %ebp, 0x98(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x650d6
incl %ebp
jmp 0x51e7b
leaq 0x58(%rsp), %rdi
callq 0x6548
leaq 0x38(%rsp), %rdi
callq 0x6548
leaq 0x78(%rsp), %rdi
callq 0x6548
leaq 0x1b0(%rsp), %rdi
callq 0x17a3e
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x47d62(%rip), %rsi     # 0x99c47
leaq 0x98(%rsp), %rdi
leaq 0x58(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x94ead(%rip), %rsi     # 0xe6dc0
movq 0x960c6(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x44ad5(%rip), %rsi     # 0x96a09
leaq 0x98(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x98(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0x94e5e(%rip), %rsi     # 0xe6dc0
movq 0x96077(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x51f8e
jmp 0x52059
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x52059
jmp 0x5203f
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x6548
jmp 0x51fb2
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6548
jmp 0x52059
jmp 0x5203f
jmp 0x52044
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
jmp 0x5205e
jmp 0x52044
jmp 0x51fdc
movq %rax, %rbx
jmp 0x5206d
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x51ffe
jmp 0x52063
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x52063
jmp 0x5203f
jmp 0x52049
movq %rax, %rbx
leaq 0x190(%rsp), %rdi
callq 0x6548
jmp 0x52026
movq %rax, %rbx
jmp 0x52033
movq %rax, %rbx
leaq 0x170(%rsp), %rdi
callq 0x6548
leaq 0x18(%rsp), %rdi
callq 0x6548
jmp 0x5204c
movq %rax, %rbx
jmp 0x52059
movq %rax, %rbx
jmp 0x52063
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x17a3e
leaq 0x58(%rsp), %rdi
callq 0x6548
leaq 0x38(%rsp), %rdi
callq 0x6548
leaq 0x78(%rsp), %rdi
callq 0x6548
leaq 0x1b0(%rsp), %rdi
callq 0x17a3e
movq %rbx, %rdi
callq 0x64b0