#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 */
float get_num(int);
int menu();
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int op = menu();
  float a, b;
  while (op != 5) {
    switch (op) {
    case 1:
      a = get_num(1);
      b = get_num(2);
      printf("%.2f + %.2f = %.2f\n\n", a, b, a + b);
      break;
    case 2:
      a = get_num(1);
      b = get_num(2);
      printf("%.2f - %.2f = %.2f\n\n", a, b, a - b);
      break;
    case 3:
      a = get_num(1);
      b = get_num(2);
      printf("%.2f * %.2f = %.2f\n\n", a, b, a * b);
      break;
    case 4:
      a = get_num(1);
      b = get_num(2);
      if (b != 0)
        printf("%.2f / %.2f = %.2f\n\n", a, b, a / b);
      else
        printf("Numero invalido, division entre cero.\n\n");
      break;
    default:
      printf("La opcion %d no es reconocida.\n\n", op);
      break;
    }
    op = menu();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <menu@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x5,-0x8(%rbp)
je     130f <main+0x1df>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     12ef <main+0x1bf>
mov    -0x18(%rbp),%rax
lea    0xe8d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0xc(%rbp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
addss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe4f(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    1300 <main+0x1d0>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0xc(%rbp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
subss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe13(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    1300 <main+0x1d0>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0xc(%rbp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdd7(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    1300 <main+0x1d0>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0xc(%rbp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    12a9 <main+0x179>
jp     12a9 <main+0x179>
jmp    12dc <main+0x1ac>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
divss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd7f(%rip),%rdi
mov    $0x3,%al
call   1050 <printf@plt>
jmp    12ea <main+0x1ba>
lea    0xd81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1300 <main+0x1d0>
mov    -0x8(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <menu@plt>
mov    %eax,-0x8(%rbp)
jmp    1149 <main+0x19>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf1a(%rip),%r14
lea    0xeab(%rip),%rbp
lea    0xeb8(%rip),%r15
lea    0xec6(%rip),%r12
lea    0xed4(%rip),%rbx
lea    0xee2(%rip),%r13
jmp    11ba <main+0x7a>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
mulss  %xmm0,%xmm2
cvtss2sd %xmm2,%xmm2
mov    %rbx,%rdi
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <menu@plt>
lea    -0x1(%rax),%ecx
cmp    $0x4,%ecx
ja     120e <main+0xce>
movslq 0x0(%rbp,%rcx,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
addss  %xmm0,%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r15,%rdi
jmp    11b0 <main+0x70>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11ba <main+0x7a>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
call   1030 <get_num@plt>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
subss  %xmm0,%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r12,%rdi
jmp    11b0 <main+0x70>
mov    $0x1,%edi
call   1030 <get_num@plt>
movss  %xmm0,0x4(%rsp)
mov    $0x2,%edi
call   1030 <get_num@plt>
ucomiss 0xd85(%rip),%xmm0
jne    127f <main+0x13f>
jnp    12a3 <main+0x163>
movss  0x4(%rsp),%xmm2
xorps  %xmm3,%xmm3
cvtss2sd %xmm2,%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
divss  %xmm0,%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r13,%rdi
jmp    11b0 <main+0x70>
lea    0xde3(%rip),%rdi
call   1040 <puts@plt>
jmp    11ba <main+0x7a>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"%.2f + %.2f = %.2f\0A\0A\00"
@.str.1 = [21 x i8] c"%.2f - %.2f = %.2f\0A\0A\00"
@.str.2 = [21 x i8] c"%.2f * %.2f = %.2f\0A\0A\00"
@.str.3 = [21 x i8] c"%.2f / %.2f = %.2f\0A\0A\00"
@.str.4 = [40 x i8] c"Numero invalido, division entre cero.\0A\0A\00"
@.str.5 = [33 x i8] c"La opcion %d no es reconocida.\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (...) @menu()
store i32 %5, i32* %2
br label %6
6: ; preds = %68, %0
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 5
br i1 %8, label %9, label %70
9: ; preds = %6
%10 = load i32, i32* %2
switch i32 %10, label %65 [
i32 1, label %11
i32 2, label %23
i32 3, label %35
i32 4, label %47
]
11: ; preds = %9
%12 = call float @get_num(i32 1)
store float %12, float* %3
%13 = call float @get_num(i32 2)
store float %13, float* %4
%14 = load float, float* %3
%15 = fpext float %14 to double
%16 = load float, float* %4
%17 = fpext float %16 to double
%18 = load float, float* %3
%19 = load float, float* %4
%20 = fadd float %18, %19
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %15, double %17, double %21)
br label %68
23: ; preds = %9
%24 = call float @get_num(i32 1)
store float %24, float* %3
%25 = call float @get_num(i32 2)
store float %25, float* %4
%26 = load float, float* %3
%27 = fpext float %26 to double
%28 = load float, float* %4
%29 = fpext float %28 to double
%30 = load float, float* %3
%31 = load float, float* %4
%32 = fsub float %30, %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), double %27, double %29, double %33)
br label %68
35: ; preds = %9
%36 = call float @get_num(i32 1)
store float %36, float* %3
%37 = call float @get_num(i32 2)
store float %37, float* %4
%38 = load float, float* %3
%39 = fpext float %38 to double
%40 = load float, float* %4
%41 = fpext float %40 to double
%42 = load float, float* %3
%43 = load float, float* %4
%44 = fmul float %42, %43
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %39, double %41, double %45)
br label %68
47: ; preds = %9
%48 = call float @get_num(i32 1)
store float %48, float* %3
%49 = call float @get_num(i32 2)
store float %49, float* %4
%50 = load float, float* %4
%51 = fcmp une float %50, 0.000000e+00
br i1 %51, label %52, label %62
52: ; preds = %47
%53 = load float, float* %3
%54 = fpext float %53 to double
%55 = load float, float* %4
%56 = fpext float %55 to double
%57 = load float, float* %3
%58 = load float, float* %4
%59 = fdiv float %57, %58
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %54, double %56, double %60)
br label %64
62: ; preds = %47
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %62, %52
br label %68
65: ; preds = %9
%66 = load i32, i32* %2
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %65, %64, %35, %23, %11
%69 = call i32 (...) @menu()
store i32 %69, i32* %2
br label %6
70: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"%.2f + %.2f = %.2f\0A\0A\00"
@.str.1 = [21 x i8] c"%.2f - %.2f = %.2f\0A\0A\00"
@.str.2 = [21 x i8] c"%.2f * %.2f = %.2f\0A\0A\00"
@.str.3 = [21 x i8] c"%.2f / %.2f = %.2f\0A\0A\00"
@.str.5 = [33 x i8] c"La opcion %d no es reconocida.\0A\0A\00"
@str = [39 x i8] c"Numero invalido, division entre cero.\0A\00"
define i32 @main() {
br label %1
1: ; preds = %37, %0
%2 = tail call i32 (...) @menu()
switch i32 %2, label %40 [
i32 5, label %42
i32 1, label %3
i32 2, label %11
i32 3, label %19
i32 4, label %27
]
3: ; preds = %1
%4 = tail call float @get_num(i32 1)
%5 = tail call float @get_num(i32 2)
%6 = fpext float %4 to double
%7 = fpext float %5 to double
%8 = fadd float %4, %5
%9 = fpext float %8 to double
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), double %6, double %7, double %9)
br label %37
11: ; preds = %1
%12 = tail call float @get_num(i32 1)
%13 = tail call float @get_num(i32 2)
%14 = fpext float %12 to double
%15 = fpext float %13 to double
%16 = fsub float %12, %13
%17 = fpext float %16 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), double %14, double %15, double %17)
br label %37
19: ; preds = %1
%20 = tail call float @get_num(i32 1)
%21 = tail call float @get_num(i32 2)
%22 = fpext float %20 to double
%23 = fpext float %21 to double
%24 = fmul float %20, %21
%25 = fpext float %24 to double
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), double %22, double %23, double %25)
br label %37
27: ; preds = %1
%28 = tail call float @get_num(i32 1)
%29 = tail call float @get_num(i32 2)
%30 = fcmp une float %29, 0.000000e+00
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = fpext float %28 to double
%33 = fpext float %29 to double
%34 = fdiv float %28, %29
%35 = fpext float %34 to double
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %32, double %33, double %35)
br label %37
37: ; preds = %31, %38, %40, %19, %11, %3
br label %1
38: ; preds = %27
%39 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %37
40: ; preds = %1
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %2)
br label %37
42: ; preds = %1
ret i32 0
}