#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*/ exit(int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int main() {
  int opcion = 0;
  while (1) {
    do {
      system("clear");
      printf("Elige una opción\n");
      printf("***********************************\n");
      printf(" 1) - Sumar dos números\n");
      printf(" 2) - Restar dos números\n");
      printf(" 3) - Dividir dos números\n");
      printf(" 4) - Multiplicar dos números\n");
      printf(" 0) - Salir del programa\n");
      printf("***********************************\n");
      printf("¿Que opción escoges? ");
      scanf("%d", &opcion);
    } while (opcion > 4);
    switch (opcion) {
    case 1:
      system("clear");
      printf("Lanzaríamos la llamada a una función que sumara.\n");
      getchar();
      getchar();
      break;
    case 2:
      system("clear");
      printf("Lanzaríamos la llamada a una función que restara.\n");
      getchar();
      getchar();
      break;
    case 3:
      system("clear");
      printf("Lanzaríamos la llamada a una función que dividiera.\n");
      getchar();
      getchar();
      break;
    case 4:
      system("clear");
      printf("Lanzaríamos la llamada a una función que multiplicara.\n");
      getchar();
      getchar();
      break;
    case 0:
      exit(0);
    default:
      system("clear");
      printf("Ha ocurrido un error en las opciones del menú.\n");
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
jmp    116b <main+0x1b>
lea    0xea2(%rip),%rdi
call   1030 <system@plt>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
lea    0xebc(%rip),%rdi
call   1040 <printf@plt>
lea    0xeca(%rip),%rdi
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
call   1040 <printf@plt>
lea    0xee9(%rip),%rdi
call   1040 <printf@plt>
lea    0xefd(%rip),%rdi
call   1040 <printf@plt>
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
lea    0xeff(%rip),%rdi
call   1040 <printf@plt>
lea    0xf0b(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x4,-0x8(%rbp)
jg     116b <main+0x1b>
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x4,%rax
ja     12d5 <main+0x185>
mov    -0x10(%rbp),%rax
lea    0xde7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdeb(%rip),%rdi
call   1030 <system@plt>
lea    0xec3(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    12f7 <main+0x1a7>
lea    0xdc0(%rip),%rdi
call   1030 <system@plt>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    12f7 <main+0x1a7>
lea    0xd95(%rip),%rdi
call   1030 <system@plt>
lea    0xed6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    12f7 <main+0x1a7>
lea    0xd6a(%rip),%rdi
call   1030 <system@plt>
lea    0xee2(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    12f7 <main+0x1a7>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xd38(%rip),%rdi
call   1030 <system@plt>
lea    0xeea(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    1166 <main+0x16>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe9a(%rip),%r14
jmp    11a5 <main+0x45>
nopl   0x0(%rax)
lea    0xfd9(%rip),%r12
mov    %r14,%rdi
call   1040 <system@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xf21(%rip),%rbp
lea    0xf01(%rip),%r12
lea    0xe60(%rip),%r13
lea    0xe71(%rip),%r15
lea    0x4(%rsp),%rbx
mov    %r14,%rdi
call   1040 <system@plt>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
lea    0xe88(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x4,%eax
jg     11c6 <main+0x66>
ja     127c <main+0x11c>
mov    %eax,%eax
lea    0xdb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
lea    0xf3d(%rip),%r12
jmp    *%rax
lea    0xeca(%rip),%r12
jmp    1187 <main+0x27>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe7a(%rip),%r12
jmp    1187 <main+0x27>
lea    0xd91(%rip),%rdi
call   1040 <system@plt>
lea    0xf38(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@.str.1 = [19 x i8] c"Elige una opci\C3\B3n\0A\00"
@.str.2 = [37 x i8] c"***********************************\0A\00"
@.str.3 = [26 x i8] c" 1) - Sumar dos n\C3\BAmeros\0A\00"
@.str.4 = [27 x i8] c" 2) - Restar dos n\C3\BAmeros\0A\00"
@.str.5 = [28 x i8] c" 3) - Dividir dos n\C3\BAmeros\0A\00"
@.str.6 = [32 x i8] c" 4) - Multiplicar dos n\C3\BAmeros\0A\00"
@.str.7 = [26 x i8] c" 0) - Salir del programa\0A\00"
@.str.8 = [24 x i8] c"\C2\BFQue opci\C3\B3n escoges? \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [52 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que sumara.\0A\00"
@.str.11 = [53 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que restara.\0A\00"
@.str.12 = [55 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que dividiera.\0A\00"
@.str.13 = [58 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que multiplicara.\0A\00"
@.str.14 = [49 x i8] c"Ha ocurrido un error en las opciones del men\C3\BA.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %0, %47
br label %4
4: ; preds = %16, %3
%5 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %2)
br label %16
16: ; preds = %4
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 4
br i1 %18, label %4, label %19
19: ; preds = %16
%20 = load i32, i32* %2
switch i32 %20, label %43 [
i32 1, label %21
i32 2, label %26
i32 3, label %31
i32 4, label %36
i32 0, label %41
]
21: ; preds = %19
%22 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 (...) @getchar()
%25 = call i32 (...) @getchar()
br label %47
26: ; preds = %19
%27 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.11, i64 0, i64 0))
%29 = call i32 (...) @getchar()
%30 = call i32 (...) @getchar()
br label %47
31: ; preds = %19
%32 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%33 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.12, i64 0, i64 0))
%34 = call i32 (...) @getchar()
%35 = call i32 (...) @getchar()
br label %47
36: ; preds = %19
%37 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%38 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.13, i64 0, i64 0))
%39 = call i32 (...) @getchar()
%40 = call i32 (...) @getchar()
br label %47
41: ; preds = %19
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %19
%44 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%45 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0))
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %36, %31, %26, %21
br label %3
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@.str.8 = [24 x i8] c"\C2\BFQue opci\C3\B3n escoges? \00"
@.str.9 = [3 x i8] c"%d\00"
@str = [18 x i8] c"Elige una opci\C3\B3n\00"
@str.16 = [25 x i8] c" 1) - Sumar dos n\C3\BAmeros\00"
@str.17 = [26 x i8] c" 2) - Restar dos n\C3\BAmeros\00"
@str.18 = [27 x i8] c" 3) - Dividir dos n\C3\BAmeros\00"
@str.19 = [31 x i8] c" 4) - Multiplicar dos n\C3\BAmeros\00"
@str.20 = [25 x i8] c" 0) - Salir del programa\00"
@str.21 = [36 x i8] c"***********************************\00"
@str.22 = [57 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que multiplicara.\00"
@str.23 = [54 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que dividiera.\00"
@str.24 = [52 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que restara.\00"
@str.25 = [51 x i8] c"Lanzar\C3\ADamos la llamada a una funci\C3\B3n que sumara.\00"
@str.26 = [48 x i8] c"Ha ocurrido un error en las opciones del men\C3\BA.\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %17, %0
%4 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.21, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.16, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.17, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.18, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.19, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.20, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.21, i64 0, i64 0))
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 4
br i1 %16, label %17, label %18
17: ; preds = %3, %28
br label %3
18: ; preds = %3
switch i32 %15, label %24 [
i32 1, label %28
i32 2, label %19
i32 3, label %20
i32 4, label %21
i32 0, label %22
]
19: ; preds = %18
br label %28
20: ; preds = %18
br label %28
21: ; preds = %18
br label %28
22: ; preds = %18
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %18
%25 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str.26, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %18, %21, %20, %19
%29 = phi i8* [ getelementptr inbounds ([57 x i8], [57 x i8]* @str.22, i64 0, i64 0), %21 ], [ getelementptr inbounds ([54 x i8], [54 x i8]* @str.23, i64 0, i64 0), %20 ], [ getelementptr inbounds ([52 x i8], [52 x i8]* @str.24, i64 0, i64 0), %19 ], [ getelementptr inbounds ([51 x i8], [51 x i8]* @str.25, i64 0, i64 0), %18 ]
%30 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @puts(i8* dereferenceable(1) %29)
%32 = call i32 (...) @getchar()
%33 = call i32 (...) @getchar()
br label %17
}