// File: /workspace/github_cpp_makefile_star2_O1/Nallantli[P]Rossa/main/rossa/function/function.cpp
// Function: function_evaluate(std::shared_ptr<function_t> const&, 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 symbol_t function_evaluate(const ptr_function_t &function, const std::vector<symbol_t> &paramValues, const token_t *token, trace_t &stack_trace)
{
	stack_trace.push_back({(token == NULL ? token_t() : *token), *function.get()});
	if (function->isVargs)
		return function_evaluate_vargs(function, paramValues, token, stack_trace);

	object_t p(function->parent, object_type_enum::OBJECT_WEAK);
	const object_t newScope(&p, 0);

	for (size_t i = 0; i < function->params.size(); i++)
	{
		if (function->params[i].first) {
			newScope.createVariable(function->params[i].second, paramValues[i], token);
		} else {
			const symbol_t &temp = newScope.createVariable(function->params[i].second, token);
			temp.set(&paramValues[i], token, stack_trace);
		}
	}

	for (const std::pair<const hash_ull, const symbol_t> &e : function->captures)
	{
		newScope.createVariable(e.first, e.second, token);
	}

	symbol_t temp = function->body->evaluate(&newScope, stack_trace);

	if (temp.getSymbolType() == symbol_t::type_t::ID_REFER)
	{
		temp.setSymbolType(symbol_t::type_t::ID_CASUAL);

		stack_trace.pop_back();
		return temp;
	}

	const symbol_t ret = symbol_t();
	ret.set(&temp, token, stack_trace);

	stack_trace.pop_back();
	return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %rbp
movq %rdi, %r12
leaq 0x68(%rsp), %rbx
testq %rcx, %rcx
je 0x24aef
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x1e698
leaq 0x58(%rsp), %rdi
movq %rbx, (%rdi)
movq 0x28(%r15), %rsi
movq 0x30(%r15), %rdx
addq %rsi, %rdx
callq 0x1e014
movups 0x48(%r15), %xmm0
leaq 0x88(%rsp), %rdi
movups %xmm0, -0x10(%rdi)
leaq 0x98(%rsp), %rax
movq %rax, -0x10(%rax)
movq 0x58(%r15), %rsi
movq 0x60(%r15), %rdx
addq %rsi, %rdx
callq 0x1e014
movl 0x78(%r15), %eax
movl %eax, 0xa8(%rsp)
jmp 0x24b55
xorps %xmm0, %xmm0
movq %rbp, %rbx
leaq 0x30(%rsp), %rbp
movaps %xmm0, 0x70(%rbp)
movaps %xmm0, 0x60(%rbp)
movaps %xmm0, 0x50(%rbp)
movaps %xmm0, 0x40(%rbp)
movaps %xmm0, 0x30(%rbp)
movaps %xmm0, 0x20(%rbp)
movaps %xmm0, 0x10(%rbp)
movaps %xmm0, (%rbp)
movq %rbp, %rdi
callq 0x251b8
leaq 0x68(%rsp), %rax
movq %rax, 0x28(%rbp)
xorl %eax, %eax
movq %rax, 0x30(%rbp)
movb %al, 0x38(%rbp)
movq %rbx, %rbp
leaq 0x68(%rsp), %rbx
leaq 0x98(%rsp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movl $0x0, 0x10(%rcx)
movq (%rbp), %rdx
leaq 0xb8(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x25066
leaq 0xb8(%rsp), %rsi
movq %r14, %rdi
callq 0x251e0
leaq 0xb8(%rsp), %rdi
callq 0x1ecd8
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x24ba9
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x103d0
movq 0x58(%rsp), %rdi
cmpq %rbx, %rdi
je 0x24bc0
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x103d0
leaq 0x30(%rsp), %rdi
callq 0x1d736
movq (%rbp), %rax
cmpb $0x1, 0x78(%rax)
jne 0x24bed
movq %r12, %rdi
movq %rbp, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x24e58
jmp 0x24dac
movq %rbp, (%rsp)
movq %r14, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movq 0x18(%rax), %rsi
leaq 0x30(%rsp), %rdx
movl $0x0, (%rdx)
leaq 0xb8(%rsp), %rbp
movq %rbp, %rdi
callq 0x3cee4
leaq 0x8(%rsp), %rdx
movq $0x0, (%rdx)
leaq 0x30(%rsp), %rdi
movq %rbp, %rsi
callq 0x3cf90
movq (%rsp), %rax
movq (%rax), %r12
movq 0x20(%r12), %rax
cmpq %rax, 0x28(%r12)
je 0x24cb8
xorl %ebx, %ebx
leaq 0x30(%rsp), %rbp
xorl %r14d, %r14d
leaq (%rax,%rbx), %rsi
addq $0x8, %rsi
cmpb $0x1, -0x8(%rsi)
jne 0x24c72
movq (%r13), %rdx
addq %rbx, %rdx
movq %rbp, %rdi
movq %r15, %rcx
callq 0x3d512
jmp 0x24c94
movq %rbp, %rdi
movq %r15, %rdx
callq 0x3d50a
movq (%r13), %rsi
addq %rbx, %rsi
movq %rax, %rdi
movq %r15, %rdx
movq 0x18(%rsp), %rcx
callq 0x40674
incq %r14
movq (%rsp), %rax
movq (%rax), %r12
movq 0x20(%r12), %rax
movq 0x28(%r12), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
addq $0x10, %rbx
cmpq %rcx, %r14
jb 0x24c50
movq 0x60(%r12), %r13
addq $0x50, %r12
cmpq %r12, %r13
movq 0x18(%rsp), %rbx
je 0x24cf3
leaq 0x30(%rsp), %rbp
leaq 0x20(%r13), %rsi
leaq 0x28(%r13), %rdx
movq %rbp, %rdi
movq %r15, %rcx
callq 0x3d512
movq %r13, %rdi
callq 0x104b0
movq %rax, %r13
cmpq %r12, %rax
jne 0x24cd0
movq (%rsp), %rax
movq (%rax), %rax
movq 0x38(%rax), %rsi
movq (%rsi), %rax
leaq 0x8(%rsp), %rdi
leaq 0x30(%rsp), %rdx
movq %rbx, %rcx
callq *(%rax)
leaq 0x8(%rsp), %rdi
callq 0x40b02
movq 0x20(%rsp), %r12
cmpl $0x4, %eax
jne 0x24d5c
leaq 0x2c(%rsp), %rsi
movl $0x3, (%rsi)
leaq 0x8(%rsp), %rdi
callq 0x40b06
movq $-0x100, %rdi
addq 0x8(%rbx), %rdi
movq %rdi, 0x8(%rbx)
callq 0x1ecd8
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x404c8
jmp 0x24d8b
movq %r12, %rdi
callq 0x400a4
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
movq %r15, %rdx
movq %rbx, %rcx
callq 0x40674
movq $-0x100, %rdi
addq 0x8(%rbx), %rdi
movq %rdi, 0x8(%rbx)
callq 0x1ecd8
leaq 0x8(%rsp), %rdi
callq 0x404da
leaq 0x30(%rsp), %rdi
callq 0x3d168
leaq 0xb8(%rsp), %rdi
callq 0x3d168
movq %r12, %rax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq %r12, %rdi
callq 0x404da
jmp 0x24e05
jmp 0x24e02
jmp 0x24e36
movq %rax, %r14
jmp 0x24e43
movq %rax, %r14
movq 0x58(%rsp), %rdi
cmpq %rbx, %rdi
je 0x24df6
movq 0x68(%rsp), %rsi
incq %rsi
callq 0x103d0
jmp 0x24df6
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x1d736
jmp 0x24e50
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x404da
jmp 0x24e39
movq %rax, %r14
leaq 0xb8(%rsp), %rdi
callq 0x1ecd8
jmp 0x24e26
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x211f6
jmp 0x24e50
jmp 0x24e36
jmp 0x24e36
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x3d168
leaq 0xb8(%rsp), %rdi
callq 0x3d168
movq %r14, %rdi
callq 0x106f0