// File: /workspace/github_cpp_makefile_star2_O1/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 %rsi, %rbx
movq %rdi, -0x30(%rbp)
movq 0x18(%rsi), %rax
subq 0x10(%rsi), %rax
movq %rax, -0x38(%rbp)
movq (%rsi), %rax
movq %rsi, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq %rax, %r12
leaq -0x250(%rbp), %r14
movq %r14, -0x10(%r14)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0x260(%rbp), %r13
movq %r13, %rdi
callq 0x4d4a
movl 0x80(%r12), %eax
movl %eax, 0x28(%r13)
movq 0x78(%r12), %rax
movq %rax, 0x20(%r13)
leaq -0x48(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%r13), %rax
cmpq %r14, %rax
je 0x16fe8
movq %rax, -0x58(%rbp)
movq -0x250(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x16fef
movups (%r14), %xmm0
movups %xmm0, (%rcx)
leaq -0x260(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x50(%rbp)
movq %r14, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x192b0
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r12
leaq -0xe0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x4d4a
leaq -0x260(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
movq %r12, %rsi
callq 0x442e
movq -0xf0(%rbp), %rdi
cmpq %r14, %rdi
je 0x1706d
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x3230
movl -0x260(%rbp), %eax
decl %eax
cmpl $0x2, %eax
jae 0x175e9
movq -0x230(%rbp), %rdx
cmpq 0x8(%r15), %rdx
jne 0x1757c
testq %rdx, %rdx
je 0x170ab
movq (%r15), %rsi
movq -0x238(%rbp), %rdi
callq 0x3240
testl %eax, %eax
jne 0x1757c
movq -0x38(%rbp), %rdx
sarq $0x3, %rdx
movq -0x200(%rbp), %rax
subq -0x208(%rbp), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
leaq -0x1(%rdx), %rax
cmpq %rax, %rcx
jne 0x17645
movl %eax, 0x50(%rbx)
movq %rdx, -0x38(%rbp)
cmpq $0x2, %rdx
jb 0x17324
movl $0x1, %r15d
xorl %r14d, %r14d
movq %rbx, -0xa0(%rbp)
movq (%rbx), %rax
movq %rbx, %rdi
movl %r15d, %esi
callq *0x18(%rax)
movq %rax, %r12
cmpl $0x12, 0x8(%rax)
jne 0x1735b
movq -0x208(%rbp), %rax
cmpb $0x1, 0x20(%rax,%r14)
jne 0x171cd
movq %r12, %rdi
addq $0x30, %rdi
leaq 0x43e5(%rip), %rsi      # 0x1b520
callq 0x30a0
testl %eax, %eax
jne 0x1750f
movq -0x30(%rbp), %rax
movq 0x8(%rax), %r13
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq -0xc0(%rbp), %rbx
movq %rax, %r12
movq %rbx, -0xd0(%rbp)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x4d4a
movl 0x80(%r12), %eax
movl %eax, 0x18(%rbx)
movq 0x78(%r12), %rax
movq %rax, 0x10(%rbx)
leaq -0x88(%rbp), %r12
movq %r12, -0x98(%rbp)
movq -0xd0(%rbp), %rax
cmpq %rbx, %rax
je 0x17244
movq %rax, -0x98(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0x1724c
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq %rax, %r13
movq -0x208(%rbp), %rax
leaq -0x68(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movq (%rax,%r14), %rsi
movq 0x8(%rax,%r14), %rdx
addq %rsi, %rdx
leaq -0x78(%rbp), %rdi
callq 0x4d4a
movq -0x30(%rbp), %rdi
movq %r13, %rsi
leaq -0x78(%rbp), %rdx
callq 0x14cca
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x17229
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x208(%rbp), %rsi
addq %r14, %rsi
addq $0x30, %r12
movq %r12, %rdi
callq 0x3150
jmp 0x17313
movups (%rbx), %xmm0
movups %xmm0, (%r12)
movq -0xc8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq %rbx, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movb $0x0, -0xc0(%rbp)
leaq -0x2d0(%rbp), %rdi
movq %r13, %rsi
leaq -0x98(%rbp), %rdx
callq 0x442e
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
movq -0xa0(%rbp), %rbx
je 0x172ab
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x3230
leaq -0xd0(%rbp), %rdi
callq 0x192b0
cmpl $0x3, -0x2d0(%rbp)
jne 0x174a2
cmpb $0x0, -0x280(%rbp)
je 0x17435
movq -0x208(%rbp), %rax
movq -0x2a0(%rbp), %rdx
cmpq 0x8(%rax,%r14), %rdx
jne 0x173c8
testq %rdx, %rdx
je 0x17307
movq (%rax,%r14), %rsi
movq -0x2a8(%rbp), %rdi
callq 0x3240
testl %eax, %eax
jne 0x173c8
leaq -0x2d0(%rbp), %rdi
callq 0x4816
incq %r15
addq $0x28, %r14
cmpq %r15, -0x38(%rbp)
jne 0x17101
leaq -0x260(%rbp), %rdi
callq 0x4816
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x17349
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3230
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x1a0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x47c9(%rip), %rsi      # 0x1bb44
leaq 0x47dc(%rip), %rdx      # 0x1bb5e
leaq -0x1b0(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x1b0(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb9c4(%rip), %rsi      # 0x22d78
leaq -0x11dd5(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x120(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x47fc(%rip), %rsi      # 0x1bbe4
leaq 0x482f(%rip), %rdx      # 0x1bc1e
leaq -0x130(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x130(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb957(%rip), %rsi      # 0x22d78
leaq -0x11e42(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x140(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x475c(%rip), %rsi      # 0x1bbb1
leaq 0x4787(%rip), %rdx      # 0x1bbe3
leaq -0x150(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x150(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb8ea(%rip), %rsi      # 0x22d78
leaq -0x11eaf(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x160(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x46d4(%rip), %rsi      # 0x1bb96
leaq 0x46e7(%rip), %rdx      # 0x1bbb0
leaq -0x170(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x170(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb87d(%rip), %rsi      # 0x22d78
leaq -0x11f1c(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x180(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x4630(%rip), %rsi      # 0x1bb5f
leaq 0x465f(%rip), %rdx      # 0x1bb95
leaq -0x190(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x190(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb810(%rip), %rsi      # 0x22d78
leaq -0x11f89(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x1e0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x4566(%rip), %rsi      # 0x1bb02
leaq 0x4589(%rip), %rdx      # 0x1bb2c
leaq -0x1f0(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x1f0(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb7a3(%rip), %rsi      # 0x22d78
leaq -0x11ff6(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq 0x3c56(%rip), %rsi      # 0x1b253
leaq -0x2d0(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x40f6
leaq 0x44da(%rip), %rsi      # 0x1baee
leaq -0x2d0(%rbp), %rdi
callq 0x3430
leaq -0x100(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rcx
movq %rax, %rdx
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x176af
movups (%rdx), %xmm0
movups %xmm0, (%r12)
jmp 0x176c0
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x1c0(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x44c8(%rip), %rsi      # 0x1bb2d
leaq 0x44d7(%rip), %rdx      # 0x1bb43
leaq -0x1d0(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x1d0(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb6da(%rip), %rsi      # 0x22d78
leaq -0x120bf(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x1770c
movq %rcx, -0x110(%rbp)
movq (%rdx), %rcx
movq %rcx, -0x100(%rbp)
movq 0x8(%rax), %rsi
leaq -0x110(%rbp), %rcx
movq %rsi, 0x8(%rcx)
movq %rdx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %r15b
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0xb67b(%rip), %rsi      # 0x22d78
leaq -0x1211e(%rip), %rdx    # 0x55e6
movq %r14, %rdi
callq 0x33d0
movq %rax, %rbx
movq -0x110(%rbp), %rdi
cmpq %r12, %rdi
je 0x17732
movq -0x100(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x17732
movq %rax, %rbx
movb $0x1, %r15b
leaq -0x2c0(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x178ae
movq -0x2c0(%rbp), %rsi
jmp 0x1789e
movq %rax, %rbx
movq -0x1d0(%rbp), %rdi
cmpq %r12, %rdi
je 0x178ae
movq -0x1c0(%rbp), %rsi
jmp 0x1789e
jmp 0x178a8
jmp 0x178a8
movq %rax, %rbx
movq -0x1f0(%rbp), %rdi
cmpq %r12, %rdi
je 0x178ae
movq -0x1e0(%rbp), %rsi
jmp 0x1789e
jmp 0x178a8
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
cmpq %r14, %rdi
je 0x178fa
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x178fa
movq %rax, %rbx
jmp 0x178fa
movq %rax, %rbx
movq -0x190(%rbp), %rdi
cmpq %r12, %rdi
je 0x178ae
movq -0x180(%rbp), %rsi
jmp 0x1789e
jmp 0x178a8
movq %rax, %rbx
movq -0x170(%rbp), %rdi
cmpq %r12, %rdi
je 0x1784c
movq -0x160(%rbp), %rsi
jmp 0x1783c
jmp 0x17846
movq %rax, %rbx
movq -0x150(%rbp), %rdi
cmpq %r12, %rdi
je 0x1784c
movq -0x140(%rbp), %rsi
jmp 0x1783c
jmp 0x17846
movq %rax, %rbx
movq -0x130(%rbp), %rdi
cmpq %r12, %rdi
je 0x1784c
movq -0x120(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x1784c
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x17859
movq %r14, %rdi
callq 0x31a0
leaq -0x2d0(%rbp), %rdi
callq 0x4816
jmp 0x178ee
movq %rax, %rbx
movq -0x78(%rbp), %rdi
leaq -0x68(%rbp), %rax
cmpq %rax, %rdi
je 0x178ee
movq -0x68(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x178ee
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
cmpq %r12, %rdi
je 0x178ae
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x178ae
movq %rax, %rbx
movb $0x1, %r15b
testb %r15b, %r15b
je 0x178ee
movq %r14, %rdi
callq 0x31a0
jmp 0x178ee
movq %rax, %rbx
movq -0x98(%rbp), %rdi
cmpq %r12, %rdi
je 0x178db
movq -0x88(%rbp), %rsi
incq %rsi
callq 0x3230
leaq -0xd0(%rbp), %rdi
callq 0x192b0
jmp 0x178ee
jmp 0x178eb
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
callq 0x4816
leaq -0x48(%rbp), %rax
movq -0x58(%rbp), %rdi
cmpq %rax, %rdi
je 0x17913
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x3230
movq %rbx, %rdi
callq 0x33f0
nop