#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 main() {
  int oper;
  double n1, n2;
  printf("Calculadora básica.\n");
  printf("\n¿Qué operación desea efectuar?\n");
  printf("\nIntroduzca:");
  printf("\n\t1 si desea efectuar una suma.");
  printf("\n\t2 si desea efectuar una resta.");
  printf("\n\t3 si desea efectuar una multiplicación.");
  printf("\n\t4 si desea efectuar una división.\n");
  printf("\nOperación: ");
  scanf("%d", &oper);
  if (oper == 0 || oper > 4) {
    printf("Usted ingresó una opción erronia.");
    return 0;
  } else {
    printf("\nIntroduzca el primer valor: ");
    scanf("%lf", &n1);
    printf("Introduzca el segundo valor: ");
    scanf("%lf", &n2);
  }
  switch (oper) {
  case 1:
    printf("\nEl resultado de %f + %f es: %f", n1, n2, n1 + n2);
    break;
  case 2:
    printf("\nEl resultado de %f - %f es: %f", n1, n2, n1 - n2);
    break;
  case 3:
    printf("\nEl resultado de %d * %f es: %f", n1, n2, n1 * n2);
    break;
  case 4:
    printf("\nEl resultado de %d / %f es: %f", n1, n2, n1 / n2);
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf39(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf51(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     11c5 <main+0xa5>
cmpl   $0x4,-0x8(%rbp)
jle    11df <main+0xbf>
lea    0xf2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e6 <main+0x1c6>
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf48(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xf3a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf28(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     12df <main+0x1bf>
mov    -0x20(%rbp),%rax
lea    0xdc1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
lea    0xefb(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12df <main+0x1bf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
lea    0xef4(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12df <main+0x1bf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
lea    0xeed(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12df <main+0x1bf>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
divsd  -0x18(%rbp),%xmm2
lea    0xee6(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0x1042(%rip),%rdi
call   1030 <puts@plt>
lea    0x104b(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x102a(%rip),%rdi
call   1030 <puts@plt>
lea    0xef1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1241 <main+0x111>
cmp    $0x5,%eax
jge    1241 <main+0x111>
lea    0xef4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf04(%rip),%rbx
lea    0x18(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xef2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     12ad <main+0x17d>
lea    0xde5(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
lea    0xebf(%rip),%rdi
jmp    12a6 <main+0x176>
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12ad <main+0x17d>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movapd %xmm0,%xmm2
subsd  %xmm1,%xmm2
lea    0xeb2(%rip),%rdi
jmp    12a6 <main+0x176>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movapd %xmm0,%xmm2
mulsd  %xmm1,%xmm2
lea    0xeb5(%rip),%rdi
jmp    12a6 <main+0x176>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xeb8(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Calculadora b\C3\A1sica.\0A\00"
@.str.1 = [36 x i8] c"\0A\C2\BFQu\C3\A9 operaci\C3\B3n desea efectuar?\0A\00"
@.str.2 = [13 x i8] c"\0AIntroduzca:\00"
@.str.3 = [32 x i8] c"\0A\091 si desea efectuar una suma.\00"
@.str.4 = [33 x i8] c"\0A\092 si desea efectuar una resta.\00"
@.str.5 = [43 x i8] c"\0A\093 si desea efectuar una multiplicaci\C3\B3n.\00"
@.str.6 = [38 x i8] c"\0A\094 si desea efectuar una divisi\C3\B3n.\0A\00"
@.str.7 = [14 x i8] c"\0AOperaci\C3\B3n: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [36 x i8] c"Usted ingres\C3\B3 una opci\C3\B3n erronia.\00"
@.str.10 = [30 x i8] c"\0AIntroduzca el primer valor: \00"
@.str.11 = [4 x i8] c"%lf\00"
@.str.12 = [30 x i8] c"Introduzca el segundo valor: \00"
@.str.13 = [32 x i8] c"\0AEl resultado de %f + %f es: %f\00"
@.str.14 = [32 x i8] c"\0AEl resultado de %f - %f es: %f\00"
@.str.15 = [32 x i8] c"\0AEl resultado de %d * %f es: %f\00"
@.str.16 = [32 x i8] c"\0AEl resultado de %d / %f es: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 0
br i1 %15, label %19, label %16
16: ; preds = %0
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 4
br i1 %18, label %19, label %21
19: ; preds = %16, %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %1
br label %57
21: ; preds = %16
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %3)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%25 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %4)
br label %26
26: ; preds = %21
%27 = load i32, i32* %2
switch i32 %27, label %56 [
i32 1, label %28
i32 2, label %35
i32 3, label %42
i32 4, label %49
]
28: ; preds = %26
%29 = load double, double* %3
%30 = load double, double* %4
%31 = load double, double* %3
%32 = load double, double* %4
%33 = fadd double %31, %32
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), double %29, double %30, double %33)
br label %56
35: ; preds = %26
%36 = load double, double* %3
%37 = load double, double* %4
%38 = load double, double* %3
%39 = load double, double* %4
%40 = fsub double %38, %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0), double %36, double %37, double %40)
br label %56
42: ; preds = %26
%43 = load double, double* %3
%44 = load double, double* %4
%45 = load double, double* %3
%46 = load double, double* %4
%47 = fmul double %45, %46
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), double %43, double %44, double %47)
br label %56
49: ; preds = %26
%50 = load double, double* %3
%51 = load double, double* %4
%52 = load double, double* %3
%53 = load double, double* %4
%54 = fdiv double %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), double %50, double %51, double %54)
br label %56
56: ; preds = %26, %49, %42, %35, %28
store i32 0, i32* %1
br label %57
57: ; preds = %56, %19
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str.2 = [13 x i8] c"\0AIntroduzca:\00"
@.str.3 = [32 x i8] c"\0A\091 si desea efectuar una suma.\00"
@.str.4 = [33 x i8] c"\0A\092 si desea efectuar una resta.\00"
@.str.5 = [43 x i8] c"\0A\093 si desea efectuar una multiplicaci\C3\B3n.\00"
@.str.7 = [14 x i8] c"\0AOperaci\C3\B3n: \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [36 x i8] c"Usted ingres\C3\B3 una opci\C3\B3n erronia.\00"
@.str.10 = [30 x i8] c"\0AIntroduzca el primer valor: \00"
@.str.11 = [4 x i8] c"%lf\00"
@.str.12 = [30 x i8] c"Introduzca el segundo valor: \00"
@.str.13 = [32 x i8] c"\0AEl resultado de %f + %f es: %f\00"
@.str.14 = [32 x i8] c"\0AEl resultado de %f - %f es: %f\00"
@.str.15 = [32 x i8] c"\0AEl resultado de %d * %f es: %f\00"
@.str.16 = [32 x i8] c"\0AEl resultado de %d / %f es: %f\00"
@str = [21 x i8] c"Calculadora b\C3\A1sica.\00"
@str.17 = [35 x i8] c"\0A\C2\BFQu\C3\A9 operaci\C3\B3n desea efectuar?\00"
@str.18 = [37 x i8] c"\0A\094 si desea efectuar una divisi\C3\B3n.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.17, i64 0, i64 0))
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.18, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
%18 = icmp sgt i32 %16, 4
%19 = or i1 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
br label %48
22: ; preds = %0
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %2)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), double* %3)
%27 = load i32, i32* %1
switch i32 %27, label %48 [
i32 1, label %28
i32 2, label %33
i32 3, label %38
i32 4, label %43
]
28: ; preds = %22
%29 = load double, double* %2
%30 = load double, double* %3
%31 = fadd double %29, %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.13, i64 0, i64 0), double %29, double %30, double %31)
br label %48
33: ; preds = %22
%34 = load double, double* %2
%35 = load double, double* %3
%36 = fsub double %34, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0), double %34, double %35, double %36)
br label %48
38: ; preds = %22
%39 = load double, double* %2
%40 = load double, double* %3
%41 = fmul double %39, %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.15, i64 0, i64 0), double %39, double %40, double %41)
br label %48
43: ; preds = %22
%44 = load double, double* %2
%45 = load double, double* %3
%46 = fdiv double %44, %45
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.16, i64 0, i64 0), double %44, double %45, double %46)
br label %48
48: ; preds = %28, %33, %38, %43, %22, %20
ret i32 0
}