#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 EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ printf(char *, float);
int scanf(char *, float *, float *, char *);
int /*<<< orphan*/ stderr;
int main() {
  float first_operand = 0.f;
  float second_operand = 0.f;
  char operator;
  while (scanf("%f %f %c", &first_operand, &second_operand, &operator) == 3) {
    switch (operator) {
    case '+':
      printf("\t%f\n", first_operand + second_operand);
      break;
    case '-':
      printf("\t%f\n", first_operand - second_operand);
      break;
    case '*':
      printf("\t%f\n", first_operand * second_operand);
      break;
    case '/':
      printf("\t%f\n", first_operand / second_operand);
      break;
    default:
      fprintf(stderr, "error: '%c' is an invalid operator\n", operator);
      break;
    }
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0xd(%rbp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    1224 <main+0xf4>
movsbl -0xd(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     1206 <main+0xd6>
mov    -0x18(%rbp),%rax
lea    0xe6f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <main+0xef>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
lea    0xe5b(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <main+0xef>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
lea    0xe40(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <main+0xef>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
jmp    121f <main+0xef>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
movsbl -0xd(%rbp),%edx
call   1040 <fprintf@plt>
jmp    114f <main+0x1f>
mov    0x2dad(%rip),%rax
mov    (%rax),%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
movl   $0x0,0x14(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xec3(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0xf(%rsp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    1231 <main+0x101>
lea    0xe9f(%rip),%r15
lea    0x14(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xf(%rsp),%rbx
lea    0xe71(%rip),%r14
lea    0xe8b(%rip),%rbp
jmp    11ca <main+0x9a>
nopl   0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm0
addss  0x10(%rsp),%xmm0
mov    %rbp,%rdi
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    1231 <main+0x101>
movsbl 0xf(%rsp),%eax
lea    -0x2a(%rax),%ecx
cmp    $0x5,%ecx
ja     11f0 <main+0xc0>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
movss  0x14(%rsp),%xmm0
mulss  0x10(%rsp),%xmm0
jmp    11ac <main+0x7c>
xchg   %ax,%ax
mov    0x2de9(%rip),%rcx
mov    (%rcx),%edi
movsbl %al,%edx
lea    0xe23(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b4 <main+0x84>
nopw   0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm0
subss  0x10(%rsp),%xmm0
jmp    11ac <main+0x7c>
xchg   %ax,%ax
movss  0x14(%rsp),%xmm0
divss  0x10(%rsp),%xmm0
jmp    11ac <main+0x7c>
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"%f %f %c\00"
@.str.1 = [5 x i8] c"\09%f\0A\00"
@stderr = global i32 0
@.str.2 = [36 x i8] c"error: '%c' is an invalid operator\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = bitcast float* %1 to i8*
store float 0.000000e+00, float* %1
%5 = bitcast float* %2 to i8*
store float 0.000000e+00, float* %2
%6 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %1, float* %2, i8* %3)
%7 = icmp eq i32 %6, 3
br i1 %7, label %8, label %37
8: ; preds = %0, %34
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
switch i32 %10, label %31 [
i32 43, label %11
i32 45, label %16
i32 42, label %21
i32 47, label %26
]
11: ; preds = %8
%12 = load float, float* %1
%13 = load float, float* %2
%14 = fadd float %12, %13
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %14)
br label %34
16: ; preds = %8
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fsub float %17, %18
%20 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %19)
br label %34
21: ; preds = %8
%22 = load float, float* %1
%23 = load float, float* %2
%24 = fmul float %22, %23
%25 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %24)
br label %34
26: ; preds = %8
%27 = load float, float* %1
%28 = load float, float* %2
%29 = fdiv float %27, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), float %29)
br label %34
31: ; preds = %8
%32 = load i32, i32* @stderr
%33 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8 signext %9)
br label %34
34: ; preds = %31, %26, %21, %16, %11
%35 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), float* %1, float* %2, i8* %3)
%36 = icmp eq i32 %35, 3
br i1 %36, label %8, label %37
37: ; preds = %34, %0
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}