// File: /workspace/github_cpp_makefile_star2_O3/rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::emit_function_prototype(spirv_cross::SPIRFunction&, spirv_cross::Bitset const&)
void CompilerHLSL::emit_function_prototype(SPIRFunction &func, const Bitset &return_flags)
{
	if (func.self != ir.default_entry_point)
		add_function_overload(func);

	auto &execution = get_entry_point();
	// Avoid shadow declarations.
	local_variable_names = resource_names;

	string decl;

	auto &type = get<SPIRType>(func.return_type);
	if (type.array.empty())
	{
		decl += flags_to_precision_qualifiers_glsl(type, return_flags);
		decl += type_to_glsl(type);
		decl += " ";
	}
	else
	{
		// We cannot return arrays in HLSL, so "return" through an out variable.
		decl = "void ";
	}

	if (func.self == ir.default_entry_point)
	{
		if (execution.model == ExecutionModelVertex)
			decl += "vert_main";
		else if (execution.model == ExecutionModelFragment)
			decl += "frag_main";
		else if (execution.model == ExecutionModelGLCompute)
			decl += "comp_main";
		else
			SPIRV_CROSS_THROW("Unsupported execution model.");
		processing_entry_point = true;
	}
	else
		decl += to_name(func.self);

	decl += "(";

	if (!type.array.empty())
	{
		// Fake array returns by writing to an out array instead.
		decl += "out ";
		decl += type_to_glsl(type);
		decl += " ";
		decl += "SPIRV_Cross_return_value";
		decl += type_to_array_glsl(type);
		if (!func.arguments.empty())
			decl += ", ";
	}

	for (auto &arg : func.arguments)
	{
		// Might change the variable name if it already exists in this function.
		// SPIRV OpName doesn't have any semantic effect, so it's valid for an implementation
		// to use same name for variables.
		// Since we want to make the GLSL debuggable and somewhat sane, use fallback names for variables which are duplicates.
		add_local_variable_name(arg.id);

		decl += argument_decl(arg);

		// Flatten a combined sampler to two separate arguments in modern HLSL.
		auto &arg_type = get<SPIRType>(arg.type);
		if (hlsl_options.shader_model > 30 && arg_type.basetype == SPIRType::SampledImage &&
		    arg_type.image.dim != DimBuffer)
		{
			// Manufacture automatic sampler arg for SampledImage texture
			decl += ", ";
			decl += join(image_is_comparison(arg_type, arg.id) ? "SamplerComparisonState " : "SamplerState ",
			             to_sampler_expression(arg.id), type_to_array_glsl(arg_type));
		}

		if (&arg != &func.arguments.back())
			decl += ", ";

		// Hold a pointer to the parameter so we can invalidate the readonly field if needed.
		auto *var = maybe_get<SPIRVariable>(arg.id);
		if (var)
			var->parameter = &arg;
	}

	decl += ")";
	statement(decl);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %r14
movq %rsi, %rbp
movq %rdi, %rbx
movl 0x8(%rsi), %eax
cmpl 0x108(%rdi), %eax
je 0x68f6a
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4ce5a
movq %rbx, %rdi
callq 0x15f76
movq %rax, %r12
leaq 0x488(%rbx), %rsi
leaq 0x450(%rbx), %rdi
callq 0xd596
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movl 0xc(%rbp), %esi
movq %rbx, %rdi
callq 0xa3ea
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq 0x28(%r15), %rax
je 0x68fd5
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x54b02(%rip), %rcx     # 0xbdac8
movl $0x5, %r8d
xorl %esi, %esi
callq 0x63f0
jmp 0x69043
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2b8e0
leaq 0x20(%rsp), %rdi
movq %rax, %rsi
callq 0x64e0
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x98(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x60b0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69032
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x4b875(%rip), %rsi     # 0xb48ae
leaq 0x20(%rsp), %rdi
callq 0x64e0
movl 0x8(%rbp), %edx
cmpl 0x108(%rbx), %edx
jne 0x69071
movl 0xb8(%r12), %eax
testl %eax, %eax
je 0x690bb
cmpl $0x5, %eax
je 0x690b2
cmpl $0x4, %eax
jne 0x693c0
leaq 0x54a69(%rip), %rsi     # 0xbdad8
jmp 0x690c2
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x60b0
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x690d3
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x690d3
leaq 0x54a29(%rip), %rsi     # 0xbdae2
jmp 0x690c2
leaq 0x54a0c(%rip), %rsi     # 0xbdace
leaq 0x20(%rsp), %rdi
callq 0x64e0
movb $0x1, 0x5d8(%rbx)
leaq 0x59b97(%rip), %rsi     # 0xc2c71
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
je 0x691b9
leaq 0x514ca(%rip), %rsi     # 0xba5c3
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq (%rbx), %rax
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x98(%rax)
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x60b0
leaq 0x10(%rsp), %r14
movq -0x10(%r14), %rdi
cmpq %r14, %rdi
je 0x69145
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x4b762(%rip), %rsi     # 0xb48ae
leaq 0x20(%rsp), %rdi
callq 0x64e0
leaq 0x51a08(%rip), %rsi     # 0xbab65
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b55a
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x60b0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x6919e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x18(%rbp), %rax
cmpq 0x20(%rbp), %rax
je 0x691b9
leaq 0x50efc(%rip), %rsi     # 0xba0ab
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq 0x18(%rbp), %r15
movq %rbp, 0x48(%rsp)
movq 0x20(%rbp), %rax
movq %rax, 0x40(%rsp)
cmpq %rax, %r15
je 0x69374
leaq 0x20(%rsp), %r13
leaq 0x78(%rsp), %rbp
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0x393f2
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4bf50
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x60b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69224
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movl (%r15), %esi
movq %rbx, %rdi
callq 0xa3ea
cmpl $0x1f, 0x788(%rbx)
jb 0x6932f
movq %rax, %r14
cmpl $0xe, 0xc(%rax)
jne 0x6932f
cmpl $0x5, 0x84(%r14)
je 0x6932f
movq %r13, %rdi
leaq 0x50e4a(%rip), %rsi     # 0xba0ab
callq 0x64e0
movl 0x4(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1b12c
testb %al, %al
leaq 0x54886(%rip), %rax     # 0xbdb04
leaq 0x54867(%rip), %rcx     # 0xbdaec
cmovneq %rcx, %rax
movq %rax, 0x70(%rsp)
movl 0x4(%r15), %edx
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x68c70
movq %rbp, %r12
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2b55a
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %r12, %rcx
callq 0x7917d
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x60b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x692f1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x69313
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x6932f
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
addq $-0x14, %rax
cmpq %rax, %r15
je 0x69350
movq %r13, %rdi
leaq 0x50d60(%rip), %rsi     # 0xba0ab
callq 0x64e0
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0xc7b4
testq %rax, %rax
je 0x69365
movq %r15, 0x68(%rax)
addq $0x14, %r15
cmpq 0x40(%rsp), %r15
jne 0x691de
leaq 0x5169a(%rip), %rsi     # 0xbaa15
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %r13
callq 0x64e0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xb634
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x693ae
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x4b2f4(%rip), %rsi     # 0xb46d1
leaq 0x4b309(%rip), %rdx     # 0xb46ed
movq %rsp, %rdi
callq 0x7be0
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x929c7(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x9299f(%rip), %rsi     # 0xfbdb0
movq 0x93bc0(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x69439
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x69446
jmp 0x69537
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
jmp 0x69537
jmp 0x6946e
jmp 0x69497
jmp 0x6946e
jmp 0x69497
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x69483
jmp 0x69537
jmp 0x69497
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69537
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69537
jmp 0x69497
movq %rax, %rbx
jmp 0x69537
jmp 0x6952f
movq %rax, %rbx
jmp 0x694d1
jmp 0x6952f
movq %rax, %rbx
jmp 0x694f3
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x694d1
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x694f3
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x69532
movq 0x60(%rsp), %rsi
jmp 0x69523
jmp 0x6952f
jmp 0x6952f
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69532
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69532
jmp 0x6952f
movq %rax, %rbx
leaq 0x30(%rsp), %r13
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x6954e
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0