// File: /workspace/github_cpp_makefile_star2_O2/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 $0x58, %rsp
movq %r8, %rbx
movq %rcx, %r14
movq %rdi, %r15
movq (%rsi), %rdi
cmpl $-0x6, (%rdi)
jne 0x3a145
movq %rdx, %r13
movq %rsi, %r12
addq $0x8, %rdi
callq 0x3bd79
movq 0x8(%r13), %rcx
subq (%r13), %rcx
sarq $0x4, %rcx
leaq 0x28(%rsp), %rsi
movq %rcx, (%rsi)
movq %rax, %rdi
callq 0x38c42
movq %rax, %rbp
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x3bd79
addq $0x8, %rax
cmpq %rax, %rbp
je 0x3a0ba
movq %r12, 0x50(%rsp)
movq %r15, 0x20(%rsp)
movq %r14, 0x48(%rsp)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rax
movaps %xmm0, (%rax)
movq 0x40(%rbp), %r15
addq $0x30, %rbp
xorl %r14d, %r14d
cmpq %rbp, %r15
je 0x3a091
leaq 0x20(%r15), %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x380ba
movq %rax, %r12
cmpq %r14, %rax
jbe 0x3a084
leaq 0x38(%r15), %rsi
leaq 0x10(%rsp), %rdi
callq 0x3bd96
movq 0x8(%r13), %rax
subq (%r13), %rax
sarq $0x4, %rax
leaq (%rax,%rax,2), %rax
movq %r12, %r14
cmpq %rax, %r12
je 0x3a091
movq %r15, %rdi
callq 0x102b0
movq %rax, %r15
jmp 0x3a042
movq 0x10(%rsp), %rax
testq %rax, %rax
je 0x3a0ed
movq 0x20(%rsp), %r15
movq %rax, (%r15)
movq 0x18(%rsp), %rax
andq $0x0, 0x18(%rsp)
movq %rax, 0x8(%r15)
andq $0x0, 0x10(%rsp)
jmp 0x3a129
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x3bd79
cmpq $0x0, 0x30(%rax)
je 0x3a19b
movq (%r12), %rdi
addq $0x8, %rdi
callq 0x3bd79
leaq 0x30(%rax), %rsi
movq %r15, %rdi
callq 0x38c1a
jmp 0x3a133
movq 0x50(%rsp), %r14
movq (%r14), %rdi
addq $0x8, %rdi
callq 0x3bd79
movq 0x20(%rsp), %r15
cmpq $0x0, 0x30(%rax)
je 0x3a1ee
movq (%r14), %rdi
addq $0x8, %rdi
callq 0x3bd79
addq $0x30, %rax
movq %r15, %rdi
movq %rax, %rsi
callq 0x38c1a
leaq 0x18(%rsp), %rdi
callq 0x1d786
movq %r15, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r15
leaq 0x3d681(%rip), %rsi     # 0x777da
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1c814
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x77b19(%rip), %rsi     # 0xb1ca0
leaq -0xad1c(%rip), %rdx     # 0x2f472
movq %r15, %rdi
callq 0x106c0
jmp 0x3a241
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r15
leaq 0x3d64b(%rip), %rsi     # 0x777fa
leaq 0x28(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x1c814
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x77ac3(%rip), %rsi     # 0xb1ca0
leaq -0xad72(%rip), %rdx     # 0x2f472
movq %r15, %rdi
callq 0x106c0
jmp 0x3a241
movl $0xa8, %edi
callq 0x101f0
movq %rax, %r15
leaq 0x3d630(%rip), %rsi     # 0x77832
leaq 0x28(%rsp), %rdi
leaq 0xf(%rsp), %rdx
callq 0x1c814
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
movq %r15, %rdi
movq 0x48(%rsp), %rdx
movq %rbx, %rcx
callq 0x3ebb8
xorl %ebp, %ebp
leaq 0x77a6e(%rip), %rsi     # 0xb1ca0
leaq -0xadc7(%rip), %rdx     # 0x2f472
movq %r15, %rdi
callq 0x106c0
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x101d0
testb %bpl, %bpl
jne 0x3a258
jmp 0x3a28c
movq %rax, %rbx
movq %r15, %rdi
callq 0x102e0
jmp 0x3a28c
jmp 0x3a268
jmp 0x3a27c
jmp 0x3a289
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x101d0
testb %bpl, %bpl
jne 0x3a27f
jmp 0x3a296
movq %rax, %rbx
movq %r15, %rdi
callq 0x102e0
jmp 0x3a296
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x1d786
movq %rbx, %rdi
callq 0x106f0