#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 */
double calcPower(double, double);
double calcUserAnswer(double first, char operand, double second) {
  double ans = 0;
  switch (operand) {
  case '*':
    ans = first * second;
    break;
  case '/':
    ans = first / second;
    break;
  case '+':
    ans = first + second;
    break;
  case '-':
    ans = first - second;
    break;
  case '^':
    if (0 <= second) {
      ans = calcPower(first, second);
    } else {
      ans = calcPower(first, second);
      ans = 1 / ans;
    }
    break;
  }
  return ans;
}


x86 assembly (clang, -O0):
<calcUserAnswer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
movsd  %xmm0,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movsd  %xmm1,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movsbl -0x9(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x2a,%eax
je     1189 <calcUserAnswer+0x79>
jmp    1145 <calcUserAnswer+0x35>
mov    -0x24(%rbp),%eax
sub    $0x2b,%eax
je     11b1 <calcUserAnswer+0xa1>
jmp    1156 <calcUserAnswer+0x46>
mov    -0x24(%rbp),%eax
sub    $0x2d,%eax
je     11c5 <calcUserAnswer+0xb5>
jmp    1167 <calcUserAnswer+0x57>
mov    -0x24(%rbp),%eax
sub    $0x2f,%eax
je     119d <calcUserAnswer+0x8d>
jmp    1178 <calcUserAnswer+0x68>
mov    -0x24(%rbp),%eax
sub    $0x5e,%eax
je     11d9 <calcUserAnswer+0xc9>
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x8(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x8(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x8(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1204 <calcUserAnswer+0xf4>
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <calcPower@plt>
movsd  %xmm0,-0x20(%rbp)
jmp    122a <calcUserAnswer+0x11a>
movsd  -0x8(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1030 <calcPower@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xde0(%rip),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122f <calcUserAnswer+0x11f>
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcUserAnswer>:
push   %rax
movapd %xmm0,%xmm2
xorpd  %xmm0,%xmm0
lea    -0x2a(%rdi),%eax
cmp    $0x5,%eax
ja     1137 <calcUserAnswer+0x27>
lea    0xee0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mulsd  %xmm1,%xmm2
jmp    117b <calcUserAnswer+0x6b>
cmp    $0x5e,%edi
jne    117f <calcUserAnswer+0x6f>
movapd %xmm2,%xmm0
movsd  %xmm1,(%rsp)
call   1030 <calcPower@plt>
xorpd  %xmm1,%xmm1
movsd  (%rsp),%xmm2
ucomisd %xmm1,%xmm2
jae    117f <calcUserAnswer+0x6f>
movsd  0xe9f(%rip),%xmm1
divsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
pop    %rax
ret
addsd  %xmm1,%xmm2
jmp    117b <calcUserAnswer+0x6b>
subsd  %xmm1,%xmm2
jmp    117b <calcUserAnswer+0x6b>
divsd  %xmm1,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @calcUserAnswer(double %0, i8 signext %1, double %2) {
%4 = alloca double
%5 = alloca i8
%6 = alloca double
%7 = alloca double
store double %0, double* %4
store i8 %1, i8* %5
store double %2, double* %6
store double 0.000000e+00, double* %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %40 [
i32 42, label %10
i32 47, label %14
i32 43, label %18
i32 45, label %22
i32 94, label %26
]
10: ; preds = %3
%11 = load double, double* %4
%12 = load double, double* %6
%13 = fmul double %11, %12
store double %13, double* %7
br label %40
14: ; preds = %3
%15 = load double, double* %4
%16 = load double, double* %6
%17 = fdiv double %15, %16
store double %17, double* %7
br label %40
18: ; preds = %3
%19 = load double, double* %4
%20 = load double, double* %6
%21 = fadd double %19, %20
store double %21, double* %7
br label %40
22: ; preds = %3
%23 = load double, double* %4
%24 = load double, double* %6
%25 = fsub double %23, %24
store double %25, double* %7
br label %40
26: ; preds = %3
%27 = load double, double* %6
%28 = fcmp ole double 0.000000e+00, %27
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load double, double* %4
%31 = load double, double* %6
%32 = call double @calcPower(double %30, double %31)
store double %32, double* %7
br label %39
33: ; preds = %26
%34 = load double, double* %4
%35 = load double, double* %6
%36 = call double @calcPower(double %34, double %35)
store double %36, double* %7
%37 = load double, double* %7
%38 = fdiv double 1.000000e+00, %37
store double %38, double* %7
br label %39
39: ; preds = %33, %29
br label %40
40: ; preds = %3, %39, %22, %18, %14, %10
%41 = load double, double* %7
ret double %41
}

LLVM IR (-O2):
define double @calcUserAnswer(double %0, i8 signext %1, double %2) {
%4 = sext i8 %1 to i32
switch i32 %4, label %18 [
i32 42, label %5
i32 47, label %7
i32 43, label %9
i32 45, label %11
i32 94, label %13
]
5: ; preds = %3
%6 = fmul double %0, %2
br label %18
7: ; preds = %3
%8 = fdiv double %0, %2
br label %18
9: ; preds = %3
%10 = fadd double %0, %2
br label %18
11: ; preds = %3
%12 = fsub double %0, %2
br label %18
13: ; preds = %3
%14 = fcmp ult double %2, 0.000000e+00
%15 = tail call double @calcPower(double %0, double %2)
br i1 %14, label %16, label %18
16: ; preds = %13
%17 = fdiv double 1.000000e+00, %15
br label %18
18: ; preds = %13, %16, %3, %11, %9, %7, %5
%19 = phi double [ 0.000000e+00, %3 ], [ %17, %16 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %15, %13 ]
ret double %19
}