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

	// Avoid shadow declarations.
	local_variable_names = resource_names;

	string decl;

	auto &type = get<SPIRType>(func.return_type);
	decl += flags_to_precision_qualifiers_glsl(type, return_flags);
	decl += type_to_glsl(type);
	decl += type_to_array_glsl(type);
	decl += " ";

	if (func.self == ir.default_entry_point)
	{
		decl += "main";
		processing_entry_point = true;
	}
	else
		decl += to_name(func.self);

	decl += "(";
	vector<string> arglist;
	for (auto &arg : func.arguments)
	{
		// Do not pass in separate images or samplers if we're remapping
		// to combined image samplers.
		if (skip_argument(arg.id))
			continue;

		// 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);

		arglist.push_back(argument_decl(arg));

		// 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;
	}

	for (auto &arg : func.shadow_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);

		arglist.push_back(argument_decl(arg));

		// 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 += merge(arglist);
	decl += ")";
	statement(decl);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1b0, %rsp            # imm = 0x1B0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rcx
movq %rcx, -0x180(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x108(%rcx), %eax
je 0x97d71
movq -0x180(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x97940
movq -0x180(%rbp), %rdi
movq %rdi, %rsi
addq $0x488, %rsi            # imm = 0x488
addq $0x450, %rdi            # imm = 0x450
callq 0x11580
leaq -0x38(%rbp), %rdi
callq 0x7530
movq -0x180(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq %rax, -0x188(%rbp)
jmp 0x97db3
movq -0x180(%rbp), %rdi
movq -0x188(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x61830
movq %rax, -0x190(%rbp)
jmp 0x97ddb
movq -0x190(%rbp), %rsi
leaq -0x38(%rbp), %rdi
callq 0x7340
jmp 0x97ded
movq -0x180(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq (%rsi), %rax
movq 0x98(%rax), %rax
leaq -0x70(%rbp), %rdi
xorl %ecx, %ecx
callq *%rax
jmp 0x97e0c
leaq -0x38(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x7470
jmp 0x97e1b
leaq -0x70(%rbp), %rdi
callq 0x7708
movq -0x180(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x90(%rbp), %rdi
callq 0x61340
jmp 0x97e3d
leaq -0x38(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x7470
jmp 0x97e4f
leaq -0x90(%rbp), %rdi
callq 0x7708
leaq 0xa6a3b(%rip), %rsi     # 0x13e89d
leaq -0x38(%rbp), %rdi
callq 0x7340
jmp 0x97e6d
movq -0x180(%rbp), %rcx
movq -0x10(%rbp), %rax
movl 0x8(%rax), %eax
cmpl 0x108(%rcx), %eax
jne 0x97ef0
leaq 0xb01ba(%rip), %rsi     # 0x148044
leaq -0x38(%rbp), %rdi
callq 0x7340
jmp 0x97e95
movq -0x180(%rbp), %rax
movb $0x1, 0x5d8(%rax)
jmp 0x97f52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x982b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x7708
jmp 0x982b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x7708
jmp 0x982b8
movq -0x180(%rbp), %rsi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xb0(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x97f15
leaq -0x38(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x7470
jmp 0x97f27
leaq -0xb0(%rbp), %rdi
callq 0x7708
jmp 0x97f52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x7708
jmp 0x982b8
leaq 0xb53d4(%rip), %rsi     # 0x14d32d
leaq -0x38(%rbp), %rdi
callq 0x7340
jmp 0x97f64
leaq -0xc8(%rbp), %rdi
callq 0x30390
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x115b0
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rdi
callq 0x115e0
movq %rax, -0xe0(%rbp)
leaq -0xd8(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x11610
testb $0x1, %al
jne 0x97fc1
jmp 0x980eb
leaq -0xd8(%rbp), %rdi
callq 0x11650
movq -0x180(%rbp), %rdi
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
movl 0x4(%rax), %esi
movq (%rdi), %rax
movq 0x148(%rax), %rax
callq *%rax
movb %al, -0x191(%rbp)
jmp 0x97ff9
movb -0x191(%rbp), %al
testb $0x1, %al
jne 0x98005
jmp 0x9801b
jmp 0x980da
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
jmp 0x982ac
movq -0x180(%rbp), %rdi
movq -0xe8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x78460
jmp 0x98033
movq -0x180(%rbp), %rsi
movq -0xe8(%rbp), %rdx
leaq -0x108(%rbp), %rdi
callq 0x95e30
jmp 0x9804f
leaq -0xc8(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0xecd0
jmp 0x98064
leaq -0x108(%rbp), %rdi
callq 0x7708
movq -0x180(%rbp), %rdi
movq -0xe8(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x116b0
movq %rax, -0x1a0(%rbp)
jmp 0x9808f
movq -0x1a0(%rbp), %rax
movq %rax, -0x110(%rbp)
cmpq $0x0, -0x110(%rbp)
je 0x980d8
movq -0xe8(%rbp), %rcx
movq -0x110(%rbp), %rax
movq %rcx, 0x68(%rax)
jmp 0x980d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x7708
jmp 0x982ac
jmp 0x980da
leaq -0xd8(%rbp), %rdi
callq 0x11710
jmp 0x97fa5
movq -0x10(%rbp), %rax
addq $0x30, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rdi
callq 0x115b0
movq %rax, -0x120(%rbp)
movq -0x118(%rbp), %rdi
callq 0x115e0
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
leaq -0x128(%rbp), %rsi
callq 0x11610
testb $0x1, %al
jne 0x9813c
jmp 0x9821f
leaq -0x120(%rbp), %rdi
callq 0x11650
movq -0x180(%rbp), %rdi
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x78460
jmp 0x98167
movq -0x180(%rbp), %rsi
movq -0x130(%rbp), %rdx
leaq -0x150(%rbp), %rdi
callq 0x95e30
jmp 0x98183
leaq -0xc8(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0xecd0
jmp 0x98198
leaq -0x150(%rbp), %rdi
callq 0x7708
movq -0x180(%rbp), %rdi
movq -0x130(%rbp), %rax
movl 0x4(%rax), %esi
callq 0x116b0
movq %rax, -0x1a8(%rbp)
jmp 0x981c3
movq -0x1a8(%rbp), %rax
movq %rax, -0x158(%rbp)
cmpq $0x0, -0x158(%rbp)
je 0x9820c
movq -0x130(%rbp), %rcx
movq -0x158(%rbp), %rax
movq %rcx, 0x68(%rax)
jmp 0x9820c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x150(%rbp), %rdi
callq 0x7708
jmp 0x982ac
jmp 0x9820e
leaq -0x120(%rbp), %rdi
callq 0x11710
jmp 0x98120
leaq -0x178(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x9f2c0
jmp 0x98234
leaq -0x38(%rbp), %rdi
leaq -0x178(%rbp), %rsi
callq 0x7470
jmp 0x98246
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq 0xacca0(%rip), %rsi     # 0x144ef9
leaq -0x38(%rbp), %rdi
callq 0x7340
jmp 0x98264
movq -0x180(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x10200
jmp 0x98276
leaq -0xc8(%rbp), %rdi
callq 0x14cd0
leaq -0x38(%rbp), %rdi
callq 0x7708
addq $0x1b0, %rsp            # imm = 0x1B0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x48(%rbp)
movl %eax, -0x4c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq -0xc8(%rbp), %rdi
callq 0x14cd0
leaq -0x38(%rbp), %rdi
callq 0x7708
movq -0x48(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)