// File: Nallantli[P]Rossa/main/rossa/function/function.cpp
// Function: function_evaluate_vargs(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_vargs(const ptr_function_t &function, const std::vector<symbol_t> &paramValues, const token_t *token, trace_t &stack_trace)
{
	object_t p(function->parent, object_type_enum::OBJECT_WEAK);
	const object_t newScope(&p, 0);

	newScope.createVariable(parser_t::HASH_VAR_ARGS, symbol_t::Array(paramValues), token);

	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
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rdi
callq 0x38430
movq 0x18(%rax), %rsi
movl $0x0, -0x3c(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
leaq -0x3c(%rbp), %rdx
callq 0x7d3b0
movq -0xc0(%rbp), %rsi
movq $0x0, -0x58(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x7d4e0
jmp 0x37ff6
movq -0x18(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x86c50
jmp 0x38005
movq -0x20(%rbp), %rcx
leaq 0x1adb88(%rip), %rsi    # 0x1e5b98
leaq -0x50(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x7de40
jmp 0x3801f
leaq -0x78(%rbp), %rdi
callq 0x86dc0
movq -0x10(%rbp), %rdi
callq 0x38430
addq $0x48, %rax
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rdi
callq 0x38470
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
callq 0x384a0
movq %rax, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x384d0
testb $0x1, %al
jne 0x38072
jmp 0x380ee
leaq -0x88(%rbp), %rdi
callq 0x38500
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rsi
movq %rsi, %rdx
addq $0x8, %rdx
movq -0x20(%rbp), %rcx
leaq -0x50(%rbp), %rdi
callq 0x7de40
jmp 0x380a2
jmp 0x380a4
leaq -0x88(%rbp), %rdi
callq 0x38530
jmp 0x38059
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x3825d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x38254
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x86dc0
jmp 0x38254
movq -0x10(%rbp), %rdi
callq 0x38430
movq %rax, %rdi
addq $0x38, %rdi
callq 0x2d300
movq %rax, %rsi
movq -0x28(%rbp), %rcx
movq (%rsi), %rax
movq (%rax), %rax
leaq -0xa8(%rbp), %rdi
leaq -0x50(%rbp), %rdx
callq *%rax
jmp 0x3811f
leaq -0xa8(%rbp), %rdi
callq 0x879c0
movl %eax, -0xd4(%rbp)
jmp 0x38133
movl -0xd4(%rbp), %eax
cmpl $0x4, %eax
jne 0x3819b
movl $0x3, -0xac(%rbp)
leaq -0xa8(%rbp), %rdi
leaq -0xac(%rbp), %rsi
callq 0x879e0
jmp 0x3815d
movq -0x28(%rbp), %rdi
callq 0x2d8f0
movq -0xd0(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x86d80
jmp 0x3817b
movl $0x1, -0xb0(%rbp)
jmp 0x3821a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
jmp 0x38248
movq -0xd0(%rbp), %rdi
movb $0x0, -0xb1(%rbp)
callq 0x86580
jmp 0x381b0
movq -0xd0(%rbp), %rdi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
leaq -0xa8(%rbp), %rsi
callq 0x870e0
jmp 0x381cd
movq -0x28(%rbp), %rdi
callq 0x2d8f0
movb $0x1, -0xb1(%rbp)
movl $0x1, -0xb0(%rbp)
testb $0x1, -0xb1(%rbp)
jne 0x38218
jmp 0x3820c
movq -0xd0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x60(%rbp)
movl %eax, -0x64(%rbp)
callq 0x86dc0
jmp 0x38248
movq -0xd0(%rbp), %rdi
callq 0x86dc0
jmp 0x3821a
leaq -0xa8(%rbp), %rdi
callq 0x86dc0
leaq -0x50(%rbp), %rdi
callq 0x7d790
leaq -0x38(%rbp), %rdi
callq 0x7d790
movq -0xc8(%rbp), %rax
addq $0xe0, %rsp
popq %rbp
retq
leaq -0xa8(%rbp), %rdi
callq 0x86dc0
leaq -0x50(%rbp), %rdi
callq 0x7d790
leaq -0x38(%rbp), %rdi
callq 0x7d790
movq -0x60(%rbp), %rdi
callq 0x119c0
nop