// File: 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
subq $0x440, %rsp            # imm = 0x440
movq %rdx, -0x388(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x378(%rbp)
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, %rsi
leaq -0x70(%rbp), %rdi
movq %rdi, -0x380(%rbp)
callq 0x24750
movq -0x380(%rbp), %rsi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x370(%rbp)
callq 0x41d0
movq -0x380(%rbp), %rdi
callq 0x285a0
movq -0x378(%rbp), %rax
movq -0x370(%rbp), %rsi
movq 0x8(%rax), %rax
movq %rax, -0x368(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x4150
jmp 0x23c36
movq -0x368(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0x6830
jmp 0x23c52
leaq -0x100(%rbp), %rdi
callq 0x41e0
cmpl $0x1, -0xe0(%rbp)
je 0x23daf
cmpl $0x2, -0xe0(%rbp)
je 0x23daf
movb $0x1, -0x151(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x390(%rbp)
leaq 0x75bc(%rip), %rsi      # 0x2b253
leaq -0x150(%rbp), %rdi
leaq -0x40(%rbp), %rdx
callq 0x5410
jmp 0x23ca9
leaq 0x7e2a(%rip), %rdx      # 0x2bada
leaq -0x130(%rbp), %rdi
leaq -0x150(%rbp), %rsi
callq 0x53c0
jmp 0x23cc5
movq -0x390(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x130(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x23ce1
movq -0x390(%rbp), %rdi
movb $0x0, -0x151(%rbp)
leaq 0x1608a(%rip), %rsi     # 0x39d80
leaq -0x1a9ed(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x2472d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x100(%rbp), %rdi
callq 0x41e0
jmp 0x2472d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x23d93
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x23d87
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x130(%rbp), %rdi
callq 0x41e0
leaq -0x150(%rbp), %rdi
callq 0x41e0
testb $0x1, -0x151(%rbp)
jne 0x23d9e
jmp 0x23daa
movq -0x390(%rbp), %rdi
callq 0x4230
jmp 0x24721
movq -0x388(%rbp), %rsi
leaq -0xe0(%rbp), %rdi
addq $0x28, %rdi
callq 0x7e40
testb $0x1, %al
jne 0x23eb1
movb $0x1, -0x17a(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x3a0(%rbp)
leaq -0x179(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x4590
movq -0x398(%rbp), %rdx
leaq 0x7ce7(%rip), %rsi      # 0x2baee
leaq -0x178(%rbp), %rdi
callq 0x52e0
jmp 0x23e15
movq -0x3a0(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x178(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x23e31
movq -0x3a0(%rbp), %rdi
movb $0x0, -0x17a(%rbp)
leaq 0x15f3a(%rip), %rsi     # 0x39d80
leaq -0x1ab3d(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x23e89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x41e0
leaq -0x179(%rbp), %rdi
callq 0x4360
testb $0x1, -0x17a(%rbp)
jne 0x23ea0
jmp 0x23eac
movq -0x3a0(%rbp), %rdi
callq 0x4230
jmp 0x24721
leaq -0xe0(%rbp), %rdi
addq $0x58, %rdi
callq 0x7620
movq -0x20(%rbp), %rcx
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x23fb5
movb $0x1, -0x1a2(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x3b0(%rbp)
leaq -0x1a1(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x4590
movq -0x3a8(%rbp), %rdx
leaq 0x7c0e(%rip), %rsi      # 0x2bb19
leaq -0x1a0(%rbp), %rdi
callq 0x52e0
jmp 0x23f19
movq -0x3b0(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x1a0(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x23f35
movq -0x3b0(%rbp), %rdi
movb $0x0, -0x1a2(%rbp)
leaq 0x15e36(%rip), %rsi     # 0x39d80
leaq -0x1ac41(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x23f8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x41e0
leaq -0x1a1(%rbp), %rdi
callq 0x4360
testb $0x1, -0x1a2(%rbp)
jne 0x23fa4
jmp 0x23fb0
movq -0x3b0(%rbp), %rdi
callq 0x4230
jmp 0x24721
movq -0x20(%rbp), %rax
subq $0x1, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movq $0x1, -0x1b0(%rbp)
movq -0x1b0(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x24703
movq -0x10(%rbp), %rdi
movl -0x1b0(%rbp), %esi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq %rax, -0x3b8(%rbp)
jmp 0x23ffe
movq -0x3b8(%rbp), %rax
movq %rax, -0x1b8(%rbp)
movq -0x1b8(%rbp), %rax
cmpl $0x12, 0x8(%rax)
je 0x24117
movb $0x1, -0x1da(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x3c8(%rbp)
leaq -0x1d9(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0x4590
movq -0x3c0(%rbp), %rdx
leaq 0x7ada(%rip), %rsi      # 0x2bb30
leaq -0x1d8(%rbp), %rdi
callq 0x52e0
jmp 0x24064
movq -0x3c8(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x1d8(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x24080
movq -0x3c8(%rbp), %rdi
movb $0x0, -0x1da(%rbp)
leaq 0x15ceb(%rip), %rsi     # 0x39d80
leaq -0x1ad8c(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x24721
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x240ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x41e0
leaq -0x1d9(%rbp), %rdi
callq 0x4360
testb $0x1, -0x1da(%rbp)
jne 0x24106
jmp 0x24112
movq -0x3c8(%rbp), %rdi
callq 0x4230
jmp 0x24721
leaq -0xe0(%rbp), %rdi
addq $0x58, %rdi
movq -0x1b0(%rbp), %rsi
subq $0x1, %rsi
callq 0x25d80
testb $0x1, 0x20(%rax)
je 0x24633
movq -0x1b8(%rbp), %rdi
addq $0x30, %rdi
leaq 0x73d2(%rip), %rsi      # 0x2b520
callq 0x66e0
movb %al, -0x3c9(%rbp)
jmp 0x2415b
movb -0x3c9(%rbp), %al
testb $0x1, %al
jne 0x2424e
jmp 0x2416b
movb $0x1, -0x202(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x3e0(%rbp)
leaq -0x201(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x4590
movq -0x3d8(%rbp), %rdx
leaq 0x79a7(%rip), %rsi      # 0x2bb4b
leaq -0x200(%rbp), %rdi
callq 0x52e0
jmp 0x241b2
movq -0x3e0(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x200(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x241ce
movq -0x3e0(%rbp), %rdi
movb $0x0, -0x202(%rbp)
leaq 0x15b9d(%rip), %rsi     # 0x39d80
leaq -0x1aeda(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x24226
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x41e0
leaq -0x201(%rbp), %rdi
callq 0x4360
testb $0x1, -0x202(%rbp)
jne 0x2423d
jmp 0x24249
movq -0x3e0(%rbp), %rdi
callq 0x4230
jmp 0x24721
movq -0x378(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x3f0(%rbp)
movq -0x1b8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x3e8(%rbp)
jmp 0x2427b
movq -0x3e8(%rbp), %rsi
leaq -0x2c8(%rbp), %rdi
callq 0x24750
jmp 0x24290
leaq -0x298(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
leaq -0x2c8(%rbp), %rsi
callq 0x41d0
movq -0x3f0(%rbp), %rsi
movq -0x3f8(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0x6830
jmp 0x242c6
leaq -0x298(%rbp), %rdi
callq 0x41e0
leaq -0x2c8(%rbp), %rdi
callq 0x285a0
cmpl $0x3, -0x278(%rbp)
je 0x243fd
movb $0x1, -0x2ea(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x408(%rbp)
leaq -0x2e9(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x4590
movq -0x400(%rbp), %rdx
leaq 0x785e(%rip), %rsi      # 0x2bb82
leaq -0x2e8(%rbp), %rdi
callq 0x52e0
jmp 0x24332
movq -0x408(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x2e8(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x2434e
movq -0x408(%rbp), %rdi
movb $0x0, -0x2ea(%rbp)
leaq 0x15a1d(%rip), %rsi     # 0x39d80
leaq -0x1b05a(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x41e0
leaq -0x2c8(%rbp), %rdi
callq 0x285a0
jmp 0x24721
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x243d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x2e8(%rbp), %rdi
callq 0x41e0
leaq -0x2e9(%rbp), %rdi
callq 0x4360
testb $0x1, -0x2ea(%rbp)
jne 0x243ec
jmp 0x243f8
movq -0x408(%rbp), %rdi
callq 0x4230
jmp 0x24622
testb $0x1, -0x228(%rbp)
jne 0x244ed
movb $0x1, -0x312(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x418(%rbp)
leaq -0x311(%rbp), %rdi
movq %rdi, -0x410(%rbp)
callq 0x4590
movq -0x410(%rbp), %rdx
leaq 0x775a(%rip), %rsi      # 0x2bb9d
leaq -0x310(%rbp), %rdi
callq 0x52e0
jmp 0x24451
movq -0x418(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x310(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x2446d
movq -0x418(%rbp), %rdi
movb $0x0, -0x312(%rbp)
leaq 0x158fe(%rip), %rsi     # 0x39d80
leaq -0x1b179(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x244c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x310(%rbp), %rdi
callq 0x41e0
leaq -0x311(%rbp), %rdi
callq 0x4360
testb $0x1, -0x312(%rbp)
jne 0x244dc
jmp 0x244e8
movq -0x418(%rbp), %rdi
callq 0x4230
jmp 0x24622
leaq -0x278(%rbp), %rax
addq $0x28, %rax
movq %rax, -0x420(%rbp)
leaq -0xe0(%rbp), %rdi
addq $0x58, %rdi
movq -0x1b0(%rbp), %rsi
subq $0x1, %rsi
callq 0x25d80
movq -0x420(%rbp), %rdi
movq %rax, %rsi
callq 0x7e40
testb $0x1, %al
jne 0x24611
movb $0x1, -0x33a(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x430(%rbp)
leaq -0x339(%rbp), %rdi
movq %rdi, -0x428(%rbp)
callq 0x4590
movq -0x428(%rbp), %rdx
leaq 0x7666(%rip), %rsi      # 0x2bbd0
leaq -0x338(%rbp), %rdi
callq 0x52e0
jmp 0x24578
movq -0x430(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x338(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x24594
movq -0x430(%rbp), %rdi
movb $0x0, -0x33a(%rbp)
leaq 0x157d7(%rip), %rsi     # 0x39d80
leaq -0x1b2a0(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x24742
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
jmp 0x245ec
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x338(%rbp), %rdi
callq 0x41e0
leaq -0x339(%rbp), %rdi
callq 0x4360
testb $0x1, -0x33a(%rbp)
jne 0x24603
jmp 0x2460f
movq -0x430(%rbp), %rdi
callq 0x4230
jmp 0x24622
leaq -0x278(%rbp), %rdi
callq 0x6df0
jmp 0x246ea
leaq -0x278(%rbp), %rdi
callq 0x6df0
jmp 0x24721
movq -0x1b8(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x438(%rbp)
jmp 0x2464e
leaq -0x88(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
decq %rsi
callq 0x25d80
movq %rax, %rsi
leaq -0x360(%rbp), %rdi
callq 0x4150
jmp 0x24675
movq -0x438(%rbp), %rsi
movq -0x378(%rbp), %rdi
leaq -0x360(%rbp), %rdx
callq 0x21250
jmp 0x24691
leaq -0x360(%rbp), %rdi
callq 0x41e0
leaq -0x88(%rbp), %rdi
movq -0x1b0(%rbp), %rsi
decq %rsi
callq 0x25d80
movq %rax, %rsi
movq -0x1b8(%rbp), %rdi
addq $0x30, %rdi
callq 0x4050
jmp 0x246c8
jmp 0x246ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x108(%rbp)
movl %eax, -0x10c(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x41e0
jmp 0x24721
jmp 0x246ec
movq -0x1b0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x1b0(%rbp)
jmp 0x23fd1
leaq -0xe0(%rbp), %rdi
callq 0x6df0
leaq -0x40(%rbp), %rdi
callq 0x41e0
addq $0x440, %rsp            # imm = 0x440
popq %rbp
retq
leaq -0xe0(%rbp), %rdi
callq 0x6df0
leaq -0x40(%rbp), %rdi
callq 0x41e0
movq -0x108(%rbp), %rdi
callq 0x4580
nopw %cs:(%rax,%rax)