// File: /workspace/github_cpp_makefile_star2_O3/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 $0x178, %rsp            # imm = 0x178
movq %rsi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, -0xd0(%rbp)
movq $0x0, -0xc0(%rbp)
movq %rdi, -0x30(%rbp)
movq 0x18(%rdi), %rax
leaq -0x80(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq -0x90(%rbp), %rdi
callq 0xfbae
leaq 0x1b56e(%rip), %rax     # 0x2b213
movq %rax, -0x70(%rbp)
leaq 0x1b564(%rip), %rax     # 0x2b214
movq %rax, -0x68(%rbp)
movq -0x88(%rbp), %rax
testq %rax, %rax
je 0xfd69
movq -0x90(%rbp), %rsi
xorl %ecx, %ecx
cmpb $0x28, (%rsi,%rcx)
je 0xfcdd
incq %rcx
cmpq %rcx, %rax
jne 0xfccd
jmp 0xfd18
xorl %edx, %edx
testb %dl, %dl
jne 0xfd18
leaq (%rsi,%rcx), %rdx
incq %rdx
addq %rcx, %rsi
movq -0x60(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x70(%rbp), %xmm0
movups %xmm0, (%rsp)
leaq -0x90(%rbp), %rdi
callq 0x1055f
movq -0x90(%rbp), %rsi
movq -0x88(%rbp), %rax
leaq 0x1cd87(%rip), %rcx     # 0x2caa6
movq %rcx, -0x70(%rbp)
leaq 0x1cd7d(%rip), %rcx     # 0x2caa7
movq %rcx, -0x68(%rbp)
testq %rax, %rax
je 0xfd69
cmpb $0x29, (%rsi)
je 0xfd42
incq %rsi
decq %rax
jne 0xfd33
jmp 0xfd69
xorl %eax, %eax
testb %al, %al
jne 0xfd69
leaq 0x1(%rsi), %rdx
movq -0x60(%rbp), %rax
movq %rax, 0x10(%rsp)
movups -0x70(%rbp), %xmm0
movups %xmm0, (%rsp)
leaq -0x90(%rbp), %rdi
callq 0x1055f
leaq 0x1b9e5(%rip), %rsi     # 0x2b755
leaq -0x70(%rbp), %rdi
xorl %edx, %edx
callq 0x104b8
movq %rbx, -0xf8(%rbp)
leaq -0xd0(%rbp), %rdi
leaq -0x90(%rbp), %rsi
leaq -0x70(%rbp), %rdx
xorl %ecx, %ecx
callq 0x12189
leaq -0x68(%rbp), %rdi
callq 0x17bb6
movq -0xd0(%rbp), %r15
cmpq -0xc8(%rbp), %r15
je 0x10057
leaq -0x40(%rbp), %r14
leaq -0x70(%rbp), %r12
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq %r12, %rdi
leaq 0x1b97e(%rip), %rsi     # 0x2b75d
xorl %edx, %edx
callq 0x104b8
leaq -0xb0(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x12189
movq %r15, -0x100(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x17bb6
movl $0x10, %eax
leaq (%rax,%rbp), %rcx
addq $-0x70, %rcx
movq %rcx, -0x10(%rcx)
movq $0x0, -0x8(%rcx)
movb $0x0, (%rcx)
addq $0x20, %rax
cmpq $0x50, %rax
jne 0xfe0f
movq -0xb0(%rbp), %r15
cmpq -0xa8(%rbp), %r15
je 0xff91
xorl %r12d, %r12d
leaq -0x110(%rbp), %rax
movq %rax, -0x120(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x120(%rbp), %rdi
callq 0xfbae
leaq -0x120(%rbp), %rdi
callq 0xa194
movl %eax, %ebx
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0xfe91
callq 0x7350
leaq 0x2c618(%rip), %rsi     # 0x3c4b0
testb %bl, %bl
jne 0xfebf
movl $0x1, %ecx
movq %r15, %rdi
leaq 0x1b1c3(%rip), %rsi     # 0x2b06e
xorl %edx, %edx
callq 0x7790
leaq 0x2c5d7(%rip), %rsi     # 0x3c490
cmpq $-0x1, %rax
je 0xfee9
movslq %r12d, %rax
shlq $0x5, %rax
leaq (%rax,%rbp), %rdi
addq $-0x70, %rdi
callq 0x7230
addq $0x20, %r15
cmpq -0xa8(%rbp), %r15
jne 0xfe47
jmp 0xff91
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rbx
leaq -0x130(%rbp), %rax
movq %rax, -0x140(%rbp)
movq (%r15), %rsi
movq 0x8(%r15), %rdx
addq %rsi, %rdx
leaq -0x140(%rbp), %r13
movq %r13, %rdi
callq 0xfbae
movq %rbx, %rdi
movq %r13, %rsi
callq 0xc924
movq %rax, %rbx
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
cmpq %rax, %rdi
je 0xff3e
callq 0x7350
testq %rbx, %rbx
je 0x101de
movq (%rbx), %rax
leaq -0xf0(%rbp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq *0x10(%rax)
movslq %r12d, %rax
shlq $0x5, %rax
leaq (%rax,%rbp), %rdi
addq $-0x70, %rdi
movq %r13, %rsi
callq 0x74d0
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0xff89
callq 0x7350
incl %r12d
jmp 0xfed3
movq -0x68(%rbp), %rbx
movq -0x48(%rbp), %r15
cmpq %r15, %rbx
jne 0xffb7
testq %rbx, %rbx
je 0x10010
movq -0x70(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq %rbx, %rdx
callq 0x73e0
testl %eax, %eax
je 0x10010
movq 0x2c4da(%rip), %r12     # 0x3c498
cmpq %r12, %rbx
jne 0xffe7
testq %rbx, %rbx
je 0x10237
movq 0x2c4bd(%rip), %rsi     # 0x3c490
movq -0x70(%rbp), %rdi
movq %rbx, %rdx
callq 0x73e0
testl %eax, %eax
je 0x10237
cmpq %r12, %r15
jne 0x10010
testq %r15, %r15
je 0x10237
movq 0x2c494(%rip), %rsi     # 0x3c490
movq -0x50(%rbp), %rdi
movq %r15, %rdx
callq 0x73e0
testl %eax, %eax
je 0x10237
xorl %ebx, %ebx
movq -0x100(%rbp), %r15
leaq -0x70(%rbp), %r12
movq -0x50(%rbp,%rbx), %rdi
leaq (%r14,%rbx), %rax
cmpq %rdi, %rax
je 0x10030
callq 0x7350
addq $-0x20, %rbx
cmpq $-0x40, %rbx
jne 0x1001d
leaq -0xb0(%rbp), %rdi
callq 0xe272
addq $0x20, %r15
cmpq -0xc8(%rbp), %r15
jne 0xfdc0
movq -0xf8(%rbp), %r15
leaq 0x10(%r15), %rbx
leaq 0x1b73e(%rip), %rsi     # 0x2b7a7
movl $0x4, %edx
movq %rbx, %rdi
callq 0x7460
movq -0x30(%rbp), %rax
movq 0x18(%rax), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
movq %rbx, %rdi
callq 0x7460
movq %rax, %r14
leaq 0x1f6b8(%rip), %rsi     # 0x2f74f
movl $0x2, %edx
movq %rax, %rdi
callq 0x7460
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x7360
movsbl %al, %esi
movq %r14, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x72b0
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *(%rax)
leaq 0x1f7db(%rip), %rsi     # 0x2f8bd
movl $0x1, %edx
movq %rbx, %rdi
callq 0x7460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x72b0
movq -0x30(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x101ab
leaq 0x1b680(%rip), %rsi     # 0x2b7ac
movl $0x5, %edx
movq %rbx, %rdi
callq 0x7460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x72b0
movq -0x30(%rbp), %rax
movq 0x28(%rax), %rdi
movq (%rdi), %rax
movq %r15, %rsi
callq *(%rax)
leaq 0x1f746(%rip), %rsi     # 0x2f8bd
movl $0x1, %edx
movq %rbx, %rdi
callq 0x7460
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7360
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7030
movq %rax, %rdi
callq 0x72b0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x101c0
callq 0x7350
leaq -0xd0(%rbp), %rdi
callq 0xe272
addq $0x178, %rsp            # imm = 0x178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x28, %edi
callq 0x71f0
movq %rax, %r12
leaq 0x1afff(%rip), %rsi     # 0x2b1f1
leaq -0xf0(%rbp), %rdi
movq %r15, %rdx
callq 0xca4b
leaq 0x1f568(%rip), %rsi     # 0x2f770
leaq -0xf0(%rbp), %rdi
callq 0x7850
leaq -0x150(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x1029e
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x102af
movl $0x28, %edi
callq 0x71f0
movq %rax, %r15
leaq -0x170(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0x1b516(%rip), %rsi     # 0x2b76d
leaq 0x1b548(%rip), %rdx     # 0x2b7a6
leaq -0x180(%rbp), %rdi
callq 0x1c46a
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movb $0x1, %r13b
leaq -0x180(%rbp), %rsi
movq %r15, %rdi
callq 0xcad6
xorl %r13d, %r13d
leaq 0x2ae23(%rip), %rsi     # 0x3b0b0
leaq -0x376e(%rip), %rdx     # 0xcb26
movq %r15, %rdi
callq 0x7770
jmp 0x102f8
movq %rdx, -0x160(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x150(%rbp)
movq 0x8(%rax), %rdx
leaq -0x160(%rbp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x30(%rbp), %rax
movl 0x8(%rax), %edx
movb $0x1, %r13b
movq %r12, %rdi
callq 0xcad6
xorl %r13d, %r13d
leaq 0x2adc7(%rip), %rsi     # 0x3b0b0
leaq -0x37ca(%rip), %rdx     # 0xcb26
movq %r12, %rdi
callq 0x7770
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x17bb6
jmp 0x10414
jmp 0x10339
movq %rax, %rbx
jmp 0x10429
movq %rax, %rbx
movq -0x180(%rbp), %rdi
cmpq %r12, %rdi
je 0x10327
callq 0x7350
testb %r13b, %r13b
jne 0x10334
jmp 0x103e8
movq %rax, %rbx
movq %r15, %rdi
jmp 0x103aa
movq %rax, %rbx
jmp 0x10414
movq %rax, %rbx
movq -0x160(%rbp), %rdi
cmpq %r15, %rdi
je 0x10355
callq 0x7350
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x1036d
callq 0x7350
testb %r13b, %r13b
jne 0x103a7
jmp 0x103e8
movq %rax, %rbx
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
je 0x103a7
callq 0x7350
jmp 0x103a7
movq %rax, %rbx
jmp 0x10408
movq %rax, %rbx
leaq -0x68(%rbp), %rdi
callq 0x17bb6
jmp 0x10408
movq %rax, %rbx
movq %r12, %rdi
callq 0x72e0
jmp 0x103e8
jmp 0x103e5
movq %rax, %rbx
movq -0x140(%rbp), %rdi
leaq -0x130(%rbp), %rax
jmp 0x103d9
jmp 0x103e5
movq %rax, %rbx
movq -0x120(%rbp), %rdi
leaq -0x110(%rbp), %rax
cmpq %rax, %rdi
je 0x103e8
callq 0x7350
jmp 0x103e8
movq %rax, %rbx
xorl %r15d, %r15d
movq -0x50(%rbp,%r15), %rdi
leaq (%r14,%r15), %rax
cmpq %rdi, %rax
je 0x103fe
callq 0x7350
addq $-0x20, %r15
cmpq $-0x40, %r15
jne 0x103eb
leaq -0xb0(%rbp), %rdi
callq 0xe272
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x10429
callq 0x7350
leaq -0xd0(%rbp), %rdi
callq 0xe272
movq %rbx, %rdi
callq 0x77b0
nop