// File: /workspace/github_cpp_makefile_star2_O3/RuiDGPires[P]CrimLang/src/semantic_analiser.cpp
// Function: sc_Tracker::func_declaration(crl::Node*)
void _sc_Tracker::func_declaration(crl::Node *node){
	this->func_returns = false;
	Context::Item item;
	item.type = Context::Item::Type::FUNC;
	item.subtype = ((crl::Leaf *)node->get_child(0))->token.str;
	item.name = ((crl::Leaf *)node->get_child(1))->token.str;
	ASSERT(item.name != "_start", "_start is a reserved name");

	// Parse once to add to the args to the declaration
	int i;
	for (i = 2; node->get_child(i)->type == crl::Node::Type::ARG; i++){
		crl::Node *arg = node->get_child(i);
		std::string var_type = ((crl::Leaf *) arg->get_child(0))->token.str;

		item.args.push_back(std::pair<std::string, bool>(var_type, arg->annotation == "mut"));
	}

	node->argc = i - 2; // Store the number of arguments

	this->add(item);

	this->enter();
	// Add args to the function context
	i = 2;
	for (; node->get_child(i)->type == crl::Node::Type::ARG; i++){
		crl::Node *arg = node->get_child(i);
		Context::Item arg_item;
		arg_item.type = Context::Item::Type::VAR;
		arg_item.subtype = ((crl::Leaf *) arg->get_child(0))->token.str;
		arg_item.name = ((crl::Leaf *) arg->get_child(1))->token.str;
		arg_item._mutable = arg->annotation == "mut";
		this->add(arg_item);
	}
	this->block(node->get_child(i), item.subtype);
	
	ASSERT(func_returns, "Functions must return on all possible paths");
	this->leave();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x248, %rsp            # imm = 0x248
movq %rsi, %r14
xorl %eax, %eax
movq %rdi, -0x30(%rbp)
movb %al, 0x10(%rdi)
leaq -0x1e8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x1c8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
movb %al, 0x10(%rcx)
movl $0x0, 0x14(%rcx)
movb %al, 0x18(%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x20(%rcx)
movq %rax, 0x30(%rcx)
movl $0x1, -0x38(%rcx)
movq (%rsi), %rax
movq %rsi, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq -0x1d8(%rbp), %rdi
addq $0x58, %rax
movq %rax, %rsi
callq 0x3150
movq (%r14), %rax
movq %r14, %rdi
movl $0x1, %esi
callq *0x18(%rax)
leaq -0x1f8(%rbp), %rbx
addq $0x58, %rax
movq %rbx, %rdi
movq %rax, %rsi
callq 0x3150
leaq 0x78b2(%rip), %rsi      # 0x1b926
movq %rbx, %rdi
callq 0x30a0
testl %eax, %eax
je 0x14463
xorl %ebx, %ebx
leaq -0xb0(%rbp), %r12
leaq -0xc0(%rbp), %r13
leal 0x2(%rbx), %r15d
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x18(%rax)
cmpl $0x12, 0x8(%rax)
jne 0x14168
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x18(%rax)
movq %rax, %r15
movq (%rax), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq -0x40(%rbp), %rcx
movq %rcx, -0x50(%rbp)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rdi
callq 0x4d52
addq $0x30, %r15
movq %r15, %rdi
leaq 0x735e(%rip), %rsi      # 0x1b450
callq 0x30a0
movl %eax, %r15d
movq %r12, -0xc0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r13, %rdi
callq 0x4d52
testl %r15d, %r15d
sete -0xa0(%rbp)
leaq -0x1a8(%rbp), %rdi
movq %r13, %rsi
callq 0x18ae4
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x14148
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x14161
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3230
incl %ebx
jmp 0x14094
movl %ebx, 0x50(%r14)
movl -0x200(%rbp), %eax
leaq -0x268(%rbp), %rdi
movl %eax, -0x8(%rdi)
leaq -0x258(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq -0x1f8(%rbp), %rsi
movq -0x1f0(%rbp), %rdx
addq %rsi, %rdx
callq 0x4d52
leaq -0x248(%rbp), %rdi
leaq -0x238(%rbp), %r12
movq %r12, -0x10(%r12)
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
addq %rsi, %rdx
callq 0x4d52
leaq -0x1b8(%rbp), %rcx
movb 0x8(%rcx), %al
leaq -0x218(%rbp), %rdi
movb %al, -0x8(%rdi)
movq (%rcx), %rax
movq %rax, -0x10(%rdi)
leaq -0x1a8(%rbp), %rsi
callq 0x4ade
leaq -0x270(%rbp), %rsi
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x13b00
leaq -0x270(%rbp), %rdi
callq 0x4824
movq %rbx, %rdi
callq 0x13a90
leaq -0x188(%rbp), %r12
movl $0x2, %ebx
xorl %r13d, %r13d
movq (%r14), %rax
movq %r14, %rdi
movl %ebx, %esi
callq *0x18(%rax)
cmpl $0x12, 0x8(%rax)
movq (%r14), %rax
movq 0x18(%rax), %rax
jne 0x143b4
movq %r14, %rdi
movl %ebx, %esi
callq *%rax
movq %rax, %r15
leaq -0xa8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq %r13, -0xb0(%rbp)
movb %r13b, -0xa8(%rbp)
leaq -0x88(%rbp), %rax
movq %rax, -0x98(%rbp)
movq %r13, -0x90(%rbp)
movb %r13b, -0x88(%rbp)
movb %r13b, -0x78(%rbp)
movl $0x0, -0x74(%rbp)
movb %r13b, -0x70(%rbp)
leaq -0x68(%rbp), %rax
movq %r13, 0x10(%rax)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl $0x3, -0xc0(%rbp)
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x3150
movq (%r15), %rax
movq %r15, %rdi
movl $0x1, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0xb8(%rbp), %rdi
movq %rax, %rsi
callq 0x3150
addq $0x30, %r15
movq %r15, %rdi
leaq 0x715b(%rip), %rsi      # 0x1b450
callq 0x30a0
testl %eax, %eax
sete -0x70(%rbp)
movl -0xc0(%rbp), %eax
movl %eax, -0x190(%rbp)
leaq -0x178(%rbp), %rax
movq %rax, -0x188(%rbp)
movq -0xb8(%rbp), %rsi
movq -0xb0(%rbp), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x4d52
leaq -0x158(%rbp), %rax
movq %rax, -0x168(%rbp)
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
addq %rsi, %rdx
leaq -0x168(%rbp), %rdi
callq 0x4d52
leaq -0xb8(%rbp), %rcx
movb 0x48(%rcx), %al
movb %al, 0x48(%r12)
movq 0x40(%rcx), %rax
movq %rax, 0x40(%r12)
leaq -0x138(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x4ade
movq -0x30(%rbp), %rdi
leaq -0x190(%rbp), %r15
movq %r15, %rsi
callq 0x13b00
movq %r15, %rdi
callq 0x4824
leaq -0xc0(%rbp), %rdi
callq 0x4824
incl %ebx
jmp 0x14223
movq %r14, %rdi
movl %ebx, %esi
callq *%rax
movq %rax, %rbx
leaq -0xd0(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x1d8(%rbp), %rsi
movq -0x1d0(%rbp), %rdx
addq %rsi, %rdx
leaq -0xe0(%rbp), %rdi
callq 0x4d52
leaq -0xe0(%rbp), %rdx
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x146d0
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x14414
movq -0xd0(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x30(%rbp), %rax
cmpb $0x0, 0x10(%rax)
je 0x144cc
movq %rax, %rcx
movq 0x8(%rax), %rbx
movq (%rbx), %rax
movq %rax, 0x8(%rcx)
movq %rbx, %rdi
callq 0x4420
movl $0x38, %esi
movq %rbx, %rdi
callq 0x3230
leaq -0x200(%rbp), %rdi
callq 0x4824
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x110(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x74ab(%rip), %rsi      # 0x1b92d
leaq 0x74bd(%rip), %rdx      # 0x1b946
leaq -0x120(%rbp), %rdi
callq 0x4336
movb $0x1, %r12b
leaq -0x120(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r12d, %r12d
leaq 0xe8bd(%rip), %rsi      # 0x22d78
leaq -0xeedc(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
jmp 0x14533
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0xf0(%rbp), %rbx
movq %rbx, -0x10(%rbx)
leaq 0x745c(%rip), %rsi      # 0x1b947
leaq 0x7480(%rip), %rdx      # 0x1b972
leaq -0x100(%rbp), %rdi
callq 0x4336
movb $0x1, %r12b
leaq -0x100(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r12d, %r12d
leaq 0xe854(%rip), %rsi      # 0x22d78
leaq -0xef45(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
movq %rax, %r15
movq -0x100(%rbp), %rdi
cmpq %rbx, %rdi
je 0x1456b
movq -0xf0(%rbp), %rsi
jmp 0x14563
jmp 0x14575
movq %rax, %r15
movq -0x120(%rbp), %rdi
cmpq %rbx, %rdi
je 0x1456b
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x3230
testb %r12b, %r12b
jne 0x14578
jmp 0x146bb
movq %rax, %r15
movq %r14, %rdi
callq 0x31a0
jmp 0x146bb
movq %rax, %r15
movq -0xe0(%rbp), %rdi
cmpq %r14, %rdi
je 0x146bb
movq -0xd0(%rbp), %rsi
jmp 0x14697
movq %rax, %r15
leaq -0x270(%rbp), %rdi
jmp 0x146b6
movq %rax, %r15
movq -0x248(%rbp), %rdi
cmpq %r12, %rdi
je 0x145d6
movq -0x238(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x145d6
movq %rax, %r15
movq -0x268(%rbp), %rdi
cmpq %rbx, %rdi
je 0x146bb
movq -0x258(%rbp), %rsi
jmp 0x14697
jmp 0x146a7
jmp 0x146a7
jmp 0x146a7
movq %rax, %r15
leaq -0x190(%rbp), %rdi
callq 0x4824
jmp 0x146af
movq %rax, %r15
movq -0x168(%rbp), %rdi
leaq -0x158(%rbp), %rax
cmpq %rax, %rdi
je 0x1463f
movq -0x158(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x1463f
movq %rax, %r15
movq -0x188(%rbp), %rdi
leaq -0x178(%rbp), %rax
cmpq %rax, %rdi
je 0x146af
movq -0x178(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x146af
movq %rax, %r15
movq -0xc0(%rbp), %rdi
cmpq %r12, %rdi
je 0x14686
movq -0xb0(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x14686
movq %rax, %r15
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x146bb
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x146bb
jmp 0x146a7
jmp 0x146a7
jmp 0x146a7
movq %rax, %r15
jmp 0x146bb
movq %rax, %r15
leaq -0xc0(%rbp), %rdi
callq 0x4824
leaq -0x200(%rbp), %rdi
callq 0x4824
movq %r15, %rdi
callq 0x33f0
nop