#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 *, double *, char *, double *);
int main(void) {
  double value1, value2;
  char operator;
  printf("Type in your expression.\n");
  scanf("%lf %c %lf", &value1, &operator, & value2);
  if (operator== '+')
    printf("%.2f\n", value1 + value2);
  else if (operator== '-')
    printf("%.2f\n", value1 - value2);
  else if (operator== '*')
    printf("%.2f\n", value1 * value2);
  else if (operator== '/')
    printf("%.2f\n", value1 / value2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x19(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x2b,%eax
jne    117f <main+0x5f>
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
lea    0xeb2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1207 <main+0xe7>
movsbl -0x19(%rbp),%eax
cmp    $0x2d,%eax
jne    11a9 <main+0x89>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1202 <main+0xe2>
movsbl -0x19(%rbp),%eax
cmp    $0x2a,%eax
jne    11d3 <main+0xb3>
movsd  -0x10(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
lea    0xe5e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
movsbl -0x19(%rbp),%eax
cmp    $0x2f,%eax
jne    11f8 <main+0xd8>
movsd  -0x10(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
lea    0xe34(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11fd <main+0xdd>
jmp    1202 <main+0xe2>
jmp    1207 <main+0xe7>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xed1(%rip),%rdi
lea    0x10(%rsp),%rsi
lea    0x7(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1050 <scanf@plt>
mov    0x7(%rsp),%al
add    $0xd6,%al
cmp    $0x5,%al
ja     11bc <main+0x8c>
movzbl %al,%eax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
jmp    11ae <main+0x7e>
movsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
jmp    11ae <main+0x7e>
movsd  0x10(%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
jmp    11ae <main+0x7e>
movsd  0x10(%rsp),%xmm0
divsd  0x8(%rsp),%xmm0
lea    0xe6e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Type in your expression.\0A\00"
@.str.1 = [11 x i8] c"%lf %c %lf\00"
@.str.2 = [6 x i8] c"%.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i8
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %2, i8* %4, double* %3)
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 43
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load double, double* %2
%12 = load double, double* %3
%13 = fadd double %11, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %45
15: ; preds = %0
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 45
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load double, double* %2
%21 = load double, double* %3
%22 = fsub double %20, %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %22)
br label %44
24: ; preds = %15
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 42
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load double, double* %2
%30 = load double, double* %3
%31 = fmul double %29, %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %31)
br label %43
33: ; preds = %24
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 47
br i1 %36, label %37, label %42
37: ; preds = %33
%38 = load double, double* %2
%39 = load double, double* %3
%40 = fdiv double %38, %39
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %40)
br label %42
42: ; preds = %37, %33
br label %43
43: ; preds = %42, %28
br label %44
44: ; preds = %43, %19
br label %45
45: ; preds = %44, %10
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"%lf %c %lf\00"
@.str.2 = [6 x i8] c"%.2f\0A\00"
@str = [25 x i8] c"Type in your expression.\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i8
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double* %1, i8* %3, double* %2)
%8 = load i8, i8* %3
switch i8 %8, label %28 [
i8 43, label %9
i8 45, label %13
i8 42, label %17
i8 47, label %21
]
9: ; preds = %0
%10 = load double, double* %1
%11 = load double, double* %2
%12 = fadd double %10, %11
br label %25
13: ; preds = %0
%14 = load double, double* %1
%15 = load double, double* %2
%16 = fsub double %14, %15
br label %25
17: ; preds = %0
%18 = load double, double* %1
%19 = load double, double* %2
%20 = fmul double %18, %19
br label %25
21: ; preds = %0
%22 = load double, double* %1
%23 = load double, double* %2
%24 = fdiv double %22, %23
br label %25
25: ; preds = %9, %17, %21, %13
%26 = phi double [ %16, %13 ], [ %24, %21 ], [ %20, %17 ], [ %12, %9 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %28
28: ; preds = %25, %0
ret i32 0
}