// File: /workspace/github_cpp_makefile_star2_O2/RuiDGPires[P]CrimLang/src/semantic_analiser.cpp
// Function: sc_Tracker::func_call(crl::Node*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void _sc_Tracker::func_call(crl::Node *node, std::string annotation){
	size_t size = node->children.size();
	std::string func_name = get_token(node->get_child(0)).str;
	Context::Item item = this->context->seek(func_name);

	ASSERT(item.type == Context::Item::Type::FUNC || item.type == Context::Item::Type::CAS, "'" + func_name + "' is not a function");

	ASSERT(item.subtype == annotation, "Return type does not match expression type");
	
	ASSERT(item.args.size() == size - 1, "Functions do not match");

	node->argc = size - 1;

	for (size_t i = 1; i < size; i++){
		crl::Node *arg = node->get_child(i);
		ASSERT(arg->type == crl::Node::Type::ARG, "Argument isn't of type ARG");
		if (item.args[i-1].second){
			ASSERT(arg->annotation == "ref", "Mutable function argments must be passed as references");
			Context::Item aux = this->context->seek(get_token(arg->get_child(0)).str);
			ASSERT(aux.type == Context::Item::Type::VAR, "No variable with this name");
			ASSERT(aux._mutable, "Variable must be mutable to be passed by reference");
			ASSERT(aux.subtype == item.args[i-1].first, "Passed variable type does not match function argument type");
		}else{
			this->expression(arg->get_child(0), item.args[i-1].first);
			arg->annotation = item.args[i-1].first;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdx, %r15
movq %rdi, -0x30(%rbp)
movq 0x18(%rsi), %r13
subq 0x10(%rsi), %r13
movq (%rsi), %rax
movq %rsi, -0x38(%rbp)
movq %rsi, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq 0x58(%rax), %rsi
leaq -0x120(%rbp), %r14
movq %r14, %rdi
callq 0xb24a
leaq -0xa0(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%r14), %rdx
leaq -0x110(%rbp), %rax
cmpq %rax, %rdx
je 0x11924
movq %rdx, -0xb0(%rbp)
movq -0x110(%rbp), %rcx
movq %rcx, -0xa0(%rbp)
jmp 0x1192a
movups (%rax), %xmm0
movups %xmm0, (%rcx)
leaq -0x120(%rbp), %rdi
movq 0x8(%rdi), %rcx
leaq -0xb0(%rbp), %r12
movq %rcx, 0x8(%r12)
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x135f8
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r14
leaq -0x140(%rbp), %rdi
movq %r12, %rsi
callq 0x32f0
leaq -0x120(%rbp), %rdi
leaq -0x140(%rbp), %rdx
movq %r14, %rsi
callq 0x4172
leaq -0x140(%rbp), %rdi
callq 0x3110
movl -0x120(%rbp), %eax
decl %eax
cmpl $0x2, %eax
jae 0x11d5f
leaq -0xf8(%rbp), %rdi
movq %r15, %rsi
callq 0x4843
testb %al, %al
je 0x11dd3
movq -0xc0(%rbp), %rax
subq -0xc8(%rbp), %rax
sarq $0x3, %r13
pushq $0x28
popq %rcx
cqto
idivq %rcx
movq %r13, -0x70(%rbp)
leaq -0x1(%r13), %rcx
cmpq %rcx, %rax
jne 0x11e2a
movq -0x38(%rbp), %rcx
movl %eax, 0x50(%rcx)
pushq $0x1
popq %r15
xorl %r13d, %r13d
leaq -0x2d0(%rbp), %rbx
cmpq -0x70(%rbp), %r15
jae 0x11b7c
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
movl %r15d, %esi
callq *0x18(%rax)
movq %rax, %r12
cmpl $0x12, 0x8(%rax)
jne 0x11ba6
movq -0xc8(%rbp), %rax
cmpb $0x1, 0x20(%rax,%r13)
jne 0x11a8e
movq %r12, %rdi
addq $0x30, %rdi
leaq 0x3aec(%rip), %rsi      # 0x15520
callq 0x410a
testb %al, %al
je 0x11d05
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r14
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0x68(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0x80(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movq -0x68(%rbp), %rax
leaq -0x58(%rbp), %rdx
cmpq %rdx, %rax
je 0x11ae4
movq %rax, -0x90(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x80(%rbp)
jmp 0x11aea
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq %rax, %r14
movq -0xc8(%rbp), %rsi
addq %r13, %rsi
movq %rbx, %rdi
callq 0x32f0
movq -0x30(%rbp), %rdi
movq %r14, %rsi
movq %rbx, %r14
movq %rbx, %rdx
callq 0x10032
movq %r14, %rdi
callq 0x3110
movq -0xc8(%rbp), %rsi
addq %r13, %rsi
addq $0x30, %r12
movq %r12, %rdi
callq 0x3160
jmp 0x11b70
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
movq -0x60(%rbp), %rax
movq %rax, -0x88(%rbp)
movq %rdx, -0x68(%rbp)
andq $0x0, -0x60(%rbp)
movb $0x0, -0x58(%rbp)
leaq -0x1b0(%rbp), %rdi
movq %r14, %rsi
leaq -0x90(%rbp), %r14
movq %r14, %rdx
callq 0x4172
movq %r14, %rdi
callq 0x3110
leaq -0x68(%rbp), %rdi
callq 0x135f8
cmpl $0x3, -0x1b0(%rbp)
jne 0x11c00
cmpb $0x0, -0x160(%rbp)
je 0x11c57
movq -0xc8(%rbp), %rsi
addq %r13, %rsi
leaq -0x188(%rbp), %rdi
callq 0x4843
testb %al, %al
je 0x11cae
leaq -0x1b0(%rbp), %rdi
callq 0x44c8
incq %r15
addq $0x28, %r13
jmp 0x119f3
leaq -0x120(%rbp), %rdi
callq 0x44c8
leaq -0xb0(%rbp), %rdi
callq 0x3110
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3f8c(%rip), %rsi      # 0x15b44
leaq -0x250(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x250(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xc1a4(%rip), %rsi      # 0x1dd90
leaq -0xccbb(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3f84(%rip), %rsi      # 0x15b96
leaq -0x210(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x210(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xc14d(%rip), %rsi      # 0x1dd90
leaq -0xcd12(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3f48(%rip), %rsi      # 0x15bb1
leaq -0x1f0(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x1f0(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xc0f6(%rip), %rsi      # 0x1dd90
leaq -0xcd69(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3f24(%rip), %rsi      # 0x15be4
leaq -0x1d0(%rbp), %rdi
leaq -0x68(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x1d0(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xc09f(%rip), %rsi      # 0x1dd90
leaq -0xcdc0(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3e48(%rip), %rsi      # 0x15b5f
leaq -0x230(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x230(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xc045(%rip), %rsi      # 0x1dd90
leaq -0xce1a(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x34e2(%rip), %rsi      # 0x15253
leaq -0x1b0(%rbp), %rdi
leaq -0xb0(%rbp), %rdx
callq 0x3c55
leaq 0x3d63(%rip), %rdx      # 0x15aee
leaq -0x2b0(%rbp), %rdi
leaq -0x1b0(%rbp), %rsi
callq 0x3c2c
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x2b0(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xbfd1(%rip), %rsi      # 0x1dd90
leaq -0xce8e(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3d1d(%rip), %rsi      # 0x15b02
leaq -0x290(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x290(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xbf77(%rip), %rsi      # 0x1dd90
leaq -0xcee8(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x11e7f
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x3cf1(%rip), %rsi      # 0x15b2d
leaq -0x270(%rbp), %rdi
leaq -0x1b0(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x270(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xbf20(%rip), %rsi      # 0x1dd90
leaq -0xcf3f(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
movq %rax, %rbx
leaq -0x2b0(%rbp), %rdi
callq 0x3110
jmp 0x11e96
movq %rax, %rbx
movb $0x1, %r15b
leaq -0x1b0(%rbp), %rdi
jmp 0x11f4e
movq %rax, %rbx
leaq -0x270(%rbp), %rdi
jmp 0x11f4e
jmp 0x11f5a
movq %rax, %rbx
leaq -0x290(%rbp), %rdi
jmp 0x11f4e
jmp 0x11f5a
jmp 0x11f5a
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x3110
jmp 0x11fa3
movq %rax, %rbx
jmp 0x11fa3
movq %rax, %rbx
leaq -0x230(%rbp), %rdi
jmp 0x11f4e
jmp 0x11f5a
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
jmp 0x11f1f
movq %rax, %rbx
leaq -0x1f0(%rbp), %rdi
jmp 0x11f1f
jmp 0x11f2b
jmp 0x11f2b
movq %rax, %rbx
leaq -0x210(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
jne 0x11f2e
jmp 0x11f36
movq %rax, %rbx
movq %r14, %rdi
callq 0x31b0
leaq -0x1b0(%rbp), %rdi
callq 0x44c8
jmp 0x11f97
movq %rax, %rbx
leaq -0x250(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
jne 0x11f5d
jmp 0x11f97
movq %rax, %rbx
movq %r14, %rdi
callq 0x31b0
jmp 0x11f97
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3110
leaq -0x68(%rbp), %rdi
callq 0x135f8
jmp 0x11f97
movq %rax, %rbx
leaq -0x2d0(%rbp), %rdi
callq 0x3110
jmp 0x11f97
jmp 0x11f94
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
callq 0x44c8
leaq -0xb0(%rbp), %rdi
callq 0x3110
movq %rbx, %rdi
callq 0x3410
nop