// File: /workspace/github_cpp_makefile_star2_O1/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 0x69854
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x4d5f8
movq %rbx, %rdi
callq 0x16254
movq %rax, %r12
leaq 0x488(%rbx), %rsi
leaq 0x450(%rbx), %rdi
callq 0xd5d6
leaq 0x30(%rsp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
movl 0xc(%rbp), %esi
movq %rbx, %rdi
callq 0xa426
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq 0x28(%r15), %rax
je 0x698bf
leaq 0x20(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x55210(%rip), %rcx     # 0xbeac0
movl $0x5, %r8d
xorl %esi, %esi
callq 0x63f0
jmp 0x6992d
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2beea
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 0x6991c
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x4bf8b(%rip), %rsi     # 0xb58ae
leaq 0x20(%rsp), %rdi
callq 0x64e0
movl 0x8(%rbp), %edx
cmpl 0x108(%rbx), %edx
jne 0x6995b
movl 0xb8(%r12), %eax
testl %eax, %eax
je 0x699a5
cmpl $0x5, %eax
je 0x6999c
cmpl $0x4, %eax
jne 0x69caa
leaq 0x55177(%rip), %rsi     # 0xbead0
jmp 0x699ac
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 0x699bd
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x699bd
leaq 0x55137(%rip), %rsi     # 0xbeada
jmp 0x699ac
leaq 0x5511a(%rip), %rsi     # 0xbeac6
leaq 0x20(%rsp), %rdi
callq 0x64e0
movb $0x1, 0x5d8(%rbx)
leaq 0x5a2dd(%rip), %rsi     # 0xc3ca1
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
je 0x69aa3
leaq 0x51bf0(%rip), %rsi     # 0xbb5d3
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 0x69a2f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x4be78(%rip), %rsi     # 0xb58ae
leaq 0x20(%rsp), %rdi
callq 0x64e0
leaq 0x5212e(%rip), %rsi     # 0xbbb75
leaq 0x20(%rsp), %rdi
callq 0x64e0
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2bb66
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x20(%rsp), %rdi
callq 0x60b0
movq (%rsp), %rdi
cmpq %r14, %rdi
je 0x69a88
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x18(%rbp), %rax
cmpq 0x20(%rbp), %rax
je 0x69aa3
leaq 0x51622(%rip), %rsi     # 0xbb0bb
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 0x69c5e
leaq 0x20(%rsp), %r13
leaq 0x78(%rsp), %rbp
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0x39b62
movq %rsp, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x4c6d4
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x60b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69b0e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movl (%r15), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0x1f, 0x788(%rbx)
jb 0x69c19
movq %rax, %r14
cmpl $0xe, 0xc(%rax)
jne 0x69c19
cmpl $0x5, 0x84(%r14)
je 0x69c19
movq %r13, %rdi
leaq 0x51570(%rip), %rsi     # 0xbb0bb
callq 0x64e0
movl 0x4(%r15), %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1b812
testb %al, %al
leaq 0x54f94(%rip), %rax     # 0xbeafc
leaq 0x54f75(%rip), %rcx     # 0xbeae4
cmovneq %rcx, %rax
movq %rax, 0x70(%rsp)
movl 0x4(%r15), %edx
leaq 0x50(%rsp), %rdi
movq %rbx, %rsi
callq 0x69554
movq %rbp, %r12
movq %rbp, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2bb66
movq %rsp, %rdi
leaq 0x70(%rsp), %rsi
leaq 0x50(%rsp), %rdx
movq %r12, %rcx
callq 0x79c89
movq (%rsp), %rsi
movq 0x8(%rsp), %rdx
movq %r13, %rdi
callq 0x60b0
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69bdb
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x69bfd
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x69c19
movq 0x60(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x48(%rsp), %rax
movq 0x20(%rax), %rax
addq $-0x14, %rax
cmpq %rax, %r15
je 0x69c3a
movq %r13, %rdi
leaq 0x51486(%rip), %rsi     # 0xbb0bb
callq 0x64e0
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0xc7f4
testq %rax, %rax
je 0x69c4f
movq %r15, 0x68(%rax)
addq $0x14, %r15
cmpq 0x40(%rsp), %r15
jne 0x69ac8
leaq 0x51dc0(%rip), %rsi     # 0xbba25
leaq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %r13
callq 0x64e0
leaq 0x20(%rsp), %rsi
movq %rbx, %rdi
callq 0xb674
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x69c98
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 0x4ba0a(%rip), %rsi     # 0xb56d1
leaq 0x4ba1f(%rip), %rdx     # 0xb56ed
movq %rsp, %rdi
callq 0x7c64
movb $0x1, %bpl
movq %rsp, %rsi
movq %r14, %rdi
callq 0x6320
leaq 0x930ad(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0x93085(%rip), %rsi     # 0xfcd80
movq 0x942d6(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x69d2b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69d2b
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x69e25
movq %r14, %rdi
callq 0x6200
jmp 0x69e25
jmp 0x69d5c
jmp 0x69d85
jmp 0x69d5c
jmp 0x69d85
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r14, %rdi
jne 0x69d71
jmp 0x69e25
jmp 0x69d85
movq %rax, %rbx
leaq 0x10(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x69e25
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69e25
jmp 0x69d85
movq %rax, %rbx
jmp 0x69e25
jmp 0x69e1d
movq %rax, %rbx
jmp 0x69dbf
jmp 0x69e1d
movq %rax, %rbx
jmp 0x69de1
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69dbf
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x69de1
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x69e20
movq 0x60(%rsp), %rsi
jmp 0x69e11
jmp 0x69e1d
jmp 0x69e1d
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x69e20
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x69e20
jmp 0x69e1d
movq %rax, %rbx
leaq 0x30(%rsp), %r13
movq 0x20(%rsp), %rdi
cmpq %r13, %rdi
je 0x69e3c
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0