// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::add_function_overload(spirv_cross::SPIRFunction const&)
void CompilerGLSL::add_function_overload(const SPIRFunction &func)
{
	Hasher hasher;
	for (auto &arg : func.arguments)
	{
		// Parameters can vary with pointer type or not,
		// but that will not change the signature in GLSL/HLSL,
		// so strip the pointer type before hashing.
		uint32_t type_id = get_non_pointer_type_id(arg.type);
		auto &type = get<SPIRType>(type_id);

		if (!combined_image_samplers.empty())
		{
			// If we have combined image samplers, we cannot really trust the image and sampler arguments
			// we pass down to callees, because they may be shuffled around.
			// Ignore these arguments, to make sure that functions need to differ in some other way
			// to be considered different overloads.
			if (type.basetype == SPIRType::SampledImage ||
			    (type.basetype == SPIRType::Image && type.image.sampled == 1) || type.basetype == SPIRType::Sampler)
			{
				continue;
			}
		}

		hasher.u32(type_id);
	}
	uint64_t types_hash = hasher.get();

	auto function_name = to_name(func.self);
	auto itr = function_overloads.find(function_name);
	if (itr != end(function_overloads))
	{
		// There exists a function with this name already.
		auto &overloads = itr->second;
		if (overloads.count(types_hash) != 0)
		{
			// Overload conflict, assign a new name.
			add_resource_name(func.self);
			function_overloads[to_name(func.self)].insert(types_hash);
		}
		else
		{
			// Can reuse the name.
			overloads.insert(types_hash);
		}
	}
	else
	{
		// First time we see this function name.
		add_resource_name(func.self);
		function_overloads[to_name(func.self)].insert(types_hash);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x110(%rbp)
leaq -0x18(%rbp), %rdi
callq 0xa7b90
movq -0x10(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa7bb0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0xa7be0
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa7c10
testb $0x1, %al
jne 0x979a3
jmp 0x97a38
leaq -0x28(%rbp), %rdi
callq 0xa7c50
movq -0x110(%rbp), %rdi
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl (%rax), %esi
callq 0x22d70
movq -0x110(%rbp), %rdi
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %esi
callq 0xea90
movq -0x110(%rbp), %rdi
movq %rax, -0x48(%rbp)
addq $0x1d8, %rdi            # imm = 0x1D8
callq 0xa10a0
testb $0x1, %al
jne 0x97a1e
movq -0x48(%rbp), %rax
cmpl $0xe, 0xc(%rax)
je 0x97a1a
movq -0x48(%rbp), %rax
cmpl $0xd, 0xc(%rax)
jne 0x97a10
movq -0x48(%rbp), %rax
cmpl $0x1, 0x8c(%rax)
je 0x97a1a
movq -0x48(%rbp), %rax
cmpl $0xf, 0xc(%rax)
jne 0x97a1c
jmp 0x97a2a
jmp 0x97a1e
movl -0x3c(%rbp), %esi
leaq -0x18(%rbp), %rdi
callq 0xa7c70
leaq -0x28(%rbp), %rdi
callq 0xa7ca0
jmp 0x9798d
leaq -0x18(%rbp), %rdi
callq 0xa7cc0
movq -0x110(%rbp), %rsi
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0x70(%rbp), %rdi
movq %rdi, -0x120(%rbp)
movl $0x1, %ecx
callq *%rax
movq -0x110(%rbp), %rdi
movq -0x120(%rbp), %rsi
addq $0x5a0, %rdi            # imm = 0x5A0
callq 0xa7ce0
movq %rax, -0x118(%rbp)
jmp 0x97a8f
movq -0x110(%rbp), %rdi
movq -0x118(%rbp), %rax
movq %rax, -0x78(%rbp)
addq $0x5a0, %rdi            # imm = 0x5A0
callq 0xa7d40
movq %rax, -0x128(%rbp)
jmp 0x97ab6
movq -0x128(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0xa7d10
testb $0x1, %al
jne 0x97add
jmp 0x97c3a
leaq -0x78(%rbp), %rdi
callq 0xa7d70
addq $0x20, %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa7da0
movq %rax, -0x130(%rbp)
jmp 0x97b0a
movq -0x130(%rbp), %rax
cmpq $0x0, %rax
je 0x97bfc
movq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
jmp 0x97b30
movq -0x110(%rbp), %rsi
movq %rsi, %rax
addq $0x5a0, %rax            # imm = 0x5A0
movq %rax, -0x138(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xb8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x97b65
movq -0x138(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0xa7dd0
movq %rax, -0x140(%rbp)
jmp 0x97b81
movq -0x140(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa7e00
movb %dl, -0x149(%rbp)
movq %rax, -0x148(%rbp)
jmp 0x97ba0
movb -0x149(%rbp), %al
movq -0x148(%rbp), %rcx
movq %rcx, -0xc8(%rbp)
movb %al, -0xc0(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0x97c35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
jmp 0x97d16
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xb8(%rbp), %rdi
callq 0x7708
jmp 0x97d16
movq -0x98(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa7e00
movb %dl, -0x159(%rbp)
movq %rax, -0x158(%rbp)
jmp 0x97c1b
movb -0x159(%rbp), %al
movq -0x158(%rbp), %rcx
movq %rcx, -0xd8(%rbp)
movb %al, -0xd0(%rbp)
jmp 0x97d04
movq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
callq 0x5c1d0
jmp 0x97c4f
movq -0x110(%rbp), %rsi
movq %rsi, %rax
addq $0x5a0, %rax            # imm = 0x5A0
movq %rax, -0x168(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xf8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
jmp 0x97c84
movq -0x168(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0xa7dd0
movq %rax, -0x170(%rbp)
jmp 0x97ca0
movq -0x170(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa7e00
movb %dl, -0x179(%rbp)
movq %rax, -0x178(%rbp)
jmp 0x97cbf
movb -0x179(%rbp), %al
movq -0x178(%rbp), %rcx
movq %rcx, -0x108(%rbp)
movb %al, -0x100(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x7708
jmp 0x97d04
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x80(%rbp)
movl %eax, -0x84(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x7708
jmp 0x97d16
leaq -0x70(%rbp), %rdi
callq 0x7708
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0x7708
movq -0x80(%rbp), %rdi
callq 0x7640
nopl (%rax,%rax)