#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 *);
double operation(char op, double current, double number) {
  switch (op) {
  case '=':
    return number;
  case '+':
    return current + number;
  case '-':
    return current - number;
  case '*':
    return current * number;
  case '^': {
    double res = 1;
    int i;
    for (i = 0; i < number; i++)
      res *= current;
    return res;
  }
  default:
    printf("\n  Unknown operator.\n\n");
    return current;
  }
}


x86 assembly (clang, -O0):
<operation>:
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
mov    %eax,-0x30(%rbp)
sub    $0x2a,%eax
je     11b8 <operation+0xa8>
jmp    113d <operation+0x2d>
mov    -0x30(%rbp),%eax
sub    $0x2b,%eax
je     1190 <operation+0x80>
jmp    114e <operation+0x3e>
mov    -0x30(%rbp),%eax
sub    $0x2d,%eax
je     11a4 <operation+0x94>
jmp    115f <operation+0x4f>
mov    -0x30(%rbp),%eax
sub    $0x3d,%eax
je     1181 <operation+0x71>
jmp    1170 <operation+0x60>
mov    -0x30(%rbp),%eax
sub    $0x5e,%eax
je     11cc <operation+0xbc>
jmp    1220 <operation+0x110>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <operation+0x126>
movsd  -0x18(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <operation+0x126>
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <operation+0x126>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <operation+0x126>
movsd  0xe2c(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1211 <operation+0x101>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e0 <operation+0xd0>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1236 <operation+0x126>
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<operation>:
push   %rax
movapd %xmm0,%xmm3
lea    -0x2a(%rdi),%eax
cmp    $0x13,%eax
ja     1137 <operation+0x27>
lea    0xee4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
movapd %xmm1,%xmm0
jmp    *%rax
mulsd  %xmm1,%xmm3
jmp    1198 <operation+0x88>
cmp    $0x5e,%edi
jne    1176 <operation+0x66>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    119e <operation+0x8e>
movsd  0xeb2(%rip),%xmm0
mov    $0x1,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
mulsd  %xmm3,%xmm0
add    $0x1,%eax
ucomisd %xmm2,%xmm1
ja     1160 <operation+0x50>
pop    %rax
ret
lea    0xedb(%rip),%rdi
movsd  %xmm3,(%rsp)
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
pop    %rax
ret
addsd  %xmm1,%xmm3
jmp    1198 <operation+0x88>
subsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
pop    %rax
ret
movsd  0xe5a(%rip),%xmm0
pop    %rax
ret

LLVM IR (-O0):
@.str = [23 x i8] c"\0A Unknown operator.\0A\0A\00"
define double @operation(i8 signext %0, double %1, double %2) {
%4 = alloca double
%5 = alloca i8
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i8 %0, i8* %5
store double %1, double* %6
store double %2, double* %7
%10 = load i8, i8* %5
%11 = sext i8 %10 to i32
switch i32 %11, label %41 [
i32 61, label %12
i32 43, label %14
i32 45, label %18
i32 42, label %22
i32 94, label %26
]
12: ; preds = %3
%13 = load double, double* %7
store double %13, double* %4
br label %44
14: ; preds = %3
%15 = load double, double* %6
%16 = load double, double* %7
%17 = fadd double %15, %16
store double %17, double* %4
br label %44
18: ; preds = %3
%19 = load double, double* %6
%20 = load double, double* %7
%21 = fsub double %19, %20
store double %21, double* %4
br label %44
22: ; preds = %3
%23 = load double, double* %6
%24 = load double, double* %7
%25 = fmul double %23, %24
store double %25, double* %4
br label %44
26: ; preds = %3
store double 1.000000e+00, double* %8
store i32 0, i32* %9
br label %27
27: ; preds = %36, %26
%28 = load i32, i32* %9
%29 = sitofp i32 %28 to double
%30 = load double, double* %7
%31 = fcmp olt double %29, %30
br i1 %31, label %32, label %39
32: ; preds = %27
%33 = load double, double* %6
%34 = load double, double* %8
%35 = fmul double %34, %33
store double %35, double* %8
br label %36
36: ; preds = %32
%37 = load i32, i32* %9
%38 = add nsw i32 %37, 1
store i32 %38, i32* %9
br label %27
39: ; preds = %27
%40 = load double, double* %8
store double %40, double* %4
br label %44
41: ; preds = %3
%42 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%43 = load double, double* %6
store double %43, double* %4
br label %44
44: ; preds = %41, %39, %22, %18, %14, %12
%45 = load double, double* %4
ret double %45
}

LLVM IR (-O2):
@str = [22 x i8] c"\0A Unknown operator.\0A\00"
define double @operation(i8 signext %0, double %1, double %2) {
%4 = sext i8 %0 to i32
switch i32 %4, label %20 [
i32 61, label %22
i32 43, label %7
i32 45, label %9
i32 42, label %11
i32 94, label %5
]
5: ; preds = %3
%6 = fcmp ogt double %2, 0.000000e+00
br i1 %6, label %13, label %22
7: ; preds = %3
%8 = fadd double %1, %2
br label %22
9: ; preds = %3
%10 = fsub double %1, %2
br label %22
11: ; preds = %3
%12 = fmul double %1, %2
br label %22
13: ; preds = %5, %13
%14 = phi i32 [ %17, %13 ], [ 0, %5 ]
%15 = phi double [ %16, %13 ], [ 1.000000e+00, %5 ]
%16 = fmul double %15, %1
%17 = add nuw nsw i32 %14, 1
%18 = sitofp i32 %17 to double
%19 = fcmp olt double %18, %2
br i1 %19, label %13, label %22
20: ; preds = %3
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %13, %5, %3, %20, %11, %9, %7
%23 = phi double [ %1, %20 ], [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %2, %3 ], [ 1.000000e+00, %5 ], [ %16, %13 ]
ret double %23
}