// File: /workspace/github_cpp_makefile_star2_O1/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 0x41842
movq %rdx, %r13
movq %rsi, %r12
addq $0x8, %rdi
callq 0x4438e
movq %rax, %rbp
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x4, %rax
movq 0x10(%rbp), %rdx
addq $0x8, %rbp
movq %rbp, %rcx
testq %rdx, %rdx
je 0x41692
movq %rbp, %rcx
xorl %esi, %esi
cmpq %rax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0x4167a
cmpq %rbp, %rcx
je 0x4169f
cmpq 0x20(%rcx), %rax
cmovaeq %rcx, %rbp
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x4438e
addq $0x8, %rax
cmpq %rax, %rbp
je 0x41780
movq %r12, 0x40(%rsp)
movq %r15, 0x30(%rsp)
movq %r14, 0x38(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq 0x40(%rbp), %r14
addq $0x30, %rbp
cmpq %rbp, %r14
je 0x4173b
xorl %r12d, %r12d
leaq 0x20(%r14), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x3f242
movq %rax, %r15
movb $0x1, %al
cmpq %r12, %r15
jbe 0x41727
movq 0x38(%r14), %rax
movq %rax, (%rsp)
leaq 0x40(%r14), %rsi
leaq 0x8(%rsp), %rdi
callq 0x37c6e
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x4, %rax
leaq (%rax,%rax,2), %rax
cmpq %rax, %r15
setne %al
movq %r15, %r12
testb %al, %al
je 0x4173b
movq %r14, %rdi
callq 0x102a0
movq %rax, %r14
cmpq %rbp, %rax
jne 0x416df
movq (%rsp), %rax
testq %rax, %rax
je 0x417ca
movq 0x30(%rsp), %r15
movq %rax, (%r15)
xorl %eax, %eax
movq %rax, 0x8(%r15)
movq 0x8(%rsp), %rcx
movq %rax, 0x8(%rsp)
movq %rcx, 0x8(%r15)
movq %rax, (%rsp)
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x41827
callq 0x1e6ee
jmp 0x41827
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x4438e
cmpq $0x0, 0x30(%rax)
je 0x418a6
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x4438e
movq 0x30(%rax), %rcx
movq %rcx, (%r15)
movq 0x38(%rax), %rax
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x41827
movq 0x757d0(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x41823
incl 0x8(%rax)
jmp 0x41827
movq 0x40(%rsp), %r14
movq (%r14), %rdi
addq $0x8, %rdi
callq 0x4438e
movq 0x30(%rsp), %r15
cmpq $0x0, 0x30(%rax)
je 0x41907
movq (%r14), %rdi
addq $0x8, %rdi
callq 0x4438e
movq 0x30(%rax), %rcx
movq %rcx, (%r15)
movq 0x38(%rax), %rax
movq %rax, 0x8(%r15)
testq %rax, %rax
je 0x41768
movq 0x7577a(%rip), %rcx     # 0xb6f90
cmpb $0x0, (%rcx)
je 0x41839
incl 0x8(%rax)
jmp 0x41768
lock
incl 0x8(%rax)
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
lock
incl 0x8(%rax)
jmp 0x41768
movq %r14, %r12
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x43f2c(%rip), %rsi     # 0x8578e
leaq 0x43f44(%rip), %rdx     # 0x857ad
leaq 0x10(%rsp), %rdi
callq 0x1e7ca
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x476dc
xorl %ebp, %ebp
leaq 0x7144e(%rip), %rsi     # 0xb2ce0
leaq -0xa0e5(%rip), %rdx     # 0x377b4
movq %r15, %rdi
callq 0x106d0
jmp 0x41965
movq %r14, %r12
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x43ee8(%rip), %rsi     # 0x857ae
leaq 0x43f18(%rip), %rdx     # 0x857e5
leaq 0x10(%rsp), %rdi
callq 0x1e7ca
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x476dc
xorl %ebp, %ebp
leaq 0x713ea(%rip), %rsi     # 0xb2ce0
leaq -0xa149(%rip), %rdx     # 0x377b4
movq %r15, %rdi
callq 0x106d0
jmp 0x41965
movl $0xa8, %edi
callq 0x101e0
movq %rax, %r15
leaq 0x20(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0x43ec2(%rip), %rsi     # 0x857e6
leaq 0x43ee7(%rip), %rdx     # 0x85812
leaq 0x10(%rsp), %rdi
callq 0x1e7ca
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r15, %rdi
movq 0x38(%rsp), %rdx
movq %rbx, %rcx
callq 0x476dc
xorl %ebp, %ebp
leaq 0x7138a(%rip), %rsi     # 0xb2ce0
leaq -0xa1a9(%rip), %rdx     # 0x377b4
movq %r15, %rdi
callq 0x106d0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x41987
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x41987
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x419d0
movq %r15, %rdi
callq 0x102d0
jmp 0x419d0
jmp 0x4199c
jmp 0x419b8
jmp 0x419cd
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r14, %rdi
je 0x419be
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x419be
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x419df
movq %r15, %rdi
callq 0x102d0
jmp 0x419df
movq %rax, %rbx
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x419df
callq 0x1e6ee
movq %rbx, %rdi
callq 0x106f0
nop