#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 getch();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf_s(char *, float *);
int /*<<< orphan*/ system(char *);
main() {
  int num = 0;
  float a = 0, b = 0;
  printf(
      "Dame los valores a y b para hacer la operacion que elegiras despues\n");
  printf("a: ");
  scanf_s("%f", &a);
  printf("b: ");
  scanf_s("%f", &b);
  printf("\n");
  printf("Que deseas? (Pon el signo)\n");
  printf("+ Sumar\n");
  printf("- Restar\n");
  printf("* Multiplicar\n");
  printf("/ Dividir\n");
  printf("\n");
  switch (getch()) {
  case 43:
    printf("%.2f+%.2f=%.2f\n", a, b, a + b);
    break;
  case 45:
    printf("%.2f-%.2f=%.2f\n", a, b, a - b);
    break;
  case 42:
    printf("%.2f*%.2f=%.2f\n", a, b, a * b);
    break;
  case 47:
    printf("%.2f/%.2f=%.2f\n", a, b, a / b);
    break;
  default:
    break;
  }
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xead(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xede(%rip),%rdi
call   1040 <printf@plt>
lea    0xed6(%rip),%rdi
mov    %rdi,-0x30(%rbp)
lea    -0xc(%rbp),%rsi
call   1060 <scanf_s@plt>
mov    -0x19(%rbp),%al
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf_s@plt>
mov    -0x19(%rbp),%al
lea    0xec4(%rip),%rdi
mov    %rdi,-0x28(%rbp)
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xea4(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x19(%rbp),%al
call   1040 <printf@plt>
mov    -0x19(%rbp),%al
call   1050 <getch@plt>
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1318 <main+0x1d8>
mov    -0x18(%rbp),%rax
lea    0xdbd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
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    0xe3e(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    131d <main+0x1dd>
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    0xe1b(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    131d <main+0x1dd>
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    0xdf8(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    131d <main+0x1dd>
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    0xdd5(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    131d <main+0x1dd>
jmp    131d <main+0x1dd>
lea    0xdcd(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe86(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf_s@plt>
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <scanf_s@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xede(%rip),%rdi
call   1040 <puts@plt>
lea    0xeed(%rip),%rdi
call   1040 <puts@plt>
lea    0xee9(%rip),%rdi
call   1040 <puts@plt>
lea    0xee6(%rip),%rdi
call   1040 <puts@plt>
lea    0xee8(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1070 <getch@plt>
add    $0xffffffd6,%eax
cmp    $0x5,%eax
ja     12ca <main+0x16a>
lea    0xdd8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
mulss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdef(%rip),%rdi
jmp    12c3 <main+0x163>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
addss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdaa(%rip),%rdi
jmp    12c3 <main+0x163>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
subss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd95(%rip),%rdi
jmp    12c3 <main+0x163>
movss  0xc(%rsp),%xmm2
cvtss2sd %xmm2,%xmm0
movss  0x8(%rsp),%xmm3
cvtss2sd %xmm3,%xmm1
divss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd90(%rip),%rdi
mov    $0x3,%al
call   1060 <printf@plt>
lea    0xd92(%rip),%rdi
call   1050 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [69 x i8] c"Dame los valores a y b para hacer la operacion que elegiras despues\0A\00"
@.str.1 = [4 x i8] c"a: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"b: \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [28 x i8] c"Que deseas? (Pon el signo)\0A\00"
@.str.6 = [9 x i8] c"+ Sumar\0A\00"
@.str.7 = [10 x i8] c"- Restar\0A\00"
@.str.8 = [15 x i8] c"* Multiplicar\0A\00"
@.str.9 = [11 x i8] c"/ Dividir\0A\00"
@.str.10 = [16 x i8] c"%.2f+%.2f=%.2f\0A\00"
@.str.11 = [16 x i8] c"%.2f-%.2f=%.2f\0A\00"
@.str.12 = [16 x i8] c"%.2f*%.2f=%.2f\0A\00"
@.str.13 = [16 x i8] c"%.2f/%.2f=%.2f\0A\00"
@.str.14 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store i32 0, i32* %2
store float 0.000000e+00, float* %3
store float 0.000000e+00, float* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %3)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (...) @getch()
switch i32 %17, label %58 [
i32 43, label %18
i32 45, label %28
i32 42, label %38
i32 47, label %48
]
18: ; preds = %0
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = load float, float* %3
%24 = load float, float* %4
%25 = fadd float %23, %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), double %20, double %22, double %26)
br label %59
28: ; preds = %0
%29 = load float, float* %3
%30 = fpext float %29 to double
%31 = load float, float* %4
%32 = fpext float %31 to double
%33 = load float, float* %3
%34 = load float, float* %4
%35 = fsub float %33, %34
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), double %30, double %32, double %36)
br label %59
38: ; preds = %0
%39 = load float, float* %3
%40 = fpext float %39 to double
%41 = load float, float* %4
%42 = fpext float %41 to double
%43 = load float, float* %3
%44 = load float, float* %4
%45 = fmul float %43, %44
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), double %40, double %42, double %46)
br label %59
48: ; preds = %0
%49 = load float, float* %3
%50 = fpext float %49 to double
%51 = load float, float* %4
%52 = fpext float %51 to double
%53 = load float, float* %3
%54 = load float, float* %4
%55 = fdiv float %53, %54
%56 = fpext float %55 to double
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), double %50, double %52, double %56)
br label %59
58: ; preds = %0
br label %59
59: ; preds = %58, %48, %38, %28, %18
%60 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"a: \00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [4 x i8] c"b: \00"
@.str.10 = [16 x i8] c"%.2f+%.2f=%.2f\0A\00"
@.str.11 = [16 x i8] c"%.2f-%.2f=%.2f\0A\00"
@.str.12 = [16 x i8] c"%.2f*%.2f=%.2f\0A\00"
@.str.13 = [16 x i8] c"%.2f/%.2f=%.2f\0A\00"
@.str.14 = [6 x i8] c"pause\00"
@str = [68 x i8] c"Dame los valores a y b para hacer la operacion que elegiras despues\00"
@str.15 = [27 x i8] c"Que deseas? (Pon el signo)\00"
@str.16 = [8 x i8] c"+ Sumar\00"
@str.17 = [9 x i8] c"- Restar\00"
@str.18 = [14 x i8] c"* Multiplicar\00"
@str.19 = [10 x i8] c"/ Dividir\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%4 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([68 x i8], [68 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %1)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 @scanf_s(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %2)
%10 = call i32 @putchar(i32 10)
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.15, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.16, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.18, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.19, i64 0, i64 0))
%16 = call i32 @putchar(i32 10)
%17 = call i32 (...) @getch()
switch i32 %17, label %50 [
i32 43, label %18
i32 45, label %26
i32 42, label %34
i32 47, label %42
]
18: ; preds = %0
%19 = load float, float* %1
%20 = fpext float %19 to double
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = fadd float %19, %21
%24 = fpext float %23 to double
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), double %20, double %22, double %24)
br label %50
26: ; preds = %0
%27 = load float, float* %1
%28 = fpext float %27 to double
%29 = load float, float* %2
%30 = fpext float %29 to double
%31 = fsub float %27, %29
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), double %28, double %30, double %32)
br label %50
34: ; preds = %0
%35 = load float, float* %1
%36 = fpext float %35 to double
%37 = load float, float* %2
%38 = fpext float %37 to double
%39 = fmul float %35, %37
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), double %36, double %38, double %40)
br label %50
42: ; preds = %0
%43 = load float, float* %1
%44 = fpext float %43 to double
%45 = load float, float* %2
%46 = fpext float %45 to double
%47 = fdiv float %43, %45
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0), double %44, double %46, double %48)
br label %50
50: ; preds = %0, %42, %34, %26, %18
%51 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.14, i64 0, i64 0))
ret i32 0
}