#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 pow(double, double);
double compute(char symbol, double op1, double op2) {
  switch (symbol) {
  case '+':
    return op1 + op2;
  case '-':
    return op1 - op2;
  case '*':
    return op1 * op2;
  case '/':
    return op1 / op2;
  case '^':
  case '$':
    return pow(op1, op2);
  }
}


x86 assembly (clang, -O0):
<compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffdc,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3a,%eax
ja     11b6 <compute+0xa6>
mov    -0x28(%rbp),%rax
lea    0xeb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <compute+0xa6>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <compute+0xa6>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <compute+0xa6>
movsd  -0x18(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11b6 <compute+0xa6>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1030 <pow@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute>:
add    $0xffffffdc,%edi
cmp    $0x3a,%edi
ja     1136 <compute+0x26>
lea    0xee1(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
jmp    1030 <pow@plt>
mulsd  %xmm1,%xmm0
ret
addsd  %xmm1,%xmm0
ret
subsd  %xmm1,%xmm0
ret
divsd  %xmm1,%xmm0
ret

LLVM IR (-O0):
define double @compute(i8 signext %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i8
%6 = alloca double
%7 = alloca double
store i8 %0, i8* %5
store double %1, double* %6
store double %2, double* %7
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %30 [
i32 43, label %10
i32 45, label %14
i32 42, label %18
i32 47, label %22
i32 94, label %26
i32 36, label %26
]
10: ; preds = %3
%11 = load double, double* %6
%12 = load double, double* %7
%13 = fadd double %11, %12
store double %13, double* %4
br label %30
14: ; preds = %3
%15 = load double, double* %6
%16 = load double, double* %7
%17 = fsub double %15, %16
store double %17, double* %4
br label %30
18: ; preds = %3
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fmul double %19, %20
store double %21, double* %4
br label %30
22: ; preds = %3
%23 = load double, double* %6
%24 = load double, double* %7
%25 = fdiv double %23, %24
store double %25, double* %4
br label %30
26: ; preds = %3, %3
%27 = load double, double* %6
%28 = load double, double* %7
%29 = call double @pow(double %27, double %28)
store double %29, double* %4
br label %30
30: ; preds = %10, %14, %18, %22, %26, %3
%31 = load double, double* %4
ret double %31
}

LLVM IR (-O2):
define double @compute(i8 signext %0, double %1, double %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %15 [
i32 43, label %5
i32 45, label %7
i32 42, label %9
i32 47, label %11
i32 94, label %13
i32 36, label %13
]
5: ; preds = %3
%6 = fadd double %1, %2
br label %15
7: ; preds = %3
%8 = fsub double %1, %2
br label %15
9: ; preds = %3
%10 = fmul double %1, %2
br label %15
11: ; preds = %3
%12 = fdiv double %1, %2
br label %15
13: ; preds = %3, %3
%14 = tail call double @pow(double %1, double %2)
br label %15
15: ; preds = %5, %7, %9, %11, %13, %3
%16 = phi double [ undef, %3 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
ret double %16
}