#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int menu() {
  int op;
  printf("Simulador Arquitetura MIPS\n");
  printf("Menu de Operacoes Simulador\n");
  printf("[1]step:\n\tExecutar Instrucao a Instrucao do programa\n");
  printf("[2]run:\n\tExecutar programa(Sem parada)\n");
  printf(
      "[3]dump_mem:\n\tImprimir Regiao da Memoria(Enderecos em Hexadecimal)\n");
  printf("[4]dum_reg:\n\tImprimir Registradores\n");
  printf("[5]Informacoes sobre o Simulador\n");
  printf("[6]Encerrar\n");
  printf("\n");
  printf("Opcao: \n");
  scanf("%d", &op);
  return op;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
call   1030 <printf@plt>
lea    0xf38(%rip),%rdi
call   1030 <printf@plt>
lea    0xf70(%rip),%rdi
call   1030 <printf@plt>
lea    0xf89(%rip),%rdi
call   1030 <printf@plt>
lea    0xf9f(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa7(%rip),%rdi
call   1030 <printf@plt>
lea    0xf94(%rip),%rdi
call   1030 <printf@plt>
lea    0xf91(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %rax
lea    0xecb(%rip),%rdi
call   1040 <puts@plt>
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
lea    0xeea(%rip),%rdi
call   1040 <puts@plt>
lea    0xf13(%rip),%rdi
call   1040 <puts@plt>
lea    0xf2e(%rip),%rdi
call   1040 <puts@plt>
lea    0xf65(%rip),%rdi
call   1040 <puts@plt>
lea    0xf7d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf92(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xf88(%rip),%rdi
call   1040 <puts@plt>
lea    0xe52(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Simulador Arquitetura MIPS\0A\00"
@.str.1 = [29 x i8] c"Menu de Operacoes Simulador\0A\00"
@.str.2 = [54 x i8] c"[1]step:\0A\09Executar Instrucao a Instrucao do programa\0A\00"
@.str.3 = [40 x i8] c"[2]run:\0A\09Executar programa(Sem parada)\0A\00"
@.str.4 = [68 x i8] c"[3]dump_mem:\0A\09Imprimir Regiao da Memoria(Enderecos em Hexadecimal)\0A\00"
@.str.5 = [37 x i8] c"[4]dum_reg:\0A\09Imprimir Registradores\0A\00"
@.str.6 = [34 x i8] c"[5]Informacoes sobre o Simulador\0A\00"
@.str.7 = [13 x i8] c"[6]Encerrar\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [9 x i8] c"Opcao: \0A\00"
@.str.10 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.9, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %1)
%13 = load i32, i32* %1
ret i32 %13
}

LLVM IR (-O2):
@.str.10 = [3 x i8] c"%d\00"
@str = [27 x i8] c"Simulador Arquitetura MIPS\00"
@str.11 = [28 x i8] c"Menu de Operacoes Simulador\00"
@str.12 = [53 x i8] c"[1]step:\0A\09Executar Instrucao a Instrucao do programa\00"
@str.13 = [39 x i8] c"[2]run:\0A\09Executar programa(Sem parada)\00"
@str.14 = [67 x i8] c"[3]dump_mem:\0A\09Imprimir Regiao da Memoria(Enderecos em Hexadecimal)\00"
@str.15 = [36 x i8] c"[4]dum_reg:\0A\09Imprimir Registradores\00"
@str.16 = [33 x i8] c"[5]Informacoes sobre o Simulador\00"
@str.17 = [12 x i8] c"[6]Encerrar\00"
@str.18 = [8 x i8] c"Opcao: \00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.12, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.13, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.14, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.15, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.16, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.17, i64 0, i64 0))
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.18, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
ret i32 %14
}