#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 scanf(char *, float *, char *, float *);
int main(void) {
  char op;
  float a, b;
  printf("Enter a number an operator and again a number:");
  while (scanf("%f%c%f", &a, &op, &b) == 3) {
    switch (op) {
    case '+':
      printf("%g%c%g=%g\n", a, op, b, a + b);
      break;
    case '-':
      printf("%g%c%g=%g\n", a, op, b, a - b);
      break;
    case '*':
      printf("%g%c%g=%g\n", a, op, b, a * b);
      break;
    case '/':
      if (b == 0) {
        printf("division by zero not allowed.\n");
        break;
      } else
        printf("%g%c%g=%g\n", a, op, b, a / b);
      break;
    default:
      printf("%c isn't supported operator in this calculator.\n", op);
    }
    printf("Enter a number an operator and again a number:");
  }
  printf("Done!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf03(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x5(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <scanf@plt>
cmp    $0x3,%eax
jne    12b3 <main+0x193>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     128e <main+0x16e>
mov    -0x18(%rbp),%rax
lea    0xe81(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x5(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
addss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe9b(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x5(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
subss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe64(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x5(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
mulss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe2d(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1257 <main+0x137>
jp     1257 <main+0x137>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsbl -0x5(%rbp),%esi
movss  -0x10(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0xc(%rbp),%xmm2
divss  -0x10(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdcc(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
jmp    12a0 <main+0x180>
movsbl -0x5(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    113d <main+0x1d>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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
lea    0xed7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef8(%rip),%rdi
lea    0x14(%rsp),%rsi
lea    0xf(%rsp),%rdx
lea    0x10(%rsp),%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    12e2 <main+0x1b2>
lea    0xea5(%rip),%r15
lea    0xecd(%rip),%r12
lea    0x14(%rsp),%r13
lea    0xf(%rsp),%rbx
lea    0x10(%rsp),%rbp
lea    0xe70(%rip),%r14
jmp    11f9 <main+0xc9>
cs nopw 0x0(%rax,%rax,1)
movss  0x14(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
mulss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe89(%rip),%rdi
mov    $0x2a,%esi
mov    $0x3,%al
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
call   1050 <scanf@plt>
cmp    $0x3,%eax
jne    12e2 <main+0x1b2>
movsbl 0xf(%rsp),%esi
lea    -0x2a(%rsi),%eax
cmp    $0x5,%eax
ja     1240 <main+0x110>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
movss  0x14(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
addss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xe1a(%rip),%rdi
mov    $0x2b,%esi
jmp    11ce <main+0x9e>
nop
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d5 <main+0xa5>
movss  0x14(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
movss  0x10(%rsp),%xmm3
xorps  %xmm1,%xmm1
cvtss2sd %xmm3,%xmm1
subss  %xmm3,%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdd9(%rip),%rdi
mov    $0x2d,%esi
jmp    11ce <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x10(%rsp),%xmm2
ucomiss 0xd63(%rip),%xmm2
jne    12b2 <main+0x182>
jp     12b2 <main+0x182>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
jmp    11d5 <main+0xa5>
movss  0x14(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
divss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
lea    0xd7a(%rip),%rdi
mov    $0x2f,%esi
jmp    11ce <main+0x9e>
lea    0xda5(%rip),%rdi
xor    %eax,%eax
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 = [47 x i8] c"Enter a number an operator and again a number:\00"
@.str.1 = [7 x i8] c"%f%c%f\00"
@.str.2 = [11 x i8] c"%g%c%g=%g\0A\00"
@.str.3 = [31 x i8] c"division by zero not allowed.\0A\00"
@.str.4 = [49 x i8] c"%c isn't supported operator in this calculator.\0A\00"
@.str.5 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %70, %0
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %3, i8* %2, float* %4)
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %72
9: ; preds = %6
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
switch i32 %11, label %66 [
i32 43, label %12
i32 45, label %24
i32 42, label %36
i32 47, label %48
]
12: ; preds = %9
%13 = load float, float* %3
%14 = fpext float %13 to double
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = load float, float* %3
%20 = load float, float* %4
%21 = fadd float %19, %20
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %14, i32 %16, double %18, double %22)
br label %70
24: ; preds = %9
%25 = load float, float* %3
%26 = fpext float %25 to double
%27 = load i8, i8* %2
%28 = sext i8 %27 to i32
%29 = load float, float* %4
%30 = fpext float %29 to double
%31 = load float, float* %3
%32 = load float, float* %4
%33 = fsub float %31, %32
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %26, i32 %28, double %30, double %34)
br label %70
36: ; preds = %9
%37 = load float, float* %3
%38 = fpext float %37 to double
%39 = load i8, i8* %2
%40 = sext i8 %39 to i32
%41 = load float, float* %4
%42 = fpext float %41 to double
%43 = load float, float* %3
%44 = load float, float* %4
%45 = fmul float %43, %44
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %38, i32 %40, double %42, double %46)
br label %70
48: ; preds = %9
%49 = load float, float* %4
%50 = fcmp oeq float %49, 0.000000e+00
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
br label %70
53: ; preds = %48
%54 = load float, float* %3
%55 = fpext float %54 to double
%56 = load i8, i8* %2
%57 = sext i8 %56 to i32
%58 = load float, float* %4
%59 = fpext float %58 to double
%60 = load float, float* %3
%61 = load float, float* %4
%62 = fdiv float %60, %61
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %55, i32 %57, double %59, double %63)
br label %65
65: ; preds = %53
br label %70
66: ; preds = %9
%67 = load i8, i8* %2
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %66, %65, %51, %36, %24, %12
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
br label %6
72: ; preds = %6
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [47 x i8] c"Enter a number an operator and again a number:\00"
@.str.1 = [7 x i8] c"%f%c%f\00"
@.str.2 = [11 x i8] c"%g%c%g=%g\0A\00"
@.str.4 = [49 x i8] c"%c isn't supported operator in this calculator.\0A\00"
@.str.5 = [6 x i8] c"Done!\00"
@str = [30 x i8] c"division by zero not allowed.\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = alloca float
%4 = bitcast float* %2 to i8*
%5 = bitcast float* %3 to i8*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %2, i8* %1, float* %3)
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %54
9: ; preds = %0, %50
%10 = load i8, i8* %1
%11 = sext i8 %10 to i32
switch i32 %11, label %48 [
i32 43, label %12
i32 45, label %20
i32 42, label %28
i32 47, label %36
]
12: ; preds = %9
%13 = load float, float* %2
%14 = fpext float %13 to double
%15 = load float, float* %3
%16 = fpext float %15 to double
%17 = fadd float %13, %15
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %14, i32 43, double %16, double %18)
br label %50
20: ; preds = %9
%21 = load float, float* %2
%22 = fpext float %21 to double
%23 = load float, float* %3
%24 = fpext float %23 to double
%25 = fsub float %21, %23
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %22, i32 45, double %24, double %26)
br label %50
28: ; preds = %9
%29 = load float, float* %2
%30 = fpext float %29 to double
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = fmul float %29, %31
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %30, i32 42, double %32, double %34)
br label %50
36: ; preds = %9
%37 = load float, float* %3
%38 = fcmp oeq float %37, 0.000000e+00
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %50
41: ; preds = %36
%42 = load float, float* %2
%43 = fpext float %42 to double
%44 = fpext float %37 to double
%45 = fdiv float %42, %37
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %43, i32 47, double %44, double %46)
br label %50
48: ; preds = %9
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.4, i64 0, i64 0), i32 %11)
br label %50
50: ; preds = %48, %41, %39, %28, %20, %12
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%52 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float* %2, i8* %1, float* %3)
%53 = icmp eq i32 %52, 3
br i1 %53, label %9, label %54
54: ; preds = %50, %0
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}