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

	local_variable_names = resource_names;
	string decl;

	processing_entry_point = (func.self == ir.default_entry_point);

	auto &type = get<SPIRType>(func.return_type);

	if (type.array.empty())
	{
		decl += func_type_decl(type);
	}
	else
	{
		// We cannot return arrays in MSL, so "return" through an out variable.
		decl = "void";
	}

	decl += " ";
	decl += to_name(func.self);
	decl += "(";

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

	if (processing_entry_point)
	{
		decl += entry_point_args(!func.arguments.empty());

		// If entry point function has variables that require early declaration,
		// ensure they each have an empty initializer, creating one if needed.
		// This is done at this late stage because the initialization expression
		// is cleared after each compilation pass.
		for (auto var_id : vars_needing_early_declaration)
		{
			auto &ed_var = get<SPIRVariable>(var_id);
			if (!ed_var.initializer)
				ed_var.initializer = ir.increase_bound_by(1);

			set<SPIRExpression>(ed_var.initializer, "{}", ed_var.basetype, true);
		}
	}

	for (auto &arg : func.arguments)
	{
		uint32_t name_id = arg.id;

		string address_space;
		auto *var = maybe_get<SPIRVariable>(arg.id);
		if (var)
		{
			// If we need to modify the name of the variable, make sure we modify the original variable.
			// Our alias is just a shadow variable.
			if (arg.alias_global_variable && var->basevariable)
				name_id = var->basevariable;

			var->parameter = &arg; // Hold a pointer to the parameter so we can invalidate the readonly field if needed.
			address_space = get_argument_address_space(*var);
		}

		add_local_variable_name(name_id);

		if (!address_space.empty())
			decl += address_space + " ";
		decl += argument_decl(arg);

		// Manufacture automatic sampler arg for SampledImage texture
		auto &arg_type = get<SPIRType>(arg.type);
		if (arg_type.basetype == SPIRType::SampledImage && arg_type.image.dim != DimBuffer)
			decl += join(", thread const ", sampler_type(arg_type), " ", to_sampler_expression(arg.id));

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

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movl 0x8(%rsi), %eax
cmpl 0x108(%rdi), %eax
je 0x76669
movq %rbx, %rdi
movq %r15, %rsi
callq 0x3e668
leaq 0x488(%rbx), %rsi
leaq 0x450(%rbx), %rdi
callq 0xb54c
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movl 0x8(%r15), %eax
cmpl 0x108(%rbx), %eax
sete 0x5d8(%rbx)
movl 0xc(%r15), %esi
movq %rbx, %rdi
callq 0x90a4
movq %rax, %r14
movq 0x20(%rax), %rax
cmpq 0x28(%r14), %rax
je 0x766ca
leaq 0x1c613(%rip), %rsi     # 0x92cd1
leaq 0x28(%rsp), %rdi
callq 0x64e0
jmp 0x766f3
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x76af6
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x64f0
leaq 0x8(%rsp), %rdi
callq 0x6548
leaq 0x1918c(%rip), %rsi     # 0x8f886
leaq 0x28(%rsp), %rdi
callq 0x64d0
movl 0x8(%r15), %edx
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
pushq $0x1
popq %rcx
movq %rbx, %rsi
callq *0x38(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x64f0
leaq 0x8(%rsp), %rdi
callq 0x6548
leaq 0x274f0(%rip), %rsi     # 0x9dc29
leaq 0x28(%rsp), %rdi
callq 0x64d0
movq 0x20(%r14), %rax
cmpq 0x28(%r14), %rax
je 0x767e6
leaq 0x27210(%rip), %rsi     # 0x9d968
leaq 0x28(%rsp), %rdi
callq 0x64d0
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq *0x98(%rax)
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x64f0
leaq 0x8(%rsp), %rdi
callq 0x6548
leaq 0x271d8(%rip), %rsi     # 0x9d970
leaq 0x28(%rsp), %rdi
callq 0x64d0
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x2547c
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x64f0
leaq 0x8(%rsp), %rdi
callq 0x6548
movq 0x18(%r15), %rax
cmpq 0x20(%r15), %rax
je 0x767e6
leaq 0x1e8af(%rip), %rsi     # 0x9508b
leaq 0x28(%rsp), %rdi
callq 0x64d0
movq %r15, 0x50(%rsp)
cmpb $0x1, 0x5d8(%rbx)
jne 0x7689e
movq 0x50(%rsp), %rcx
movq 0x18(%rcx), %rax
xorl %edx, %edx
cmpq 0x20(%rcx), %rax
setne %dl
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x76d50
leaq 0x28(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x64f0
leaq 0x8(%rbx), %rax
movq %rax, 0x48(%rsp)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x6548
movq 0x8e0(%rbx), %rbp
movq 0x8e8(%rbx), %r14
leaq 0x2713c(%rip), %r12     # 0x9d98d
cmpq %r14, %rbp
je 0x7689e
movl (%rbp), %esi
movq %rbx, %rdi
callq 0x9c0e
movq %rax, %r13
movl 0x18(%rax), %eax
testl %eax, %eax
jne 0x7687c
movq 0x48(%rsp), %rdi
pushq $0x1
popq %rsi
callq 0x202bc
movl %eax, 0x18(%r13)
addq $0xc, %r13
movb $0x1, 0x8(%rsp)
movq %rbx, %rdi
movl %eax, %esi
movq %r12, %rdx
movq %r13, %rcx
movq %r15, %r8
callq 0x819fa
addq $0x4, %rbp
jmp 0x76851
movq 0x50(%rsp), %rax
movq 0x18(%rax), %r15
movq 0x20(%rax), %rax
movq %rax, 0x48(%rsp)
leaq 0x78(%rsp), %r12
leaq 0x28(%rsp), %r13
leaq 0x98(%rsp), %rbp
cmpq 0x48(%rsp), %r15
je 0x76a3a
movl 0x4(%r15), %r14d
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0xa9e4
testq %rax, %rax
je 0x7692f
cmpb $0x1, 0x10(%r15)
jne 0x76908
movl 0x1c(%rax), %ecx
testl %ecx, %ecx
je 0x76908
movl %ecx, %r14d
movq %r15, 0x68(%rax)
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x6f534
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x6320
movq %r12, %rdi
callq 0x6548
movq %rbx, %rdi
movl %r14d, %esi
callq 0x2f168
cmpq $0x0, 0x10(%rsp)
je 0x76969
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
leaq 0x18f35(%rip), %rdx     # 0x8f886
callq 0x174a5
movq %r13, %rdi
movq %r12, %rsi
callq 0x64f0
movq %r12, %rdi
callq 0x6548
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x77e06
movq %r13, %rdi
movq %r12, %rsi
callq 0x64f0
movq %r12, %rdi
callq 0x6548
movl (%r15), %esi
movq %rbx, %rdi
callq 0x90a4
cmpl $0xe, 0xc(%rax)
jne 0x76a06
cmpl $0x5, 0x84(%rax)
je 0x76a06
leaq 0x58(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x78108
movl 0x4(%r15), %edx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x6f3a6
movq %r12, %rdi
leaq 0x26fc3(%rip), %rsi     # 0x9d990
leaq 0x58(%rsp), %rdx
leaq 0x18ead(%rip), %rcx     # 0x8f886
movq %rbp, %r8
callq 0x81a36
movq %r13, %rdi
movq %r12, %rsi
callq 0x64f0
movq %r12, %rdi
callq 0x6548
movq %rbp, %rdi
callq 0x6548
leaq 0x58(%rsp), %rdi
callq 0x6548
movq 0x50(%rsp), %rax
movq 0x20(%rax), %rax
addq $-0x14, %rax
cmpq %rax, %r15
je 0x76a27
movq %r13, %rdi
leaq 0x1e669(%rip), %rsi     # 0x9508b
callq 0x64d0
leaq 0x8(%rsp), %rdi
callq 0x6548
addq $0x14, %r15
jmp 0x768c2
leaq 0x1efb4(%rip), %rsi     # 0x959f5
leaq 0x28(%rsp), %rdi
callq 0x64d0
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0x9da6
leaq 0x28(%rsp), %rdi
callq 0x6548
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x76ad7
jmp 0x76abf
jmp 0x76ad7
jmp 0x76abf
jmp 0x76ad7
jmp 0x76abf
jmp 0x76ad7
jmp 0x76abf
jmp 0x76ad7
jmp 0x76abf
jmp 0x76abf
movq %rax, %rbx
jmp 0x76ab0
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x6548
jmp 0x76aa3
jmp 0x76ad7
movq %rax, %rbx
leaq 0x98(%rsp), %rdi
callq 0x6548
leaq 0x58(%rsp), %rdi
jmp 0x76ace
jmp 0x76abf
jmp 0x76ad7
jmp 0x76ad7
jmp 0x76ac6
movq %rax, %rbx
jmp 0x76ae4
jmp 0x76ad7
movq %rax, %rbx
leaq 0x78(%rsp), %rdi
callq 0x6548
jmp 0x76ada
jmp 0x76ad7
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x6548
leaq 0x28(%rsp), %rdi
callq 0x6548
movq %rbx, %rdi
callq 0x64b0