// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rdx, %r15
movq %rsi, -0x38(%rbp)
movq %rdi, -0x30(%rbp)
movq 0x18(%rdx), %r13
subq 0x10(%rdx), %r13
sarq $0x3, %r13
leaq -0x198(%rbp), %r14
movq %r14, %rdi
callq 0x12b72
xorl %ebx, %ebx
leaq -0xa8(%rbp), %r12
cmpq %rbx, %r13
je 0x12340
movq (%r15), %rax
movq %r15, %rdi
movl %ebx, %esi
callq *0x18(%rax)
movq %rax, -0xa8(%rbp)
movq %r14, %rdi
movq %r12, %rsi
callq 0x132c2
incq %rbx
jmp 0x12319
leaq -0x198(%rbp), %r13
leaq -0xa8(%rbp), %r14
movq -0x168(%rbp), %rax
cmpq -0x188(%rbp), %rax
je 0x12418
cmpq -0x160(%rbp), %rax
jne 0x1237e
movq -0x150(%rbp), %rax
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %r12
movq %r13, %rdi
callq 0x1354a
movl 0x8(%r12), %eax
addl $-0xc, %eax
cmpl $0xd, %eax
ja 0x123dc
leaq 0x34fa(%rip), %rcx      # 0x15898
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x78(%r12), %eax
cmpl $0x1c, %eax
je 0x125d1
cmpl $0x14, %eax
je 0x125f0
cmpl $0x1, %eax
jne 0x1234e
jmp 0x1260f
movq 0x18(%r12), %rax
subq 0x10(%r12), %rax
cmpq $0x9, %rax
jae 0x125b2
xorl %ebx, %ebx
movq 0x18(%r12), %rax
subq 0x10(%r12), %rax
sarq $0x3, %rax
cmpq %rax, %rbx
jae 0x1234e
movq (%r12), %rax
movq %r12, %rdi
movl %ebx, %esi
callq *0x18(%rax)
movq %rax, -0xa8(%rbp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x132c2
incq %rbx
jmp 0x123de
leaq 0x2eaf(%rip), %rsi      # 0x152ce
leaq -0xa8(%rbp), %rdx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x3be4
jmp 0x12723
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
cmpl $0x1, 0x78(%rax)
jne 0x12744
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rbx
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0x128(%rbp), %rdi
movq %rax, %rsi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
leaq -0x128(%rbp), %rdx
movq %rbx, %rsi
callq 0x4172
movq -0x30(%rbp), %r14
leaq -0x128(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0x32f0
jmp 0x1265c
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rbx
movq (%r12), %rax
movq %r12, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0x108(%rbp), %rdi
movq %rax, %rsi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
leaq -0x108(%rbp), %rdx
movq %rbx, %rsi
callq 0x4172
movq -0x30(%rbp), %r14
leaq -0x108(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0x32f0
jmp 0x1265c
movq (%r15), %rax
movq %r15, %rdi
xorl %esi, %esi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
leaq -0xb8(%rbp), %rcx
movq %rcx, -0x10(%rcx)
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x1266d
movq %rdx, -0xc8(%rbp)
movq -0x98(%rbp), %rcx
movq %rcx, -0xb8(%rbp)
jmp 0x12673
movq (%r12), %rax
pushq $0x1
popq %rsi
movq %r12, %rdi
callq *0x18(%rax)
addq $0x58, %rax
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
callq 0xb24a
movq -0x30(%rbp), %r14
leaq 0x10(%r14), %rcx
movq %rcx, (%r14)
leaq -0x98(%rbp), %rax
movq -0x10(%rax), %rdx
cmpq %rax, %rdx
je 0x126fd
movq %rdx, (%r14)
movq -0x98(%rbp), %rcx
movq %rcx, 0x10(%r14)
jmp 0x12703
leaq 0x30da(%rip), %rsi      # 0x15693
leaq -0xa8(%rbp), %rdx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x3be4
jmp 0x12723
leaq 0x3653(%rip), %rsi      # 0x15c2b
leaq -0xa8(%rbp), %rdx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x3be4
jmp 0x12723
leaq 0x30a0(%rip), %rsi      # 0x15697
leaq -0xa8(%rbp), %rdx
movq -0x30(%rbp), %r14
movq %r14, %rdi
callq 0x3be4
jmp 0x12723
addq $0x58, %r12
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rbx
leaq -0xe8(%rbp), %rdi
movq %r12, %rsi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
leaq -0xe8(%rbp), %rdx
movq %rbx, %rsi
callq 0x4172
movq -0x30(%rbp), %r14
leaq -0xe8(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
callq 0x44c8
jmp 0x12723
movups (%rax), %xmm0
movups %xmm0, (%rcx)
leaq -0xa8(%rbp), %rdi
movq 0x8(%rdi), %rcx
leaq -0xc8(%rbp), %r14
movq %rcx, 0x8(%r14)
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x135f8
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rbx
leaq -0x148(%rbp), %rdi
movq %r14, %rsi
callq 0x32f0
movq -0x30(%rbp), %r14
leaq -0xa8(%rbp), %rdi
leaq -0x148(%rbp), %rdx
movq %rbx, %rsi
callq 0x4172
leaq -0x148(%rbp), %rdi
callq 0x3110
leaq -0x80(%rbp), %rsi
movq %r14, %rdi
callq 0x32f0
leaq -0xa8(%rbp), %rdi
callq 0x44c8
leaq -0xc8(%rbp), %rdi
callq 0x3110
jmp 0x12723
movups (%rax), %xmm0
movups %xmm0, (%rcx)
leaq -0xa8(%rbp), %rdi
movq 0x8(%rdi), %rcx
movq %rcx, 0x8(%r14)
movq %rax, (%rdi)
andq $0x0, 0x8(%rdi)
movb $0x0, 0x10(%rdi)
callq 0x135f8
leaq -0x198(%rbp), %rdi
callq 0x12ec0
movq %r14, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x50
popq %rdi
callq 0x3140
movq %rax, %r14
leaq 0x34c9(%rip), %rsi      # 0x15c1f
leaq -0x1b8(%rbp), %rdi
leaq -0xa8(%rbp), %rdx
callq 0x3be4
movb $0x1, %r15b
pushq $-0x1
popq %rdx
leaq -0x1b8(%rbp), %rcx
movq %r14, %rdi
movl %edx, %esi
callq 0x4e88
xorl %r15d, %r15d
leaq 0xb606(%rip), %rsi      # 0x1dd90
leaq -0xd859(%rip), %rdx     # 0x4f38
movq %r14, %rdi
callq 0x33f0
jmp 0x12820
movq %rax, %rbx
leaq -0xe8(%rbp), %rdi
jmp 0x1283b
jmp 0x12850
jmp 0x12850
jmp 0x12850
jmp 0x12850
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x44c8
jmp 0x127e8
movq %rax, %rbx
leaq -0x148(%rbp), %rdi
callq 0x3110
jmp 0x127e8
jmp 0x12820
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
jmp 0x1283b
movq %rax, %rbx
leaq -0x108(%rbp), %rdi
jmp 0x1283b
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x3110
testb %r15b, %r15b
jne 0x12816
jmp 0x12853
movq %rax, %rbx
movq %r14, %rdi
callq 0x31b0
jmp 0x12853
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x44c8
jmp 0x12853
movq %rax, %rbx
leaq -0x128(%rbp), %rdi
callq 0x3110
jmp 0x12853
jmp 0x12850
jmp 0x12850
jmp 0x12850
jmp 0x12850
jmp 0x12850
jmp 0x12850
jmp 0x12850
movq %rax, %rbx
leaq -0x198(%rbp), %rdi
callq 0x12ec0
movq %rbx, %rdi
callq 0x3410
nop