// File: /workspace/github_cpp_makefile_star2_O3/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, %r12
movq %rdi, %rbx
movl 0x8(%rsi), %eax
cmpl 0x108(%rdi), %eax
je 0x92f49
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4ce5a
leaq 0x488(%rbx), %rsi
leaq 0x450(%rbx), %rdi
callq 0xd596
leaq 0x38(%rsp), %r14
movq %r14, -0x10(%r14)
movq $0x0, -0x8(%r14)
movb $0x0, (%r14)
movl 0x8(%r12), %eax
cmpl 0x108(%rbx), %eax
sete 0x5d8(%rbx)
movl 0xc(%r12), %esi
movq %rbx, %rdi
callq 0xa3ea
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq 0x28(%r15), %rax
je 0x92fbc
leaq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x24d44(%rip), %rcx     # 0xb7cf1
movl $0x4, %r8d
xorl %esi, %esi
callq 0x63f0
jmp 0x92ffb
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x935ec
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x92ffb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x218ac(%rip), %rsi     # 0xb48ae
leaq 0x28(%rsp), %rdi
callq 0x64e0
movl 0x8(%r12), %edx
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movl $0x1, %ecx
callq *0x38(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x93053
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x2fc17(%rip), %rsi     # 0xc2c71
leaq 0x28(%rsp), %rdi
callq 0x64e0
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
je 0x93137
leaq 0x2f937(%rip), %rsi     # 0xc29b0
leaq 0x28(%rsp), %rdi
callq 0x64e0
movq (%rbx), %rax
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq *0x98(%rax)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x930c9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x2f8e8(%rip), %rsi     # 0xc29b8
leaq 0x28(%rsp), %rdi
callq 0x64e0
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2b55a
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x9311a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x18(%r12), %rax
cmpq 0x20(%r12), %rax
je 0x93137
leaq 0x26f7e(%rip), %rsi     # 0xba0ab
leaq 0x28(%rsp), %rdi
callq 0x64e0
movq %r12, 0x70(%rsp)
cmpb $0x1, 0x5d8(%rbx)
jne 0x9320c
movq 0x70(%rsp), %rcx
movq 0x18(%rcx), %rax
xorl %edx, %edx
cmpq 0x20(%rcx), %rax
setne %dl
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x93af0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x93198
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8e0(%rbx), %r14
movq 0x8e8(%rbx), %r15
cmpq %r15, %r14
je 0x9320c
leaq 0x8(%rbx), %rax
movq %rax, 0x68(%rsp)
leaq 0x2f81a(%rip), %r12     # 0xc29d5
leaq 0x8(%rsp), %r13
movl (%r14), %esi
movq %rbx, %rdi
callq 0xb3ca
movq %rax, %rbp
movl 0x18(%rax), %eax
testl %eax, %eax
jne 0x931e7
movq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x24f8a
movl %eax, 0x18(%rbp)
addq $0xc, %rbp
movb $0x1, 0x8(%rsp)
movq %rbx, %rdi
movl %eax, %esi
movq %r12, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0xa5e2a
addq $0x4, %r14
cmpq %r15, %r14
jne 0x931c0
movq 0x70(%rsp), %rax
movq 0x18(%rax), %r15
movq 0x20(%rax), %rax
movq %rax, 0x68(%rsp)
cmpq %rax, %r15
je 0x93467
leaq 0x58(%rsp), %r14
leaq 0x48(%rsp), %r12
movl 0x4(%r15), %ebp
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
movl 0x4(%r15), %esi
movq %rbx, %rdi
callq 0xc7b4
testq %rax, %rax
je 0x932a4
cmpb $0x1, 0x10(%r15)
jne 0x9326e
movl 0x1c(%rax), %ecx
testl %ecx, %ecx
je 0x9326e
movl %ecx, %ebp
movq %r15, 0x68(%rax)
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x8960a
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x6310
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x932a4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
movl %ebp, %esi
callq 0x393f2
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
movq 0x70(%rsp), %rbp
je 0x9330c
movq %r14, 0x48(%rsp)
movq 0x8(%rsp), %rsi
addq %rsi, %rdx
movq %r12, %rdi
callq 0xe456
movq %r12, %rdi
leaq 0x215d2(%rip), %rsi     # 0xb48ae
callq 0x64e0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x9330c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x95f86
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93345
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movl (%r15), %esi
movq %rbx, %rdi
callq 0xa3ea
cmpl $0xe, 0xc(%rax)
jne 0x9341e
cmpl $0x5, 0x84(%rax)
je 0x9341e
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x9636a
movl 0x4(%r15), %edx
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x893aa
movq %r12, %rdi
leaq 0x2f640(%rip), %rsi     # 0xc29d8
leaq 0x78(%rsp), %rdx
leaq 0x2150a(%rip), %rcx     # 0xb48ae
movq %r13, %r8
callq 0xa5e71
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x933d7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x933fc
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x9341e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x20(%rbp), %rax
addq $-0x14, %rax
cmpq %rax, %r15
je 0x9343c
leaq 0x28(%rsp), %rdi
leaq 0x26c74(%rip), %rsi     # 0xba0ab
callq 0x64e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x93458
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x14, %r15
cmpq 0x68(%rsp), %r15
jne 0x93231
leaq 0x275a7(%rip), %rsi     # 0xbaa15
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %r14
callq 0x64e0
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xb634
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x934a1
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x934f2
jmp 0x93505
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x93581
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x93581
jmp 0x9357e
jmp 0x934e8
jmp 0x93505
movq %rax, %rbx
jmp 0x935b0
jmp 0x93505
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x935ba
jmp 0x93505
movq %rax, %rbx
jmp 0x935cc
movq %rax, %rbx
jmp 0x93558
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93533
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x93533
jmp 0x935a8
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x93558
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x935ab
movq 0x88(%rsp), %rsi
jmp 0x9359c
jmp 0x9357e
jmp 0x935a8
jmp 0x9358a
jmp 0x935a8
jmp 0x9358a
movq %rax, %rbx
leaq 0x38(%rsp), %r14
jmp 0x935cc
jmp 0x935a8
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x935ab
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x935ab
jmp 0x935a8
movq %rax, %rbx
leaq 0x38(%rsp), %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x935cc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x935e3
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop