// File: /workspace/github_cpp_makefile_star2_O1/RuiDGPires[P]CrimLang/src/generator.cpp
// Function: gc_Tracker::func_call(crl::Node*, std::__cxx11::basic_stringstream<char, std::char_traits<char>, std::allocator<char>>&)
void _gc_Tracker::func_call(crl::Node *node, std::stringstream &stream){
	ASSERT(node->get_child(0)->type == crl::Node::Type::LEAF, "Func declaration must have a type as first token");
	std::string name = get_token(node->get_child(0)).str;

	u32 ret_size = size_of(node->annotation);

	stream << 
		"MVI R1 " << ret_size << "\n" <<
		"SUB RS R1\n"; // ALLOCATE MEMORY FOR RETURN VALUE

	for (u32 i = 1; i <= node->argc; i ++){
		crl::Node *arg = node->get_child(i);
		bool is_mut = arg->annotation == "ref";

		if (is_mut){
			std::string arg_name = get_token(arg->get_child(0)).str;
			if (symb_tracker.has_local(arg_name)){
				stream << "MVI R1 " << symb_tracker.get_local(arg_name).first << "\n" <<
					"MOV R2 RF\n" << 
					"SUB R2 R1\n" <<
					"PSH R2\n";
			}else{
				stream << "MVI R1 " << symb_tracker.get_global(arg_name) << "\n" <<
					"PSH R1\n";
			}
		}else this->expression(arg->get_child(0), stream_funcs);
	}

	stream << "JMP " << name << "\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x138, %rsp            # imm = 0x138
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, -0x60(%rbp)
movq (%rsi), %rax
movq %rsi, %rdi
xorl %esi, %esi
callq *0x18(%rax)
cmpl $0x10, 0x8(%rax)
jne 0x6b4b
movq (%r14), %rax
movq %r14, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq %rax, %r15
leaq -0xc0(%rbp), %r13
movq %r13, -0x10(%r13)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %r12
movq %r12, %rdi
callq 0x4d4a
movq %r13, %rdx
movl 0x80(%r15), %eax
movl %eax, 0x28(%r12)
movq 0x78(%r15), %rax
movq %rax, 0x20(%r12)
leaq -0x70(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%r12), %rax
cmpq %r13, %rax
je 0x6702
movq %rax, -0x80(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x70(%rbp)
jmp 0x6708
movups (%rdx), %xmm0
movups %xmm0, (%rcx)
leaq -0xd0(%rbp), %rdi
movq 0x8(%rdi), %rax
movq %rax, -0x78(%rbp)
movq %rdx, (%rdi)
movq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x192b0
leaq -0x130(%rbp), %r12
movq %r12, -0x10(%r12)
movq 0x30(%r14), %rsi
movq 0x38(%r14), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %rdi
callq 0x4d4a
leaq -0x140(%rbp), %rdi
callq 0x93d7
movl %eax, %r15d
movq -0x140(%rbp), %rdi
cmpq %r12, %rdi
je 0x6778
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x3230
addq $0x10, %rbx
leaq 0x14bfa(%rip), %rsi     # 0x1b37d
movl $0x7, %edx
movq %rbx, -0x30(%rbp)
movq %rbx, %rdi
callq 0x3280
movl %r15d, %esi
movq -0x30(%rbp), %rdi
callq 0x3170
movq %rax, %r15
leaq 0x14d39(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
leaq 0x14cf4(%rip), %rsi     # 0x1b4b2
movl $0xa, %edx
movq %r15, %rdi
callq 0x3280
cmpl $0x0, 0x50(%r14)
je 0x6ae6
movq -0x60(%rbp), %rax
leaq 0x318(%rax), %rcx
movq %rcx, -0x100(%rbp)
leaq -0x40(%rbp), %r12
leaq 0x530(%rax), %rcx
movq %rcx, -0x58(%rbp)
addq $0x560, %rax            # imm = 0x560
movq %rax, -0xf8(%rbp)
movl $0x1, %r15d
movq (%r14), %rax
movq %r14, %rdi
movl %r15d, %esi
callq *0x18(%rax)
movq %rax, %r13
movq %rax, %rdi
addq $0x30, %rdi
leaq 0x14cf9(%rip), %rsi     # 0x1b520
callq 0x30a0
testl %eax, %eax
je 0x6854
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x18(%rax)
movq -0x60(%rbp), %rdi
movq %rax, %rsi
movq -0x100(%rbp), %rdx
callq 0x8c94
jmp 0x6ad9
movq %r12, %rbx
movq (%r13), %rax
movq %r13, %rdi
xorl %esi, %esi
callq *0x18(%rax)
leaq -0xc0(%rbp), %r12
movq %rax, %r13
movq %r12, -0xd0(%rbp)
movq 0x58(%rax), %rsi
movq 0x60(%rax), %rdx
addq %rsi, %rdx
leaq -0xd0(%rbp), %rdi
callq 0x4d4a
movl 0x80(%r13), %eax
leaq -0xb0(%rbp), %rcx
movl %eax, 0x8(%rcx)
movq 0x78(%r13), %rax
movq %rax, (%rcx)
movq %rbx, -0x50(%rbp)
movq -0xd0(%rbp), %rax
cmpq %r12, %rax
je 0x68c4
movq %rax, -0x50(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x68cc
movups (%r12), %xmm0
movups %xmm0, (%rbx)
movq -0xc8(%rbp), %rax
movq %rax, -0x48(%rbp)
movq %r12, -0xd0(%rbp)
movq $0x0, -0xc8(%rbp)
movb $0x0, -0xc0(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x192b0
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xa0(%rbp), %rdi
movq %rbx, %r12
callq 0x4d4a
movq -0x58(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0xdea0
movl %eax, %r13d
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x6959
movq -0x90(%rbp), %rsi
incq %rsi
callq 0x3230
testb %r13b, %r13b
je 0x6a23
movl $0x7, %edx
movq -0x30(%rbp), %rdi
leaq 0x14a0b(%rip), %rsi     # 0x1b37d
callq 0x3280
leaq -0x110(%rbp), %rax
movq %rax, -0x120(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %r13
movq %r13, %rdi
callq 0x4d4a
movq -0xf8(%rbp), %rdi
movq %r13, %rsi
callq 0xe94c
movq (%rax), %rax
movl 0x10(%rax), %esi
movq -0x30(%rbp), %rdi
callq 0x3170
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x14b14(%rip), %rsi     # 0x1b4e3
callq 0x3280
movl $0xa, %edx
movq %r13, %rdi
leaq 0x14b41(%rip), %rsi     # 0x1b524
callq 0x3280
movl $0xa, %edx
movq %r13, %rdi
leaq 0x14b38(%rip), %rsi     # 0x1b52f
callq 0x3280
movl $0x7, %edx
movq %r13, %rdi
leaq 0x14b2f(%rip), %rsi     # 0x1b53a
callq 0x3280
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rcx
jmp 0x6ab1
movl $0x7, %edx
movq -0x30(%rbp), %rdi
leaq 0x1494a(%rip), %rsi     # 0x1b37d
callq 0x3280
leaq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x4d4a
movq -0x58(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0xea96
movl (%rax), %esi
movq -0x30(%rbp), %rdi
callq 0x3170
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0x14a59(%rip), %rsi     # 0x1b4e3
callq 0x3280
movl $0x7, %edx
movq %r13, %rdi
leaq 0x14aa4(%rip), %rsi     # 0x1b542
callq 0x3280
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rcx
movq %rcx, %rax
cmpq %rcx, %rdi
je 0x6ac4
movq (%rax), %rsi
incq %rsi
callq 0x3230
movq -0x50(%rbp), %rdi
cmpq %r12, %rdi
je 0x6ad9
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3230
incl %r15d
cmpl 0x50(%r14), %r15d
jbe 0x680a
leaq 0x14a28(%rip), %rsi     # 0x1b515
movl $0x4, %edx
movq -0x30(%rbp), %rdi
callq 0x3280
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movq -0x30(%rbp), %rdi
callq 0x3280
leaq 0x149d0(%rip), %rsi     # 0x1b4e3
movl $0x1, %edx
movq %rax, %rdi
callq 0x3280
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x6b39
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3230
addq $0x138, %rsp            # imm = 0x138
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x3120
movq %rax, %r14
leaq -0x150(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1485b(%rip), %rsi     # 0x1b3c6
leaq 0x14884(%rip), %rdx     # 0x1b3f6
leaq -0x160(%rbp), %rdi
callq 0x433a
movb $0x1, %r15b
leaq -0x160(%rbp), %rcx
movq %r14, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x5470
xorl %r15d, %r15d
leaq 0x1c1d4(%rip), %rsi     # 0x22d78
leaq -0x15c5(%rip), %rdx     # 0x55e6
movq %r14, %rdi
callq 0x33d0
movq %rax, %r13
movq -0x160(%rbp), %rdi
cmpq %r12, %rdi
je 0x6bd9
movq -0x150(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x6bd9
movq %rax, %r13
movb $0x1, %r15b
testb %r15b, %r15b
je 0x6cae
movq %r14, %rdi
callq 0x31a0
jmp 0x6cae
movq %rax, %r13
movq -0x140(%rbp), %rdi
cmpq %r12, %rdi
je 0x6c95
movq -0x130(%rbp), %rsi
jmp 0x6c88
jmp 0x6c4f
movq %rax, %r13
movq -0xa0(%rbp), %rdi
leaq -0x90(%rbp), %rax
cmpq %rax, %rdi
je 0x6c7b
movq -0x90(%rbp), %rsi
jmp 0x6c73
jmp 0x6c92
jmp 0x6c92
movq %rax, %r13
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x6c7b
movq -0xe0(%rbp), %rsi
jmp 0x6c73
movq %rax, %r13
jmp 0x6c7b
jmp 0x6c92
movq %rax, %r13
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x6c7b
movq -0x110(%rbp), %rsi
incq %rsi
callq 0x3230
movq -0x50(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6c95
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x3230
jmp 0x6c95
movq %rax, %r13
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x6cae
movq -0x70(%rbp), %rsi
incq %rsi
callq 0x3230
movq %r13, %rdi
callq 0x33f0