#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*/ syserr(char *, char *);
float process_operation(int val1, int val2, char op) {
  switch (op) {
  case '+':
    return (float)val1 + val2;
    break;
  case '-':
    return (float)val1 - val2;
    break;
  case '*':
    return (float)val1 * val2;
    break;
  case '/':
    return (float)val1 / val2;
    break;
  default:
    syserr("process operation() ", "not valid operator");
    break;
  }
  return -1;
}


x86 assembly (clang, -O0):
<process_operation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x5,%eax
ja     11ad <process_operation+0x9d>
mov    -0x18(%rbp),%rax
lea    0xec0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cd <process_operation+0xbd>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cd <process_operation+0xbd>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cd <process_operation+0xbd>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11cd <process_operation+0xbd>
lea    0xe68(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1030 <syserr@plt>
movss  0xe38(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_operation>:
push   %rax
add    $0xffffffd6,%edx
cmp    $0x5,%edx
ja     1145 <process_operation+0x35>
lea    0xee4(%rip),%rax
movslq (%rax,%rdx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
cvtsi2ss %edi,%xmm1
cvtsi2ss %esi,%xmm0
mulss  %xmm1,%xmm0
pop    %rax
ret
cvtsi2ss %edi,%xmm1
cvtsi2ss %esi,%xmm0
addss  %xmm1,%xmm0
pop    %rax
ret
lea    0xed0(%rip),%rdi
lea    0xede(%rip),%rsi
call   1030 <syserr@plt>
movss  0xea0(%rip),%xmm0
pop    %rax
ret
cvtsi2ss %edi,%xmm0
cvtsi2ss %esi,%xmm1
subss  %xmm1,%xmm0
pop    %rax
ret
cvtsi2ss %edi,%xmm0
cvtsi2ss %esi,%xmm1
divss  %xmm1,%xmm0
pop    %rax
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"process operation() \00"
@.str.1 = [19 x i8] c"not valid operator\00"
define float @process_operation(i32 %0, i32 %1, i8 signext %2) {
%4 = sext i8 %2 to i32
switch i32 %4, label %21 [
i32 43, label %5
i32 45, label %9
i32 42, label %13
i32 47, label %17
]
5: ; preds = %3
%6 = sitofp i32 %0 to float
%7 = sitofp i32 %1 to float
%8 = fadd float %6, %7
br label %23
9: ; preds = %3
%10 = sitofp i32 %0 to float
%11 = sitofp i32 %1 to float
%12 = fsub float %10, %11
br label %23
13: ; preds = %3
%14 = sitofp i32 %0 to float
%15 = sitofp i32 %1 to float
%16 = fmul float %14, %15
br label %23
17: ; preds = %3
%18 = sitofp i32 %0 to float
%19 = sitofp i32 %1 to float
%20 = fdiv float %18, %19
br label %23
21: ; preds = %3
%22 = tail call i32 @syserr(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17, %13, %9, %5
%24 = phi float [ -1.000000e+00, %21 ], [ %20, %17 ], [ %16, %13 ], [ %12, %9 ], [ %8, %5 ]
ret float %24
}