// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
andq $0x0, -0x60(%rbp)
movq %rdi, -0x30(%rbp)
movq 0x18(%rdi), %rsi
leaq -0xe0(%rbp), %rdi
callq 0x85b0
leaq 0x192fd(%rip), %rsi     # 0x28243
leaq -0xe0(%rbp), %rdi
callq 0xf49a
leaq 0x1ab46(%rip), %rsi     # 0x29a9f
leaq -0xe0(%rbp), %rdi
callq 0xf49a
leaq 0x197e2(%rip), %rsi     # 0x2874e
leaq -0xb0(%rbp), %rdi
xorl %edx, %edx
callq 0xf4d6
movq %rbx, -0xb8(%rbp)
leaq -0x70(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
leaq -0xb0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x11aa6
leaq -0xa8(%rbp), %rdi
callq 0x16ef0
movq -0x70(%rbp), %rbx
leaq -0xb0(%rbp), %r12
leaq -0x180(%rbp), %r14
cmpq -0x68(%rbp), %rbx
je 0xf19f
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
movq %r12, %rdi
leaq 0x1977e(%rip), %rsi     # 0x28756
xorl %edx, %edx
callq 0xf4d6
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x11aa6
movq %rbx, -0xc0(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x16ef0
pushq $0x10
popq %rax
leaq (%rax,%rbp), %rcx
addq $-0xb0, %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0xf006
xorl %ebx, %ebx
movq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r15
je 0xf124
movq %r14, %rdi
movq %r15, %rsi
callq 0x85b0
movq %r14, %rdi
callq 0xa89e
movl %eax, %r13d
movq %r14, %rdi
callq 0x8930
movslq %ebx, %r12
leaq 0x2d499(%rip), %rsi     # 0x3c4f8
testb %r13b, %r13b
jne 0xf082
movq %r15, %rdi
leaq 0x19030(%rip), %rsi     # 0x2809e
xorl %edx, %edx
callq 0x88f0
leaq 0x2d45c(%rip), %rsi     # 0x3c4d8
cmpq $-0x1, %rax
je 0xf0a3
shlq $0x5, %r12
leaq (%r12,%rbp), %rdi
addq $-0xb0, %rdi
callq 0x8240
leaq -0xb0(%rbp), %r12
addq $0x20, %r15
jmp 0xf02d
movq -0x30(%rbp), %rax
movq 0x10(%rax), %r13
leaq -0x160(%rbp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x85b0
movq %r13, %rdi
movq %rbx, %rsi
callq 0xc772
movq %rax, %r13
movq %rbx, %rdi
callq 0x8930
testq %r13, %r13
je 0xf277
movq (%r13), %rax
leaq -0x100(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq *0x10(%rax)
movq %r12, %rax
shlq $0x5, %rax
leaq (%rax,%rbp), %rdi
addq $-0xb0, %rdi
movq %rbx, %rsi
callq 0x84d0
movq %rbx, %rdi
callq 0x8930
incl %r12d
movl %r12d, %ebx
leaq -0xb0(%rbp), %r12
jmp 0xf09d
movq %r12, %rdi
leaq -0x90(%rbp), %rsi
callq 0xc8fa
testb %al, %al
je 0xf169
movq %r12, %rdi
leaq 0x2d397(%rip), %rsi     # 0x3c4d8
callq 0xce8f
testb %al, %al
jne 0xf2e6
leaq -0x90(%rbp), %rdi
leaq 0x2d37c(%rip), %rsi     # 0x3c4d8
callq 0xce8f
testb %al, %al
jne 0xf2e6
pushq $0x20
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0xb0, %rdi
callq 0x8930
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0xf16c
leaq -0x50(%rbp), %rdi
callq 0xdb90
movq -0xc0(%rbp), %rbx
addq $0x20, %rbx
jmp 0xefb8
movq -0xb8(%rbp), %r14
leaq 0x10(%r14), %rbx
leaq 0x195ef(%rip), %rsi     # 0x287a0
movq %rbx, %rdi
callq 0x8390
movq -0x30(%rbp), %rcx
movq 0x18(%rcx), %rsi
movq %rax, %rdi
callq 0x8340
leaq 0x1d564(%rip), %rsi     # 0x2c734
movq %rax, %rdi
callq 0x8390
movq %rax, %rdi
callq 0x81f0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
leaq 0x1d6ab(%rip), %rsi     # 0x2c8a2
movq %rbx, %rdi
callq 0x8390
movq %rax, %rdi
callq 0x81f0
movq -0x30(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0xf250
leaq 0x1958c(%rip), %rsi     # 0x287a5
movq %rbx, %rdi
callq 0x8390
movq %rax, %rdi
callq 0x81f0
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
leaq 0x1d662(%rip), %rsi     # 0x2c8a2
movq %rbx, %rdi
callq 0x8390
movq %rax, %rdi
callq 0x81f0
leaq -0xe0(%rbp), %rdi
callq 0x8930
leaq -0x70(%rbp), %rdi
callq 0xdb90
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x28
popq %rdi
callq 0x8200
movq %rax, %r14
leaq 0x18f98(%rip), %rsi     # 0x28221
leaq -0x100(%rbp), %rdi
movq %r15, %rdx
callq 0xc83b
leaq 0x1d4b6(%rip), %rdx     # 0x2c755
leaq -0x140(%rbp), %rdi
leaq -0x100(%rbp), %rsi
callq 0xc63c
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movb $0x1, %r15b
leaq -0x140(%rbp), %rsi
movq %r14, %rdi
callq 0xc8b2
xorl %r15d, %r15d
leaq 0x2bddb(%rip), %rsi     # 0x3b0b0
leaq -0x29ec(%rip), %rdx     # 0xc8f0
movq %r14, %rdi
callq 0x87a0
jmp 0xf33d
pushq $0x28
popq %rdi
callq 0x8200
movq %rax, %r14
leaq 0x1946e(%rip), %rsi     # 0x28766
leaq -0x120(%rbp), %rdi
leaq -0x100(%rbp), %rdx
callq 0x8180
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movb $0x1, %r15b
leaq -0x120(%rbp), %rsi
movq %r14, %rdi
callq 0xc8b2
xorl %r15d, %r15d
leaq 0x2bd82(%rip), %rsi     # 0x3b0b0
leaq -0x2a45(%rip), %rdx     # 0xc8f0
movq %r14, %rdi
callq 0x87a0
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x16ef0
jmp 0xf40c
jmp 0xf35b
movq %rax, %rbx
jmp 0xf418
movq %rax, %rbx
jmp 0xf40c
movq %rax, %rbx
leaq -0x120(%rbp), %rdi
jmp 0xf3a8
jmp 0xf3b4
movq %rax, %rbx
jmp 0xf403
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x16ef0
jmp 0xf403
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x8930
jmp 0xf3a1
movq %rax, %rbx
movb $0x1, %r15b
leaq -0x100(%rbp), %rdi
callq 0x8930
testb %r15b, %r15b
jne 0xf3b7
jmp 0xf3e5
movq %rax, %rbx
movq %r14, %rdi
callq 0x82f0
jmp 0xf3e5
jmp 0xf3e2
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
jmp 0xf3db
jmp 0xf3e2
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0x8930
jmp 0xf3e5
movq %rax, %rbx
pushq $0x20
popq %r14
leaq (%r14,%rbp), %rdi
addq $-0xb0, %rdi
callq 0x8930
addq $-0x20, %r14
cmpq $-0x20, %r14
jne 0xf3e9
leaq -0x50(%rbp), %rdi
callq 0xdb90
leaq -0xe0(%rbp), %rdi
callq 0x8930
leaq -0x70(%rbp), %rdi
callq 0xdb90
movq %rbx, %rdi
callq 0x87e0
nop