// File: /workspace/github_cpp_makefile_star2_O1/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, %rbx
movq %rsi, %r15
movq %rdi, %r14
callq 0x16254
movq %rax, %r12
movl 0xc(%r15), %esi
movq %r14, %rdi
callq 0xa426
leaq 0x1b0(%rsp), %rdi
movq %rax, %rsi
callq 0x1f216
leaq 0x60(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0xb8(%r12), %eax
xorl $0x4, %eax
movl 0x10(%r15), %ecx
xorl $0x3, %ecx
orl %eax, %ecx
setne %bpl
movq %r15, 0x28(%rsp)
jne 0x64f22
movq %r15, %rdx
movl 0x788(%r14), %r15d
cmpl $0x1f, %r15d
leaq 0x57bc7(%rip), %rax     # 0xbca61
leaq 0x57bc6(%rip), %rcx     # 0xbca67
cmovbq %rax, %rcx
movq %rcx, 0x30(%rsp)
movl 0x8(%rdx), %esi
movq %r14, %rdi
movl $0x1e, %edx
callq 0x14ff6
leaq 0x98(%rsp), %rdx
movl %eax, (%rdx)
leaq 0xb8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x763a9
leaq 0x50(%rsp), %rdi
leaq 0xb8(%rsp), %r13
movq %r13, %rsi
callq 0x6310
movq (%r13), %rdi
leaq 0xc8(%rsp), %rax
cmpq %rax, %rdi
je 0x64f0c
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x6260
cmpl $0x1e, %r15d
movq 0x28(%rsp), %r15
ja 0x64f22
movl $0x4, 0x1c4(%rsp)
movl 0x8(%r15), %edx
movl 0x10(%r15), %eax
xorl $0x1, %eax
orl 0xb8(%r12), %eax
sete %r15b
imulq $0x148, %rdx, %r12      # imm = 0x148
addq 0x38(%r14), %r12
movq (%r14), %rax
leaq 0x30(%rsp), %rdi
movq %r14, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
testb %bpl, %bpl
je 0x65022
testb $0x40, 0x63(%r12)
jne 0x6508b
leaq 0xb8(%rsp), %r13
movl $0x0, (%r13)
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1fbce
movl 0xb8(%rsp), %r12d
testq %rax, %rax
je 0x64fab
leal 0x1(%r12), %eax
movl %eax, 0xb8(%rsp)
cmpl $0x40, %eax
setae %bpl
jb 0x64f7e
testb $0x1, %bpl
je 0x65093
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5acda(%rip), %rsi     # 0xbfcaf
leaq 0x5acfc(%rip), %rdx     # 0xbfcd8
leaq 0xb8(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x97d95(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x97d6d(%rip), %rsi     # 0xfcd80
movq 0x98fbe(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq (%r14), %rax
leaq 0xb8(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r14, %rsi
xorl %r8d, %r8d
callq *0xc8(%rax)
leaq 0x5031d(%rip), %rdx     # 0xb536a
leaq 0x5aa95(%rip), %r8      # 0xbfae9
leaq 0xb8(%rsp), %rsi
leaq 0x50(%rsp), %rcx
movq %r14, %rdi
callq 0x56058
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65406
movq 0xc8(%rsp), %rsi
jmp 0x653fe
movl 0xa4(%r12), %r12d
leaq 0x98(%rsp), %rdi
movq %r14, %rsi
movl %r12d, %edx
callq 0x64952
cmpl $0x2, 0x1c8(%rsp)
setae %al
andb %al, %r15b
cmpb $0x1, %r15b
jne 0x652f1
movq 0x1d0(%rsp), %rax
cmpq 0x1d8(%rsp), %rax
jne 0x654ec
movl $0x0, 0x4(%rsp)
cmpl $0x0, 0x1c8(%rsp)
je 0x653e5
leaq 0x78(%rsp), %rbp
xorl %r15d, %r15d
leaq 0x982b7(%rip), %rax     # 0xfd3b0
addq $0x10, %rax
movq %rax, 0x70(%rsp)
leaq 0xb8(%rsp), %rdi
leaq 0x1b0(%rsp), %rsi
callq 0x1f216
movl $0x1, 0xd0(%rsp)
movq 0x28(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x14fd8
movq (%r14), %rcx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq *0x140(%rcx)
leaq 0x190(%rsp), %r13
movq %r13, %rdi
leaq 0x30(%rsp), %rsi
leaq 0x59e52(%rip), %rdx     # 0xbefaf
leaq 0x4(%rsp), %rcx
callq 0x76572
movq (%r14), %rax
movq %rbp, %rdi
movq %r14, %rsi
leaq 0xb8(%rsp), %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq *0xc8(%rax)
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
movq %rbp, %rdx
leaq 0x501d4(%rip), %rcx     # 0xb536a
leaq 0x98(%rsp), %r8
leaq 0x59e0a(%rip), %r9      # 0xbefaf
leaq 0x5a93d(%rip), %rax     # 0xbfae9
pushq %rax
leaq 0xc(%rsp), %rax
pushq %rax
callq 0x76436
addq $0x10, %rsp
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x651de
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x65203
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x6521f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movl %r12d, 0x78(%rsp)
movq %rbx, 0x8(%rsp)
movq %rbx, %rdi
movq %rbp, %rsi
leaq 0x8(%rsp), %rdx
callq 0x7e27c
movq 0x70(%rsp), %rax
movq %rax, 0xb8(%rsp)
leaq 0x158(%rsp), %rdi
callq 0xdeb6
movq 0x120(%rsp), %rdi
testq %rdi, %rdi
je 0x65270
movq 0x130(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq 0xf0(%rsp), %rdi
testq %rdi, %rdi
je 0x652b5
movq 0x110(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq %r15, 0xf0(%rsp)
movl %r15d, 0xf8(%rsp)
movq %r15, 0x100(%rsp)
movl %r15d, 0x108(%rsp)
movq %r15, 0x110(%rsp)
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x652d2
movq 0xe8(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movl 0x4(%rsp), %eax
incl %eax
movl %eax, 0x4(%rsp)
incl %r12d
cmpl 0x1c8(%rsp), %eax
jb 0x65102
jmp 0x653e5
movq 0x28(%rsp), %rax
movl 0x8(%rax), %esi
movq %r14, %rdi
callq 0x14fd8
movq (%r14), %rcx
leaq 0xb8(%rsp), %rdi
movq %r14, %rsi
movq %rax, %rdx
callq *0x140(%rcx)
movq (%r14), %rax
leaq 0x8(%rsp), %rdi
leaq 0x1b0(%rsp), %rdx
leaq 0x30(%rsp), %rcx
movq %r14, %rsi
xorl %r8d, %r8d
callq *0xc8(%rax)
leaq 0x5002a(%rip), %rcx     # 0xb536a
leaq 0x5a7a2(%rip), %r9      # 0xbfae9
leaq 0xb8(%rsp), %rsi
leaq 0x8(%rsp), %rdx
leaq 0x98(%rsp), %r8
movq %r14, %rdi
callq 0x7661e
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6537f
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x653a0
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x1b0(%rsp), %rsi
movq %r14, %rdi
callq 0x647aa
movl %eax, %ebp
testl %eax, %eax
je 0x653e5
leaq 0x8(%rsp), %r14
leaq 0xb8(%rsp), %r15
movl %r12d, 0x8(%rsp)
movq %rbx, 0xb8(%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x7e27c
incl %r12d
decl %ebp
jne 0x653c3
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65406
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65421
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6543d
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x97f6c(%rip), %rax     # 0xfd3b0
addq $0x10, %rax
leaq 0x250(%rsp), %rbx
movq %rax, -0xa0(%rbx)
movq %rbx, %rdi
callq 0xdeb6
movq -0x38(%rbx), %rdi
testq %rdi, %rdi
je 0x65478
movq 0x228(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq 0x1e8(%rsp), %rdi
testq %rdi, %rdi
je 0x654bd
movq 0x208(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
xorl %eax, %eax
movq %rax, 0x1e8(%rsp)
movl %eax, 0x1f0(%rsp)
movq %rax, 0x1f8(%rsp)
movl %eax, 0x200(%rsp)
movq %rax, 0x208(%rsp)
movq 0x1d0(%rsp), %rdi
testq %rdi, %rdi
je 0x654da
movq 0x1e0(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0xc8(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x57565(%rip), %rsi     # 0xbca71
leaq 0x5759d(%rip), %rdx     # 0xbcab0
leaq 0xb8(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x9785e(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x97836(%rip), %rsi     # 0xfcd80
movq 0x98a87(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x65581
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x65581
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x65713
movq %r14, %rdi
callq 0x6200
jmp 0x65713
movq %rax, %rbx
movq 0xb8(%rsp), %rdi
cmpq %r15, %rdi
je 0x655bf
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x655bf
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x656f2
movq %r14, %rdi
callq 0x6200
jmp 0x656f2
jmp 0x656dd
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x655fd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x655fd
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x656f2
movq 0xc8(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x656f2
jmp 0x656dd
jmp 0x6565f
movq %rax, %rbx
leaq 0xc8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65713
movq 0xc8(%rsp), %rsi
jmp 0x6570b
jmp 0x6565f
jmp 0x65657
movq %rax, %rbx
jmp 0x6572e
movq %rax, %rbx
jmp 0x65713
jmp 0x656dd
movq %rax, %rbx
jmp 0x656bd
movq %rax, %rbx
jmp 0x65698
movq %rax, %rbx
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x65698
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x190(%rsp), %rdi
leaq 0x1a0(%rsp), %rax
cmpq %rax, %rdi
je 0x656bd
movq 0x1a0(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x656e5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x656e5
jmp 0x656e2
movq %rax, %rbx
jmp 0x656f2
movq %rax, %rbx
leaq 0xb8(%rsp), %rdi
callq 0x1c438
leaq 0xa8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x65713
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x6572e
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6574a
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x1b0(%rsp), %rdi
callq 0x1c438
movq %rbx, %rdi
callq 0x64a0
nop