// File: araujoigor[P]ipp-compiler/./src/include/IFlowControl.hpp
// Function: IFlowControl::generateCode(std::basic_fstream<char, std::char_traits<char>>&)
void generateCode(std::fstream& fileStream) {
		//Variavel para armazenamento dos tokens que iremos gerar através da quebra
		//da expressao do if pelos tokens '&&' e '||'
		vector<string> tokens;

		//Armazenamos a expressao original temporariamente, para processamento
		string tempStr = *expression;

		//eliminamos todos os parenteses para analise
		boost::erase_all(tempStr, "(");
		boost::erase_all(tempStr, ")");

		//Quebramos a expressao pelos operadores || e &&
		boost::algorithm::split_regex(tokens, tempStr, boost::regex("&&|\\|\\|"));

		//Iteramos sobre as sub expressões para dividir os elementos da expressão e procurar por comparações
		//incorretas e/ou variaveis não declaradas
		for(auto it = tokens.begin(); it != tokens.end(); it++){
			//Vetor de strings para armazenamento das subexpressões
			vector<string> varsExps;

			//Quebramos cada subexpressão pelos operadores de comparação
			boost::algorithm::split_regex(varsExps, *it, boost::regex("==|!=|<|>|<=|>="));
			string type[2];
			int i = 0;

			//Obtemos o tipo de cada operando das comparações
			for(auto it2 = varsExps.begin(); it2 != varsExps.end(); it2++){
				//Se for um numeri=o
				if(IMath::isNumber(*it2)){
					type[i] = IReal::myType;
					continue;
				}

				//Se for uma string
				if(it2->find("\"") != string::npos){
					type[i] = IString::myType;
					continue;
				}

				IData *data = ownerBlock->getLocalVariable(*it2);

				//Se for uma variavel
				if(data == NULL){
					//Variavel nao declarada, gera um erro
					throw ISourceErrorException("Variavel " + *it2 + " nao declarada.", myLine);
				}else{
					type[i] = data->getType();
				}

				i++;
			}

			//Caso a comparação seja de tipagem errada, gera-se um erro
			if(type[0] != type[1] && (type[0] == IString::myType || type[1] == IString::myType)){
				throw ISourceErrorException("Impossivel comparar uma variavel numerica com uma string.", myLine);
			}
		}

		//Se tudo estiver certo, traduzimos o código
		fileStream << "if (" << *expression << "){" << endl;
		ifBlock->generateCode(fileStream);
		fileStream << "}" << endl;

		if(elseBlock != NULL){
			fileStream << "else{" << endl;
			elseBlock->generateCode(fileStream);
			fileStream << "}" << endl;
		}

	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1e8(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x16110
movq -0x1e8(%rbp), %rax
movq 0x18(%rax), %rsi
leaq -0x48(%rbp), %rdi
callq 0x9240
jmp 0x18e4d
leaq 0x447fd(%rip), %rsi     # 0x5d651
leaq -0x48(%rbp), %rdi
callq 0x19750
jmp 0x18e5f
leaq 0x46047(%rip), %rsi     # 0x5eead
leaq -0x48(%rbp), %rdi
callq 0x19750
jmp 0x18e71
leaq 0x44ce4(%rip), %rsi     # 0x5db5c
leaq -0x68(%rbp), %rdi
xorl %edx, %edx
callq 0x19820
jmp 0x18e85
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
xorl %ecx, %ecx
callq 0x197b0
jmp 0x18e9a
leaq -0x68(%rbp), %rdi
callq 0x19880
leaq -0x28(%rbp), %rdi
callq 0x198a0
movq %rax, -0x70(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x19910
movq %rax, -0x78(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0x78(%rbp), %rsi
callq 0x198d0
testb $0x1, %al
jne 0x18ed3
jmp 0x1950e
leaq -0x90(%rbp), %rdi
callq 0x16110
leaq -0x70(%rbp), %rdi
callq 0x19940
movq %rax, -0x1f0(%rbp)
leaq 0x44c6e(%rip), %rsi     # 0x5db64
leaq -0xa0(%rbp), %rdi
xorl %edx, %edx
callq 0x19820
jmp 0x18f06
movq -0x1f0(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x197b0
jmp 0x18f24
leaq -0xa0(%rbp), %rdi
callq 0x19880
leaq -0xe0(%rbp), %rax
movq %rax, %rcx
addq $0x40, %rcx
movq %rcx, -0x200(%rbp)
movq %rax, -0x1f8(%rbp)
movq -0x1f8(%rbp), %rdi
movq %rdi, -0x208(%rbp)
callq 0x97d0
movq -0x208(%rbp), %rax
movq -0x200(%rbp), %rcx
addq $0x20, %rax
cmpq %rcx, %rax
movq %rax, -0x1f8(%rbp)
jne 0x18f4c
movl $0x0, -0xe4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x198a0
movq %rax, -0xf0(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x19910
movq %rax, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x198d0
testb $0x1, %al
jne 0x18fc9
jmp 0x19316
leaq -0xf0(%rbp), %rdi
callq 0x19940
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
callq 0x9240
jmp 0x18fe6
leaq -0x118(%rbp), %rdi
callq 0xda40
movb %al, -0x209(%rbp)
jmp 0x18ffa
leaq -0x118(%rbp), %rdi
callq 0x9c30
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x19015
jmp 0x190d3
movslq -0xe4(%rbp), %rax
shlq $0x5, %rax
leaq -0xe0(%rbp,%rax), %rdi
leaq 0x69651(%rip), %rsi     # 0x82680
callq 0x9060
jmp 0x19036
jmp 0x192fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x19678
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1966f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x19880
jmp 0x1966f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x194fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x19880
jmp 0x194fd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x194b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x9c30
jmp 0x194b1
leaq -0xf0(%rbp), %rdi
callq 0x19960
movq %rax, %rdi
leaq 0x443c3(%rip), %rsi     # 0x5d4ac
xorl %eax, %eax
movl %eax, %edx
callq 0x9be0
cmpq $-0x1, %rax
je 0x1911e
movslq -0xe4(%rbp), %rax
shlq $0x5, %rax
leaq -0xe0(%rbp,%rax), %rdi
leaq 0x6954e(%rip), %rsi     # 0x82660
callq 0x9060
jmp 0x19119
jmp 0x192fc
movq -0x1e8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x218(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x19940
movq %rax, %rsi
leaq -0x140(%rbp), %rdi
callq 0x9240
jmp 0x1914d
movq -0x218(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x127e0
movq %rax, -0x220(%rbp)
jmp 0x19169
leaq -0x140(%rbp), %rdi
callq 0x9c30
movq -0x220(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
jne 0x192a7
movb $0x1, -0x181(%rbp)
movl $0x28, %edi
callq 0x9290
movq %rax, -0x228(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x19940
movq %rax, %rdx
leaq 0x44470(%rip), %rsi     # 0x5d62f
leaq -0x180(%rbp), %rdi
callq 0x12960
jmp 0x191cd
leaq 0x489bb(%rip), %rdx     # 0x61b8f
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x123f0
jmp 0x191e9
movq -0x228(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0x160(%rbp), %rsi
callq 0x12a70
jmp 0x19208
movq -0x228(%rbp), %rdi
movb $0x0, -0x181(%rbp)
leaq 0x67e3b(%rip), %rsi     # 0x81058
leaq -0x6744(%rip), %rdx     # 0x12ae0
callq 0x9a20
jmp 0x1968a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x9c30
jmp 0x194b1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1928b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1927f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x160(%rbp), %rdi
callq 0x9c30
leaq -0x180(%rbp), %rdi
callq 0x9c30
testb $0x1, -0x181(%rbp)
jne 0x19296
jmp 0x192a2
movq -0x228(%rbp), %rdi
callq 0x9400
jmp 0x194b1
movq -0x120(%rbp), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x1a8(%rbp), %rdi
callq *%rax
jmp 0x192c0
movslq -0xe4(%rbp), %rax
leaq -0xe0(%rbp), %rdi
shlq $0x5, %rax
addq %rax, %rdi
leaq -0x1a8(%rbp), %rsi
callq 0x96a0
leaq -0x1a8(%rbp), %rdi
callq 0x9c30
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
leaq -0xf0(%rbp), %rdi
xorl %esi, %esi
callq 0x19980
movq %rax, -0x1b0(%rbp)
jmp 0x18f9a
leaq -0xe0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
addq $0x20, %rsi
callq 0x12b00
testb $0x1, %al
jne 0x19336
jmp 0x19444
leaq -0xe0(%rbp), %rdi
leaq 0x6931c(%rip), %rsi     # 0x82660
callq 0x13620
testb $0x1, %al
jne 0x1936d
leaq -0xe0(%rbp), %rdi
addq $0x20, %rdi
leaq 0x69301(%rip), %rsi     # 0x82660
callq 0x13620
testb $0x1, %al
jne 0x1936d
jmp 0x19444
movb $0x1, -0x1d2(%rbp)
movl $0x28, %edi
callq 0x9290
movq %rax, -0x238(%rbp)
leaq -0x1d1(%rbp), %rdi
movq %rdi, -0x230(%rbp)
callq 0x9ab0
movq -0x230(%rbp), %rdx
leaq 0x447ce(%rip), %rsi     # 0x5db74
leaq -0x1d0(%rbp), %rdi
callq 0x97c0
jmp 0x193b4
movq -0x238(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0x1d0(%rbp), %rsi
callq 0x12a70
jmp 0x193d3
movq -0x238(%rbp), %rdi
movb $0x0, -0x1d2(%rbp)
leaq 0x67c70(%rip), %rsi     # 0x81058
leaq -0x690f(%rip), %rdx     # 0x12ae0
callq 0x9a20
jmp 0x1968a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x1941f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x9c30
leaq -0x1d1(%rbp), %rdi
callq 0x95e0
testb $0x1, -0x1d2(%rbp)
jne 0x19436
jmp 0x19442
movq -0x238(%rbp), %rdi
callq 0x9400
jmp 0x194b1
leaq -0xe0(%rbp), %rax
movq %rax, -0x248(%rbp)
addq $0x40, %rax
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x250(%rbp)
callq 0x9c30
movq -0x248(%rbp), %rcx
movq -0x250(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x240(%rbp)
jne 0x1945d
leaq -0x90(%rbp), %rdi
callq 0x16130
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x19980
movq %rax, -0x1e0(%rbp)
jmp 0x18eb0
leaq -0xe0(%rbp), %rax
movq %rax, -0x260(%rbp)
addq $0x40, %rax
movq %rax, -0x258(%rbp)
movq -0x258(%rbp), %rdi
addq $-0x20, %rdi
movq %rdi, -0x268(%rbp)
callq 0x9c30
movq -0x260(%rbp), %rcx
movq -0x268(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x258(%rbp)
jne 0x194ca
jmp 0x194fd
leaq -0x90(%rbp), %rdi
callq 0x16130
jmp 0x1966f
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0x44691(%rip), %rsi     # 0x5dbae
callq 0x9500
movq %rax, -0x270(%rbp)
jmp 0x1952b
movq -0x270(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x9490
movq %rax, -0x278(%rbp)
jmp 0x1954b
movq -0x278(%rbp), %rdi
leaq 0x48615(%rip), %rsi     # 0x61b6e
callq 0x9500
movq %rax, -0x280(%rbp)
jmp 0x19567
movq -0x280(%rbp), %rdi
movq 0x68a23(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x1957c
movq -0x1e8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x19595
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0x48738(%rip), %rsi     # 0x61cdc
callq 0x9500
movq %rax, -0x288(%rbp)
jmp 0x195b2
movq -0x288(%rbp), %rdi
movq 0x689d8(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x195c7
movq -0x1e8(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x19654
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0x445cf(%rip), %rsi     # 0x5dbb3
callq 0x9500
movq %rax, -0x290(%rbp)
jmp 0x195f2
movq -0x290(%rbp), %rdi
movq 0x68998(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x19607
movq -0x1e8(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x19620
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0x486ad(%rip), %rsi     # 0x61cdc
callq 0x9500
movq %rax, -0x298(%rbp)
jmp 0x1963d
movq -0x298(%rbp), %rdi
movq 0x6894d(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x19652
jmp 0x19654
leaq -0x48(%rbp), %rdi
callq 0x9c30
leaq -0x28(%rbp), %rdi
callq 0x16130
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x9c30
leaq -0x28(%rbp), %rdi
callq 0x16130
movq -0x50(%rbp), %rdi
callq 0x9a90
nopw (%rax,%rax)