#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 *);
int main(void) {
  float accumulator = 0;
  float operand;
  char operator;
  int exitStatus = 0;
  while (!exitStatus) {
    scanf("%f %c", &operand, &operator);
    switch (operator) {
    case '+':
      accumulator += operand;
      break;
    case '-':
      accumulator -= operand;
      break;
    case '*':
      accumulator *= operand;
      break;
    case '/':
      accumulator /= operand;
      break;
    case 'S':
      accumulator = operand;
      break;
    case 'E':
      exitStatus = 1;
      break;
    default:
      printf("Unrecognized operator!\n");
    }
    printf("= %.4f\n", accumulator);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1154 <main+0x34>
jmp    122f <main+0x10f>
lea    0xf4d(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0xd(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x29,%eax
ja     1205 <main+0xe5>
mov    -0x20(%rbp),%rax
lea    0xe77(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1213 <main+0xf3>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1213 <main+0xf3>
movss  -0xc(%rbp),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1213 <main+0xf3>
movss  -0xc(%rbp),%xmm1
movss  -0x8(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1213 <main+0xf3>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1213 <main+0xf3>
movl   $0x1,-0x14(%rbp)
jmp    1213 <main+0xf3>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    113e <main+0x1e>
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
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xf5a(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x13(%rsp),%r13
lea    0xf57(%rip),%r12
lea    0xf48(%rip),%rbx
lea    0xe93(%rip),%rbp
jmp    1194 <main+0x64>
mov    %r12,%rdi
call   1030 <puts@plt>
movss  0xc(%rsp),%xmm0
nopl   (%rax)
movss  %xmm0,0xc(%rsp)
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
call   1050 <scanf@plt>
movsbl 0x13(%rsp),%eax
add    $0xffffffd6,%eax
cmp    $0x29,%eax
ja     116f <main+0x3f>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
movss  0xc(%rsp),%xmm0
mulss  0x14(%rsp),%xmm0
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm0
subss  0x14(%rsp),%xmm0
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm0
divss  0x14(%rsp),%xmm0
jmp    1180 <main+0x50>
movss  0x14(%rsp),%xmm0
jmp    1180 <main+0x50>
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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