// File: /workspace/github_cpp_makefile_star2_O3/Nallantli[P]Rossa/main/rossa/symbol/symbol.cpp
// Function: symbol_t::getFunction(std::vector<symbol_t, std::allocator<symbol_t>> const&, token_t const*, std::vector<std::pair<token_t, function_t>, std::allocator<std::pair<token_t, function_t>>>&) const
const ptr_function_t symbol_t::getFunction(const std::vector<symbol_t> &params, const token_t *token, trace_t &stack_trace) const
{
	if (d->type != value_type_enum::FUNCTION)
	{
		throw rossa_error_t(_NOT_FUNCTION_, *token, stack_trace);
	}

	const auto it = std::get<wrapper_t>(d->value).map.find(params.size());
	if (it == std::get<wrapper_t>(d->value).map.end())
	{
		if (std::get<wrapper_t>(d->value).varg != nullptr)
		{
			return std::get<wrapper_t>(d->value).varg;
		}
		throw rossa_error_t(_FUNCTION_ARG_SIZE_FAILURE_, *token, stack_trace);
	}

	ptr_function_t f = nullptr;
	size_t cur_v = 0;
	for (auto &f2 : it->second)
	{
		size_t v = f2.first.validity(params, stack_trace);
		if (v > cur_v)
		{
			cur_v = v;
			f = f2.second;
			if (v == params.size() * 3)
			{
				break;
			}
		}
	}

	if (f == nullptr)
	{
		if (std::get<wrapper_t>(d->value).varg != nullptr)
		{
			return std::get<wrapper_t>(d->value).varg;
		}
		throw rossa_error_t(_FUNCTION_VALUE_NOT_EXIST_, *token, stack_trace);
	}

	return f;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdi, %r15
movq (%rsi), %rdi
cmpl $-0x6, (%rdi)
jne 0x41111
movq %rdx, %r13
movq %rsi, %r12
addq $0x8, %rdi
callq 0x43bfe
movq %rax, %rbp
movq 0x10(%rax), %rax
addq $0x8, %rbp
testq %rax, %rax
je 0x40f8a
movq 0x8(%r13), %rcx
subq (%r13), %rcx
sarq $0x4, %rcx
movq %rbp, %rdx
xorl %esi, %esi
cmpq %rcx, 0x20(%rax)
setb %sil
cmovaeq %rax, %rdx
movq 0x10(%rax,%rsi,8), %rax
testq %rax, %rax
jne 0x40f65
cmpq %rbp, %rdx
je 0x40f8a
cmpq 0x20(%rdx), %rcx
cmovaeq %rdx, %rbp
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x43bfe
addq $0x8, %rax
cmpq %rax, %rbp
je 0x4109c
movq %r14, 0x30(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq 0x40(%rbp), %r14
addq $0x30, %rbp
cmpq %rbp, %r14
je 0x41052
movq %r12, 0x38(%rsp)
movq %r15, 0x40(%rsp)
xorl %r15d, %r15d
leaq 0x20(%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3eb8a
movq %rax, %r12
cmpq %r15, %rax
jbe 0x41013
movq 0x38(%r14), %rax
movq %rax, (%rsp)
leaq 0x40(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x3775e
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x4, %rax
leaq (%rax,%rax,2), %rax
movq %r12, %r15
cmpq %rax, %r12
je 0x41023
movq %r14, %rdi
callq 0x102a0
movq %rax, %r14
cmpq %rbp, %rax
jne 0x40fce
movq (%rsp), %rax
testq %rax, %rax
movq 0x40(%rsp), %r15
movq 0x38(%rsp), %r12
je 0x41052
movq %rax, (%r15)
movq 0x8(%rsp), %rax
xorl %ecx, %ecx
movq %rcx, 0x8(%rsp)
movq %rax, 0x8(%r15)
movq %rcx, (%rsp)
jmp 0x410ea
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x43bfe
cmpq $0x0, 0x30(%rax)
je 0x41175
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x43bfe
movq 0x30(%rax), %rcx
movq %rcx, (%r15)
movq 0x38(%rax), %rax
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x410ea
movq 0x73efe(%rip), %rcx     # 0xb4f90
cmpb $0x0, (%rcx)
je 0x410e6
incl 0x8(%rax)
jmp 0x410ea
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x43bfe
cmpq $0x0, 0x30(%rax)
je 0x411d5
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x43bfe
movq 0x30(%rax), %rcx
movq %rcx, (%r15)
movq 0x38(%rax), %rax
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x410f9
movq 0x73eb4(%rip), %rcx     # 0xb4f90
cmpb $0x0, (%rcx)
je 0x4110b
incl 0x8(%rax)
jmp 0x410f9
lock
incl 0x8(%rax)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x410f9
callq 0x1e5bc
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%rax)
jmp 0x410f9
movq %r14, %r12
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x4367d(%rip), %rsi     # 0x847ae
leaq 0x43695(%rip), %rdx     # 0x847cd
leaq 0x10(%rsp), %rdi
callq 0x1e698
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x46e88
xorl %ebp, %ebp
leaq 0x6fbbf(%rip), %rsi     # 0xb0d20
leaq -0x9ec4(%rip), %rdx     # 0x372a4
movq %r15, %rdi
callq 0x106d0
jmp 0x41234
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x43674(%rip), %rsi     # 0x84806
leaq 0x43699(%rip), %rdx     # 0x84832
leaq 0x10(%rsp), %rdi
callq 0x1e698
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq 0x46e88
xorl %ebp, %ebp
leaq 0x6fb5c(%rip), %rsi     # 0xb0d20
leaq -0x9f27(%rip), %rdx     # 0x372a4
movq %r15, %rdi
callq 0x106d0
jmp 0x41234
movq %r14, %r12
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x435d9(%rip), %rsi     # 0x847ce
leaq 0x43609(%rip), %rdx     # 0x84805
leaq 0x10(%rsp), %rdi
callq 0x1e698
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x46e88
xorl %ebp, %ebp
leaq 0x6fafb(%rip), %rsi     # 0xb0d20
leaq -0x9f88(%rip), %rdx     # 0x372a4
movq %r15, %rdi
callq 0x106d0
jmp 0x41266
jmp 0x41287
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x41252
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
testb %bpl, %bpl
jne 0x4125c
jmp 0x41299
movq %rax, %rbx
movq %r15, %rdi
callq 0x102d0
jmp 0x41299
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x41280
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
testb %bpl, %bpl
jne 0x4128a
jmp 0x412a8
movq %rax, %rbx
movq %r15, %rdi
callq 0x102d0
jmp 0x412a8
jmp 0x41296
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x412a8
callq 0x1e5bc
movq %rbx, %rdi
callq 0x106f0