// File: /workspace/github_cpp_makefile_star2_O1/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_builtin_outputs_in_struct()
void CompilerHLSL::emit_builtin_outputs_in_struct()
{
	bool legacy = hlsl_options.shader_model <= 30;
	active_output_builtins.for_each_bit([&](uint32_t i) {
		const char *type = nullptr;
		const char *semantic = nullptr;
		auto builtin = static_cast<BuiltIn>(i);
		switch (builtin)
		{
		case BuiltInPosition:
			type = "float4";
			semantic = legacy ? "POSITION" : "SV_Position";
			break;

		case BuiltInFragDepth:
			type = "float";
			semantic = legacy ? "DEPTH" : "SV_Depth";
			break;

		case BuiltInClipDistance:
			// HLSL is a bit weird here, use SV_ClipDistance0, SV_ClipDistance1 and so on with vectors.
			for (uint32_t clip = 0; clip < clip_distance_count; clip += 4)
			{
				uint32_t to_declare = clip_distance_count - clip;
				if (to_declare > 4)
					to_declare = 4;

				uint32_t semantic_index = clip / 4;

				static const char *types[] = { "float", "float2", "float3", "float4" };
				statement(types[to_declare - 1], " ", builtin_to_glsl(builtin, StorageClassOutput), semantic_index,
				          " : SV_ClipDistance", semantic_index, ";");
			}
			break;

		case BuiltInCullDistance:
			// HLSL is a bit weird here, use SV_CullDistance0, SV_CullDistance1 and so on with vectors.
			for (uint32_t cull = 0; cull < cull_distance_count; cull += 4)
			{
				uint32_t to_declare = cull_distance_count - cull;
				if (to_declare > 4)
					to_declare = 4;

				uint32_t semantic_index = cull / 4;

				static const char *types[] = { "float", "float2", "float3", "float4" };
				statement(types[to_declare - 1], " ", builtin_to_glsl(builtin, StorageClassOutput), semantic_index,
				          " : SV_CullDistance", semantic_index, ";");
			}
			break;

		case BuiltInPointSize:
			// If point_size_compat is enabled, just ignore PointSize.
			// PointSize does not exist in HLSL, but some code bases might want to be able to use these shaders,
			// even if it means working around the missing feature.
			if (hlsl_options.point_size_compat)
				break;
			else
				SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");

		default:
			SPIRV_CROSS_THROW("Unsupported builtin in HLSL.");
			break;
		}

		if (type && semantic)
			statement(type, " ", builtin_to_glsl(builtin, StorageClassOutput), " : ", semantic, ";");
	});
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x40, %rsp
movq %rdi, %rbx
cmpl $0x1f, 0x788(%rdi)
leaq 0xf(%rsp), %rax
setb (%rax)
leaq 0x30(%rsp), %r14
movq %rax, (%r14)
movq %rdi, 0x8(%r14)
xorl %r15d, %r15d
movq 0x310(%rbx), %rax
btq %r15, %rax
jae 0x64530
movq %r14, %rdi
movl %r15d, %esi
callq 0x740b0
incq %r15
cmpq $0x40, %r15
jne 0x64518
movq 0x330(%rbx), %rsi
testq %rsi, %rsi
je 0x6461c
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
callq 0x7d4ee
movq 0x328(%rbx), %r14
testq %r14, %r14
je 0x645a1
leaq 0x10(%rsp), %rbx
leaq 0x8(%r14), %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x64591
movl (%rdx), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x18(%rsp)
jmp 0x64599
movq %rbx, %rdi
callq 0x7a00
movq (%r14), %r14
testq %r14, %r14
jne 0x64572
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r14
cmpq %r14, %rbx
je 0x645dd
movq %r14, %rax
subq %rbx, %rax
sarq $0x2, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21b53
movq %rbx, %rdi
movq %r14, %rsi
callq 0x21c36
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
cmpq %r15, %r14
je 0x64605
leaq 0x30(%rsp), %rbx
movl (%r14), %esi
movq %rbx, %rdi
callq 0x740b0
addq $0x4, %r14
cmpq %r15, %r14
jne 0x645f1
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x6461c
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
addq $0x40, %rsp
popq %rbx
popq %r14
popq %r15
retq
jmp 0x6462a
jmp 0x6462a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x64644
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0