// File: RuiDGPires[P]CrimLang/src/semantic_analiser.cpp
// Function: sc_Tracker::expression_get_type[abi:cxx11](crl::Node*)
std::string _sc_Tracker::expression_get_type(crl::Node *node){
	size_t size = node->children.size();

	std::stack<crl::Node *> stack;

	for (size_t i = 0; i < size; i++){
		stack.push(node->get_child(i));
	}

	while(!stack.empty()){
		crl::Node *current = stack.top();
		stack.pop();
		switch (current->type){
		case crl::Node::Type::CALL:
			{
			std::string func_name = get_token(node->get_child(0)).str;
			Context::Item item = this->context->seek(func_name);
			return item.subtype;
			}
			break;
			
		case crl::Node::Type::DEC:
		case crl::Node::Type::INC:
			if (((crl::Leaf *) current->get_child(0))->token.type == crl::Token::Type::IDENT){
				Context::Item item = this->context->seek(((crl::Leaf *) current->get_child(0))->token.str);
				return item.subtype;
			}else ASSERT(false, "Unkown type");
			break;
		case crl::Node::Type::CAST:
			return get_token(current->get_child(1)).str;
			break;
		case crl::Node::Type::VECTOR:
			{
			Context::Item item = this->context->seek(((crl::Leaf *) current->get_child(0))->token.str);
			return item.subtype;
			}
			break;
		case crl::Node::Type::LEAF:
			if (((crl::Leaf *) current)->token.type == crl::Token::Type::IDENT){
				Context::Item item = this->context->seek(((crl::Leaf *) current)->token.str);
				return item.subtype;
			}else if (((crl::Leaf *) current)->token.type == crl::Token::Type::INT);
			else if (((crl::Leaf *) current)->token.type == crl::Token::Type::DEC)
				return "f32";
			else if (((crl::Leaf *) current)->token.type == crl::Token::Type::STRING)
				return "string";
			break;

		case crl::Node::Type::COMPARISON:
			if (current->children.size() > 1){
				return "u32";
				break;
			}
		default:
			for (size_t i = 0; i < current->children.size(); i++)
				stack.push(current->get_child(i));
			break;
		}
	}
	return "i32"; // Default type
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x480, %rsp            # imm = 0x480
movq %rdi, -0x3c0(%rbp)
movq %rdi, %rax
movq %rax, -0x3b8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x3b0(%rbp)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
movq %rax, -0x20(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x25da0
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0x24dd9
movq -0x18(%rbp), %rdi
movl -0x78(%rbp), %esi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq %rax, -0x3c8(%rbp)
jmp 0x24d98
movq -0x3c8(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x25dd0
jmp 0x24db2
jmp 0x24db4
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x24d75
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x25668
jmp 0x24ddb
leaq -0x70(%rbp), %rdi
callq 0x25e00
movb %al, -0x3c9(%rbp)
jmp 0x24dec
movb -0x3c9(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x24dfd
jmp 0x255e8
leaq -0x70(%rbp), %rdi
callq 0x25e20
movq %rax, -0x3d8(%rbp)
jmp 0x24e0f
movq -0x3d8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x98(%rbp)
leaq -0x70(%rbp), %rdi
callq 0x25e40
jmp 0x24e2b
movq -0x98(%rbp), %rax
movl 0x8(%rax), %eax
addl $-0xc, %eax
movl %eax, %ecx
movq %rcx, -0x3e0(%rbp)
subl $0xd, %eax
ja 0x25551
movq -0x3e0(%rbp), %rax
leaq 0x6a2c(%rip), %rcx      # 0x2b884
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x3e8(%rbp)
jmp 0x24e79
movq -0x3e8(%rbp), %rsi
leaq -0xe8(%rbp), %rdi
callq 0x24750
jmp 0x24e8e
leaq -0xb8(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
leaq -0xe8(%rbp), %rsi
movq %rsi, -0x400(%rbp)
callq 0x41d0
movq -0x400(%rbp), %rdi
callq 0x285a0
movq -0x3b0(%rbp), %rax
movq -0x3f8(%rbp), %rsi
movq 0x8(%rax), %rax
movq %rax, -0x3f0(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x4150
jmp 0x24ee2
movq -0x3f0(%rbp), %rsi
leaq -0x158(%rbp), %rdi
leaq -0x178(%rbp), %rdx
callq 0x6830
jmp 0x24efe
leaq -0x178(%rbp), %rdi
callq 0x41e0
movq -0x3c0(%rbp), %rdi
leaq -0x130(%rbp), %rsi
callq 0x4150
jmp 0x24f1f
movl $0x1, -0x17c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x6df0
leaq -0xb8(%rbp), %rdi
callq 0x41e0
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x24f98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x41e0
jmp 0x24f98
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x6df0
leaq -0xb8(%rbp), %rdi
callq 0x41e0
jmp 0x25668
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x408(%rbp)
jmp 0x24fc4
movq -0x408(%rbp), %rax
cmpl $0x1, 0x78(%rax)
jne 0x250b9
movq -0x3b0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x418(%rbp)
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x410(%rbp)
jmp 0x25002
movq -0x410(%rbp), %rsi
addq $0x58, %rsi
leaq -0x210(%rbp), %rdi
callq 0x4150
jmp 0x2501b
movq -0x418(%rbp), %rsi
leaq -0x1f0(%rbp), %rdi
leaq -0x210(%rbp), %rdx
callq 0x6830
jmp 0x25037
leaq -0x210(%rbp), %rdi
callq 0x41e0
movq -0x3c0(%rbp), %rdi
leaq -0x1c8(%rbp), %rsi
callq 0x4150
jmp 0x25058
movl $0x1, -0x17c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x6df0
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x210(%rbp), %rdi
callq 0x41e0
jmp 0x25668
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x6df0
jmp 0x25668
movb $0x1, -0x232(%rbp)
movl $0x50, %edi
callq 0x4190
movq %rax, -0x428(%rbp)
leaq -0x231(%rbp), %rdi
movq %rdi, -0x420(%rbp)
callq 0x4590
movq -0x420(%rbp), %rdx
leaq 0x6b19(%rip), %rsi      # 0x2bc0b
leaq -0x230(%rbp), %rdi
callq 0x52e0
jmp 0x25100
movq -0x428(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
leaq -0x230(%rbp), %rcx
movl %edx, %esi
callq 0x9140
jmp 0x2511c
movq -0x428(%rbp), %rdi
movb $0x0, -0x232(%rbp)
leaq 0x14c4f(%rip), %rsi     # 0x39d80
leaq -0x1be28(%rip), %rdx    # 0x9310
callq 0x4550
jmp 0x2567d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
jmp 0x25174
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x230(%rbp), %rdi
callq 0x41e0
leaq -0x231(%rbp), %rdi
callq 0x4360
testb $0x1, -0x232(%rbp)
jne 0x2518b
jmp 0x25197
movq -0x428(%rbp), %rdi
callq 0x4230
jmp 0x25668
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
movl $0x1, %esi
callq *%rax
movq %rax, -0x430(%rbp)
jmp 0x251ba
movq -0x430(%rbp), %rsi
leaq -0x268(%rbp), %rdi
callq 0x24750
jmp 0x251cf
movq -0x3c0(%rbp), %rdi
leaq -0x268(%rbp), %rsi
callq 0x41d0
leaq -0x268(%rbp), %rdi
callq 0x285a0
movl $0x1, -0x17c(%rbp)
jmp 0x2564f
movq -0x3b0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x440(%rbp)
movq -0x98(%rbp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
xorl %esi, %esi
callq *%rax
movq %rax, -0x438(%rbp)
jmp 0x2522a
movq -0x438(%rbp), %rsi
addq $0x58, %rsi
leaq -0x2f8(%rbp), %rdi
callq 0x4150
jmp 0x25243
movq -0x440(%rbp), %rsi
leaq -0x2d8(%rbp), %rdi
leaq -0x2f8(%rbp), %rdx
callq 0x6830
jmp 0x2525f
leaq -0x2f8(%rbp), %rdi
callq 0x41e0
movq -0x3c0(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
callq 0x4150
jmp 0x25280
movl $0x1, -0x17c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x6df0
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x2f8(%rbp), %rdi
callq 0x41e0
jmp 0x25668
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x6df0
jmp 0x25668
movq -0x98(%rbp), %rax
cmpl $0x1, 0x78(%rax)
jne 0x253bb
movq -0x3b0(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x448(%rbp)
movq -0x98(%rbp), %rsi
addq $0x58, %rsi
leaq -0x388(%rbp), %rdi
callq 0x4150
jmp 0x2531d
movq -0x448(%rbp), %rsi
leaq -0x368(%rbp), %rdi
leaq -0x388(%rbp), %rdx
callq 0x6830
jmp 0x25339
leaq -0x388(%rbp), %rdi
callq 0x41e0
movq -0x3c0(%rbp), %rdi
leaq -0x340(%rbp), %rsi
callq 0x4150
jmp 0x2535a
movl $0x1, -0x17c(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x6df0
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x388(%rbp), %rdi
callq 0x41e0
jmp 0x25668
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x368(%rbp), %rdi
callq 0x6df0
jmp 0x25668
movq -0x98(%rbp), %rax
cmpl $0x13, 0x78(%rax)
jne 0x253cd
jmp 0x254c5
movq -0x98(%rbp), %rax
cmpl $0x14, 0x78(%rax)
jne 0x25447
leaq -0x389(%rbp), %rdi
movq %rdi, -0x450(%rbp)
callq 0x4590
movq -0x3c0(%rbp), %rdi
movq -0x450(%rbp), %rdx
leaq 0x6295(%rip), %rsi      # 0x2b697
callq 0x52e0
jmp 0x25409
leaq -0x389(%rbp), %rdi
callq 0x4360
movl $0x1, -0x17c(%rbp)
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x389(%rbp), %rdi
callq 0x4360
jmp 0x25668
movq -0x98(%rbp), %rax
cmpl $0x1c, 0x78(%rax)
jne 0x254c1
leaq -0x38a(%rbp), %rdi
movq %rdi, -0x458(%rbp)
callq 0x4590
movq -0x3c0(%rbp), %rdi
movq -0x458(%rbp), %rdx
leaq 0x679b(%rip), %rsi      # 0x2bc17
callq 0x52e0
jmp 0x25483
leaq -0x38a(%rbp), %rdi
callq 0x4360
movl $0x1, -0x17c(%rbp)
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x38a(%rbp), %rdi
callq 0x4360
jmp 0x25668
jmp 0x254c3
jmp 0x254c5
jmp 0x254c7
jmp 0x255e3
movq -0x98(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
cmpq $0x1, %rax
jbe 0x2554f
leaq -0x38b(%rbp), %rdi
movq %rdi, -0x460(%rbp)
callq 0x4590
movq -0x3c0(%rbp), %rdi
movq -0x460(%rbp), %rdx
leaq 0x6189(%rip), %rsi      # 0x2b693
callq 0x52e0
jmp 0x25511
leaq -0x38b(%rbp), %rdi
callq 0x4360
movl $0x1, -0x17c(%rbp)
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x38b(%rbp), %rdi
callq 0x4360
jmp 0x25668
jmp 0x25551
movq $0x0, -0x398(%rbp)
movq -0x398(%rbp), %rax
movq %rax, -0x468(%rbp)
movq -0x98(%rbp), %rdi
addq $0x10, %rdi
callq 0x51d0
movq %rax, %rcx
movq -0x468(%rbp), %rax
cmpq %rcx, %rax
jae 0x255e1
movq -0x98(%rbp), %rdi
movl -0x398(%rbp), %esi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movq %rax, -0x470(%rbp)
jmp 0x255a8
movq -0x470(%rbp), %rax
movq %rax, -0x3a0(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x25dd0
jmp 0x255c8
jmp 0x255ca
movq -0x398(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x398(%rbp)
jmp 0x2555c
jmp 0x255e3
jmp 0x24ddb
leaq -0x3a1(%rbp), %rdi
movq %rdi, -0x478(%rbp)
callq 0x4590
movq -0x3c0(%rbp), %rdi
movq -0x478(%rbp), %rdx
leaq 0x5cbe(%rip), %rsi      # 0x2b2ce
callq 0x52e0
jmp 0x25617
leaq -0x3a1(%rbp), %rdi
callq 0x4360
movl $0x1, -0x17c(%rbp)
jmp 0x2564f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x3a1(%rbp), %rdi
callq 0x4360
jmp 0x25668
leaq -0x70(%rbp), %rdi
callq 0x25e60
movq -0x3b8(%rbp), %rax
addq $0x480, %rsp            # imm = 0x480
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0x25e60
movq -0x88(%rbp), %rdi
callq 0x4580
nopl (%rax)