#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);
void do_next_op(char operator, double right_operand, double *accumulator) {
  switch (operator) {
  case '+':
    *accumulator += right_operand;
    break;
  case '-':
    *accumulator -= right_operand;
    break;
  case '*':
    *accumulator *= right_operand;
    break;
  case '^':
    *accumulator = pow(*accumulator, right_operand);
    break;
  case '/':
    if (right_operand != 0)
      *accumulator /= right_operand;
    break;
  }
}


x86 assembly (clang, -O0):
<do_next_op>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsbl -0x1(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x2a,%eax
je     11b0 <do_next_op+0xa0>
jmp    113c <do_next_op+0x2c>
mov    -0x1c(%rbp),%eax
sub    $0x2b,%eax
je     1180 <do_next_op+0x70>
jmp    114d <do_next_op+0x3d>
mov    -0x1c(%rbp),%eax
sub    $0x2d,%eax
je     1196 <do_next_op+0x86>
jmp    115e <do_next_op+0x4e>
mov    -0x1c(%rbp),%eax
sub    $0x2f,%eax
je     11e5 <do_next_op+0xd5>
jmp    116f <do_next_op+0x5f>
mov    -0x1c(%rbp),%eax
sub    $0x5e,%eax
je     11c6 <do_next_op+0xb6>
jmp    121c <do_next_op+0x10c>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    121c <do_next_op+0x10c>
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
jmp    121c <do_next_op+0x10c>
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
jmp    121c <do_next_op+0x10c>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1030 <pow@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    121c <do_next_op+0x10c>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1202 <do_next_op+0xf2>
jp     1202 <do_next_op+0xf2>
jmp    1217 <do_next_op+0x107>
movsd  -0x10(%rbp),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
jmp    121c <do_next_op+0x10c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_next_op>:
push   %rbx
mov    %rsi,%rbx
movapd %xmm0,%xmm1
lea    -0x2a(%rdi),%eax
cmp    $0x5,%eax
ja     1136 <do_next_op+0x26>
lea    0xed9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mulsd  (%rbx),%xmm1
jmp    116e <do_next_op+0x5e>
cmp    $0x5e,%edi
jne    1172 <do_next_op+0x62>
movsd  (%rbx),%xmm0
call   1030 <pow@plt>
jmp    116a <do_next_op+0x5a>
addsd  (%rbx),%xmm1
jmp    116e <do_next_op+0x5e>
movsd  (%rbx),%xmm0
subsd  %xmm1,%xmm0
jmp    116a <do_next_op+0x5a>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1162 <do_next_op+0x52>
jnp    1172 <do_next_op+0x62>
movsd  (%rbx),%xmm0
divsd  %xmm1,%xmm0
movapd %xmm0,%xmm1
movsd  %xmm1,(%rbx)
pop    %rbx
ret

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

LLVM IR (-O2):
define void @do_next_op(i8 signext %0, double %1, double* nocapture %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %24 [
i32 43, label %5
i32 45, label %8
i32 42, label %11
i32 94, label %14
i32 47, label %17
]
5: ; preds = %3
%6 = load double, double* %2
%7 = fadd double %6, %1
br label %22
8: ; preds = %3
%9 = load double, double* %2
%10 = fsub double %9, %1
br label %22
11: ; preds = %3
%12 = load double, double* %2
%13 = fmul double %12, %1
br label %22
14: ; preds = %3
%15 = load double, double* %2
%16 = tail call double @pow(double %15, double %1)
br label %22
17: ; preds = %3
%18 = fcmp une double %1, 0.000000e+00
br i1 %18, label %19, label %24
19: ; preds = %17
%20 = load double, double* %2
%21 = fdiv double %20, %1
br label %22
22: ; preds = %5, %8, %11, %14, %19
%23 = phi double [ %21, %19 ], [ %16, %14 ], [ %13, %11 ], [ %10, %8 ], [ %7, %5 ]
store double %23, double* %2
br label %24
24: ; preds = %22, %17, %3
ret void
}