// File: araujoigor[P]ipp-compiler/./src/include/IWhile.hpp
// Function: IWhile::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[0] = 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);
			}
		}

		fileStream << "while (" << *expression << "){" << endl;
		innerBlock->generateCode(fileStream);
		fileStream << "}" << endl;
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x290, %rsp            # imm = 0x290
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 0x56f3d
leaq 0x670d(%rip), %rsi      # 0x5d651
leaq -0x48(%rbp), %rdi
callq 0x19750
jmp 0x56f4f
leaq 0x7f57(%rip), %rsi      # 0x5eead
leaq -0x48(%rbp), %rdi
callq 0x19750
jmp 0x56f61
leaq 0x6bf4(%rip), %rsi      # 0x5db5c
leaq -0x68(%rbp), %rdi
xorl %edx, %edx
callq 0x19820
jmp 0x56f75
leaq -0x28(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x68(%rbp), %rdx
xorl %ecx, %ecx
callq 0x197b0
jmp 0x56f8a
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 0x56fc3
jmp 0x575f0
leaq -0x90(%rbp), %rdi
callq 0x16110
leaq -0x70(%rbp), %rdi
callq 0x19940
movq %rax, -0x1f0(%rbp)
leaq 0x6b7e(%rip), %rsi      # 0x5db64
leaq -0xa0(%rbp), %rdi
xorl %edx, %edx
callq 0x19820
jmp 0x56ff6
movq -0x1f0(%rbp), %rsi
leaq -0x90(%rbp), %rdi
leaq -0xa0(%rbp), %rdx
xorl %ecx, %ecx
callq 0x197b0
jmp 0x57014
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 0x5703c
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 0x570b9
jmp 0x573f8
leaq -0xf0(%rbp), %rdi
callq 0x19940
movq %rax, %rsi
leaq -0x118(%rbp), %rdi
callq 0x9240
jmp 0x570d6
leaq -0x118(%rbp), %rdi
callq 0xda40
movb %al, -0x209(%rbp)
jmp 0x570ea
leaq -0x118(%rbp), %rdi
callq 0x9c30
movb -0x209(%rbp), %al
testb $0x1, %al
jne 0x57105
jmp 0x571c3
movslq -0xe4(%rbp), %rax
shlq $0x5, %rax
leaq -0xe0(%rbp,%rax), %rdi
leaq 0x2b561(%rip), %rsi     # 0x82680
callq 0x9060
jmp 0x57126
jmp 0x573de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x576cd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x576c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x19880
jmp 0x576c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x575df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x19880
jmp 0x575df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x57593
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x9c30
jmp 0x57593
leaq -0xf0(%rbp), %rdi
callq 0x19960
movq %rax, %rdi
leaq 0x62d3(%rip), %rsi      # 0x5d4ac
xorl %eax, %eax
movl %eax, %edx
callq 0x9be0
cmpq $-0x1, %rax
je 0x5720e
movslq -0xe4(%rbp), %rax
shlq $0x5, %rax
leaq -0xe0(%rbp,%rax), %rdi
leaq 0x2b45e(%rip), %rsi     # 0x82660
callq 0x9060
jmp 0x57209
jmp 0x573de
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 0x5723d
movq -0x218(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x127e0
movq %rax, -0x220(%rbp)
jmp 0x57259
leaq -0x140(%rbp), %rdi
callq 0x9c30
movq -0x220(%rbp), %rax
movq %rax, -0x120(%rbp)
cmpq $0x0, -0x120(%rbp)
jne 0x57397
movb $0x1, -0x181(%rbp)
movl $0x28, %edi
callq 0x9290
movq %rax, -0x228(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x19940
movq %rax, %rdx
leaq 0x6380(%rip), %rsi      # 0x5d62f
leaq -0x180(%rbp), %rdi
callq 0x12960
jmp 0x572bd
leaq 0xa8cb(%rip), %rdx      # 0x61b8f
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x123f0
jmp 0x572d9
movq -0x228(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0x160(%rbp), %rsi
callq 0x12a70
jmp 0x572f8
movq -0x228(%rbp), %rdi
movb $0x0, -0x181(%rbp)
leaq 0x29d4b(%rip), %rsi     # 0x81058
leaq -0x44834(%rip), %rdx    # 0x12ae0
callq 0x9a20
jmp 0x576df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x9c30
jmp 0x57593
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5737b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x5736f
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 0x57386
jmp 0x57392
movq -0x228(%rbp), %rdi
callq 0x9400
jmp 0x57593
movq -0x120(%rbp), %rsi
movq (%rsi), %rax
movq 0x10(%rax), %rax
leaq -0x1a8(%rbp), %rdi
callq *%rax
jmp 0x573b0
leaq -0xe0(%rbp), %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 0x5708a
leaq -0xe0(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
addq $0x20, %rsi
callq 0x12b00
testb $0x1, %al
jne 0x57418
jmp 0x57526
leaq -0xe0(%rbp), %rdi
leaq 0x2b23a(%rip), %rsi     # 0x82660
callq 0x13620
testb $0x1, %al
jne 0x5744f
leaq -0xe0(%rbp), %rdi
addq $0x20, %rdi
leaq 0x2b21f(%rip), %rsi     # 0x82660
callq 0x13620
testb $0x1, %al
jne 0x5744f
jmp 0x57526
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 0x66ec(%rip), %rsi      # 0x5db74
leaq -0x1d0(%rbp), %rdi
callq 0x97c0
jmp 0x57496
movq -0x238(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movl 0x8(%rax), %edx
leaq -0x1d0(%rbp), %rsi
callq 0x12a70
jmp 0x574b5
movq -0x238(%rbp), %rdi
movb $0x0, -0x1d2(%rbp)
leaq 0x29b8e(%rip), %rsi     # 0x81058
leaq -0x449f1(%rip), %rdx    # 0x12ae0
callq 0x9a20
jmp 0x576df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x57501
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 0x57518
jmp 0x57524
movq -0x238(%rbp), %rdi
callq 0x9400
jmp 0x57593
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 0x5753f
leaq -0x90(%rbp), %rdi
callq 0x16130
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
callq 0x19980
movq %rax, -0x1e0(%rbp)
jmp 0x56fa0
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 0x575ac
jmp 0x575df
leaq -0x90(%rbp), %rdi
callq 0x16130
jmp 0x576c4
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0xa463(%rip), %rsi      # 0x61a62
callq 0x9500
movq %rax, -0x270(%rbp)
jmp 0x5760d
movq -0x270(%rbp), %rdi
movq -0x1e8(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x9490
movq %rax, -0x278(%rbp)
jmp 0x5762d
movq -0x278(%rbp), %rdi
leaq 0xa533(%rip), %rsi      # 0x61b6e
callq 0x9500
movq %rax, -0x280(%rbp)
jmp 0x57649
movq -0x280(%rbp), %rdi
movq 0x2a941(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x5765e
movq -0x1e8(%rbp), %rax
movq 0x20(%rax), %rdi
movq -0x10(%rbp), %rsi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x57677
movq -0x10(%rbp), %rdi
addq $0x10, %rdi
leaq 0xa656(%rip), %rsi      # 0x61cdc
callq 0x9500
movq %rax, -0x288(%rbp)
jmp 0x57694
movq -0x288(%rbp), %rdi
movq 0x2a8f6(%rip), %rsi     # 0x81f98
callq 0x95a0
jmp 0x576a9
leaq -0x48(%rbp), %rdi
callq 0x9c30
leaq -0x28(%rbp), %rdi
callq 0x16130
addq $0x290, %rsp            # imm = 0x290
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x9c30
leaq -0x28(%rbp), %rdi
callq 0x16130
movq -0x50(%rbp), %rdi
callq 0x9a90
nop