// File: /workspace/github_cpp_makefile_star2_O1/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 0x93b69
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4d5f8
leaq 0x488(%rbx), %rsi
leaq 0x450(%rbx), %rdi
callq 0xd5d6
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 0xa426
movq %rax, %r15
movq 0x20(%rax), %rax
cmpq 0x28(%r15), %rax
je 0x93bdc
leaq 0x28(%rsp), %rdi
movq 0x8(%rdi), %rdx
leaq 0x25134(%rip), %rcx     # 0xb8d01
movl $0x4, %r8d
xorl %esi, %esi
callq 0x63f0
jmp 0x93c1b
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x9420c
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 0x93c1b
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x21c8c(%rip), %rsi     # 0xb58ae
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 0x93c73
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x30027(%rip), %rsi     # 0xc3ca1
leaq 0x28(%rsp), %rdi
callq 0x64e0
movq 0x20(%r15), %rax
cmpq 0x28(%r15), %rax
je 0x93d57
leaq 0x2fd47(%rip), %rsi     # 0xc39e0
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 0x93ce9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
leaq 0x2fcf8(%rip), %rsi     # 0xc39e8
leaq 0x28(%rsp), %rdi
callq 0x64e0
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x2bb66
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 0x93d3a
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x18(%r12), %rax
cmpq 0x20(%r12), %rax
je 0x93d57
leaq 0x2736e(%rip), %rsi     # 0xbb0bb
leaq 0x28(%rsp), %rdi
callq 0x64e0
movq %r12, 0x70(%rsp)
cmpb $0x1, 0x5d8(%rbx)
jne 0x93e2c
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 0x94724
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 0x93db8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x8e0(%rbx), %r14
movq 0x8e8(%rbx), %r15
cmpq %r15, %r14
je 0x93e2c
leaq 0x8(%rbx), %rax
movq %rax, 0x68(%rsp)
leaq 0x2fc2a(%rip), %r12     # 0xc3a05
leaq 0x8(%rsp), %r13
movl (%r14), %esi
movq %rbx, %rdi
callq 0xb40a
movq %rax, %rbp
cmpl $0x0, 0x18(%rax)
jne 0x93e06
movq 0x68(%rsp), %rdi
movl $0x1, %esi
callq 0x2561c
movl %eax, 0x18(%rbp)
movl 0x18(%rbp), %esi
addq $0xc, %rbp
movb $0x1, 0x8(%rsp)
movq %rbx, %rdi
movq %r12, %rdx
movq %rbp, %rcx
movq %r13, %r8
callq 0xa6d36
addq $0x4, %r14
cmpq %r15, %r14
jne 0x93de0
movq 0x70(%rsp), %rax
movq 0x18(%rax), %r15
movq 0x20(%rax), %rax
movq %rax, 0x68(%rsp)
cmpq %rax, %r15
je 0x94087
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 0xc7f4
testq %rax, %rax
je 0x93ec4
cmpb $0x1, 0x10(%r15)
jne 0x93e8e
movl 0x1c(%rax), %ecx
testl %ecx, %ecx
je 0x93e8e
movl %ecx, %ebp
movq %r15, 0x68(%rax)
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x8a250
leaq 0x8(%rsp), %rdi
movq %r12, %rsi
callq 0x6310
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93ec4
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
movl %ebp, %esi
callq 0x39b62
movq 0x10(%rsp), %rdx
testq %rdx, %rdx
movq 0x70(%rsp), %rbp
je 0x93f2c
movq %r14, 0x48(%rsp)
movq 0x8(%rsp), %rsi
addq %rsi, %rdx
movq %r12, %rdi
callq 0xe480
movq %r12, %rdi
leaq 0x219b2(%rip), %rsi     # 0xb58ae
callq 0x64e0
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93f2c
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x96c02
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93f65
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movl (%r15), %esi
movq %rbx, %rdi
callq 0xa426
cmpl $0xe, 0xc(%rax)
jne 0x9403e
cmpl $0x5, 0x84(%rax)
je 0x9403e
leaq 0x78(%rsp), %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x96f94
movl 0x4(%r15), %edx
leaq 0x98(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x89ff8
movq %r12, %rdi
leaq 0x2fa50(%rip), %rsi     # 0xc3a08
leaq 0x78(%rsp), %rdx
leaq 0x218ea(%rip), %rcx     # 0xb58ae
movq %r13, %r8
callq 0xa6d7d
movq 0x48(%rsp), %rsi
movq 0x50(%rsp), %rdx
leaq 0x28(%rsp), %rdi
callq 0x60b0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x93ff7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x9401c
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x9403e
movq 0x88(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x20(%rbp), %rax
addq $-0x14, %rax
cmpq %rax, %r15
je 0x9405c
leaq 0x28(%rsp), %rdi
leaq 0x27064(%rip), %rsi     # 0xbb0bb
callq 0x64e0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x94078
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
addq $0x14, %r15
cmpq 0x68(%rsp), %r15
jne 0x93e51
leaq 0x27997(%rip), %rsi     # 0xbba25
leaq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %r14
callq 0x64e0
leaq 0x28(%rsp), %rsi
movq %rbx, %rdi
callq 0xb674
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x940c1
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 0x94112
jmp 0x94125
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x941a1
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x941a1
jmp 0x9419e
jmp 0x94108
jmp 0x94125
movq %rax, %rbx
jmp 0x941d0
jmp 0x94125
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x941da
jmp 0x94125
movq %rax, %rbx
jmp 0x941ec
movq %rax, %rbx
jmp 0x94178
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x94153
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x94153
jmp 0x941c8
movq %rax, %rbx
movq 0x98(%rsp), %rdi
leaq 0xa8(%rsp), %rax
cmpq %rax, %rdi
je 0x94178
movq 0xa8(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x78(%rsp), %rdi
leaq 0x88(%rsp), %rax
cmpq %rax, %rdi
je 0x941cb
movq 0x88(%rsp), %rsi
jmp 0x941bc
jmp 0x9419e
jmp 0x941c8
jmp 0x941aa
jmp 0x941c8
jmp 0x941aa
movq %rax, %rbx
leaq 0x38(%rsp), %r14
jmp 0x941ec
jmp 0x941c8
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0x941cb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x941cb
jmp 0x941c8
movq %rax, %rbx
leaq 0x38(%rsp), %r14
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x941ec
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6260
movq 0x28(%rsp), %rdi
cmpq %r14, %rdi
je 0x94203
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6260
movq %rbx, %rdi
callq 0x64a0
nop