#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*/ assert(int);
scalar_t__ is_operator(char const);
int apply(const char operation, const int operand1, const int operand2) {
  assert(is_operator(operation) && "Unsupported operation");
  switch (operation) {
  case '+':
    return operand1 + operand2;
  case '-':
    return operand1 - operand2;
  case '/':
    return operand1 / operand2;
  case '*':
    return operand1 * operand2;
  default:
    assert(false && "Unsupported operation");
  }
}


x86 assembly (clang, -O0):
<apply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <is_operator@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
je     1159 <apply+0x39>
mov    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    1159 <apply+0x39>
mov    -0x11(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
movsbl -0x5(%rbp),%eax
add    $0xffffffd6,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     11cb <apply+0xab>
mov    -0x20(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <apply+0xb2>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <apply+0xb2>
mov    -0xc(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %eax,-0x4(%rbp)
jmp    11d2 <apply+0xb2>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d2 <apply+0xb2>
xor    %edi,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
call   1040 <is_operator@plt>
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1030 <assert@plt>
add    $0xffffffd6,%ebp
cmp    $0x5,%ebp
ja     1161 <apply+0x41>
lea    0xeb3(%rip),%rax
movslq (%rax,%rbp,4),%rcx
add    %rax,%rcx
jmp    *%rcx
imul   %r14d,%ebx
jmp    117a <apply+0x5a>
add    %r14d,%ebx
jmp    117a <apply+0x5a>
xor    %edi,%edi
call   1030 <assert@plt>
jmp    117a <apply+0x5a>
sub    %ebx,%r14d
mov    %r14d,%ebx
jmp    117a <apply+0x5a>
mov    %r14d,%eax
cltd
idiv   %ebx
mov    %eax,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Unsupported operation\00"
define i32 @apply(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i8, i8* %5
%9 = call i64 @is_operator(i8 signext %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
br label %12
12: ; preds = %11, %3
%13 = phi i1 [ false, %3 ], [ true, %11 ]
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
switch i32 %17, label %34 [
i32 43, label %18
i32 45, label %22
i32 47, label %26
i32 42, label %30
]
18: ; preds = %12
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = add nsw i32 %19, %20
store i32 %21, i32* %4
br label %36
22: ; preds = %12
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = sub nsw i32 %23, %24
store i32 %25, i32* %4
br label %36
26: ; preds = %12
%27 = load i32, i32* %6
%28 = load i32, i32* %7
%29 = sdiv i32 %27, %28
store i32 %29, i32* %4
br label %36
30: ; preds = %12
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = mul nsw i32 %31, %32
store i32 %33, i32* %4
br label %36
34: ; preds = %12
%35 = call i32 @assert(i32 0)
br label %36
36: ; preds = %18, %22, %26, %30, %34
%37 = load i32, i32* %4
ret i32 %37
}

LLVM IR (-O2):
define i32 @apply(i8 signext %0, i32 %1, i32 %2) {
%4 = tail call i64 @is_operator(i8 signext %0)
%5 = icmp ne i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = sext i8 %0 to i32
switch i32 %8, label %17 [
i32 43, label %9
i32 45, label %11
i32 47, label %13
i32 42, label %15
]
9: ; preds = %3
%10 = add nsw i32 %2, %1
br label %19
11: ; preds = %3
%12 = sub nsw i32 %1, %2
br label %19
13: ; preds = %3
%14 = sdiv i32 %1, %2
br label %19
15: ; preds = %3
%16 = mul nsw i32 %2, %1
br label %19
17: ; preds = %3
%18 = tail call i32 @assert(i32 0)
br label %19
19: ; preds = %9, %11, %13, %15, %17
%20 = phi i32 [ undef, %17 ], [ %16, %15 ], [ %14, %13 ], [ %12, %11 ], [ %10, %9 ]
ret i32 %20
}