#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 *, float *, char *, float *);
int main(void) {
  float value1, value2;
  char operator;
  printf("Type in your expression.\n");
  scanf("%f %c %f", &value1, &operator, & value2);
  switch (operator) {
  case '+':
    printf("%.2f\n", value1 + value2);
    break;
  case '-':
    printf("%.2f\n", value1 - value2);
    break;
  case '*':
  case 'x':
  case 'X':
    printf("%.2f\n", value1 * value2);
    break;
  case '/':
    if (0 == value2)
      printf("Division by zero.\n");
    else
      printf("%.2f\n", value1 / value2);
    break;
  default:
    printf("Unknown operator.\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xd(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x2a,%eax
je     1201 <main+0xe1>
jmp    116a <main+0x4a>
mov    -0x14(%rbp),%eax
sub    $0x2b,%eax
je     11bf <main+0x9f>
jmp    117b <main+0x5b>
mov    -0x14(%rbp),%eax
sub    $0x2d,%eax
je     11e0 <main+0xc0>
jmp    118c <main+0x6c>
mov    -0x14(%rbp),%eax
sub    $0x2f,%eax
je     1222 <main+0x102>
jmp    119d <main+0x7d>
mov    -0x14(%rbp),%eax
sub    $0x58,%eax
je     1201 <main+0xe1>
jmp    11ae <main+0x8e>
mov    -0x14(%rbp),%eax
sub    $0x78,%eax
je     1201 <main+0xe1>
jmp    1269 <main+0x149>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
xorps  %xmm0,%xmm0
ucomiss -0xc(%rbp),%xmm0
jne    1248 <main+0x128>
jp     1248 <main+0x128>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1264 <main+0x144>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdc6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1277 <main+0x157>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf90(%rip),%rdi
call   1030 <puts@plt>
lea    0xf75(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
movsbl 0xf(%rsp),%ecx
lea    -0x2a(%rcx),%eax
cmp    $0x2e,%eax
ja     1186 <main+0x56>
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  0x14(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
jmp    11ae <main+0x7e>
cmp    $0x78,%ecx
jne    1199 <main+0x69>
movss  0x14(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
jmp    11ae <main+0x7e>
lea    0xf56(%rip),%rdi
jmp    11d9 <main+0xa9>
movss  0x14(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xf0c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11de <main+0xae>
movss  0x10(%rsp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11e5 <main+0xb5>
jp     11e5 <main+0xb5>
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
movss  0x14(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
jmp    11b2 <main+0x82>

LLVM IR (-O0):
@.str = [26 x i8] c"Type in your expression.\0A\00"
@.str.1 = [9 x i8] c"%f %c %f\00"
@.str.2 = [6 x i8] c"%.2f\0A\00"
@.str.3 = [19 x i8] c"Division by zero.\0A\00"
@.str.4 = [19 x i8] c"Unknown operator.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %2, i8* %4, float* %3)
%7 = load i8, i8* %4
%8 = sext i8 %7 to i32
switch i32 %8, label %39 [
i32 43, label %9
i32 45, label %15
i32 42, label %21
i32 120, label %21
i32 88, label %21
i32 47, label %27
]
9: ; preds = %0
%10 = load float, float* %2
%11 = load float, float* %3
%12 = fadd float %10, %11
%13 = fpext float %12 to double
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %13)
br label %41
15: ; preds = %0
%16 = load float, float* %2
%17 = load float, float* %3
%18 = fsub float %16, %17
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %19)
br label %41
21: ; preds = %0, %0, %0
%22 = load float, float* %2
%23 = load float, float* %3
%24 = fmul float %22, %23
%25 = fpext float %24 to double
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %25)
br label %41
27: ; preds = %0
%28 = load float, float* %3
%29 = fcmp oeq float 0.000000e+00, %28
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %38
32: ; preds = %27
%33 = load float, float* %2
%34 = load float, float* %3
%35 = fdiv float %33, %34
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %36)
br label %38
38: ; preds = %32, %30
br label %41
39: ; preds = %0
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %38, %21, %15, %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%f %c %f\00"
@.str.2 = [6 x i8] c"%.2f\0A\00"
@str = [25 x i8] c"Type in your expression.\00"
@str.5 = [18 x i8] c"Division by zero.\00"
@str.6 = [18 x i8] c"Unknown operator.\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
%5 = bitcast float* %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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), float* %1, i8* %3, float* %2)
%8 = load i8, i8* %3
%9 = sext i8 %8 to i32
switch i32 %9, label %38 [
i32 43, label %10
i32 45, label %16
i32 42, label %22
i32 120, label %22
i32 88, label %22
i32 47, label %28
]
10: ; preds = %0
%11 = load float, float* %1
%12 = load float, float* %2
%13 = fadd float %11, %12
%14 = fpext float %13 to double
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %14)
br label %40
16: ; preds = %0
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fsub float %17, %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %20)
br label %40
22: ; preds = %0, %0, %0
%23 = load float, float* %1
%24 = load float, float* %2
%25 = fmul float %23, %24
%26 = fpext float %25 to double
%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 %40
28: ; preds = %0
%29 = load float, float* %2
%30 = fcmp oeq float %29, 0.000000e+00
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.5, i64 0, i64 0))
br label %40
33: ; preds = %28
%34 = load float, float* %1
%35 = fdiv float %34, %29
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), double %36)
br label %40
38: ; preds = %0
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %40
40: ; preds = %31, %33, %38, %22, %16, %10
ret i32 0
}