#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 */
scalar_t__ strcmp(char *, char *);
long eval_op(long x, char *op, long y) {
  if (strcmp(op, "+") == 0)
    return x + y;
  if (strcmp(op, "-") == 0)
    return x - y;
  if (strcmp(op, "*") == 0)
    return x * y;
  if (strcmp(op, "/") == 0)
    return x / y;
  return 0;
}


x86 assembly (clang, -O0):
<eval_op>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xed1(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    114f <eval_op+0x3f>
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11db <eval_op+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xea8(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117a <eval_op+0x6a>
mov    -0x10(%rbp),%rax
sub    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11db <eval_op+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11a6 <eval_op+0x96>
mov    -0x10(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11db <eval_op+0xcb>
mov    -0x18(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11d3 <eval_op+0xc3>
mov    -0x10(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,-0x8(%rbp)
jmp    11db <eval_op+0xcb>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_op>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1173 <eval_op+0x63>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1178 <eval_op+0x68>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1180 <eval_op+0x70>
lea    0xea5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1186 <eval_op+0x76>
xor    %r15d,%r15d
jmp    11aa <eval_op+0x9a>
add    %r14,%r15
jmp    11aa <eval_op+0x9a>
sub    %r15,%r14
mov    %r14,%r15
jmp    11aa <eval_op+0x9a>
imul   %r14,%r15
jmp    11aa <eval_op+0x9a>
mov    %r14,%rax
or     %r15,%rax
shr    $0x20,%rax
je     119f <eval_op+0x8f>
mov    %r14,%rax
cqto
idiv   %r15
mov    %rax,%r15
jmp    11aa <eval_op+0x9a>
mov    %r14d,%eax
xor    %edx,%edx
div    %r15d
mov    %eax,%r15d
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"/\00"
define i64 @eval_op(i64 %0, i8* %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i64
store i64 %0, i64* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%8 = load i8*, i8** %6
%9 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i64, i64* %5
%13 = load i64, i64* %7
%14 = add nsw i64 %12, %13
store i64 %14, i64* %4
br label %40
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i64, i64* %5
%21 = load i64, i64* %7
%22 = sub nsw i64 %20, %21
store i64 %22, i64* %4
br label %40
23: ; preds = %15
%24 = load i8*, i8** %6
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = load i64, i64* %5
%29 = load i64, i64* %7
%30 = mul nsw i64 %28, %29
store i64 %30, i64* %4
br label %40
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %31
%36 = load i64, i64* %5
%37 = load i64, i64* %7
%38 = sdiv i64 %36, %37
store i64 %38, i64* %4
br label %40
39: ; preds = %31
store i64 0, i64* %4
br label %40
40: ; preds = %39, %35, %27, %19, %11
%41 = load i64, i64* %4
ret i64 %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [2 x i8] c"*\00"
@.str.3 = [2 x i8] c"/\00"
define i64 @eval_op(i64 %0, i8* %1, i64 %2) {
%4 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = add nsw i64 %2, %0
br label %23
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = sub nsw i64 %0, %2
br label %23
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = mul nsw i64 %2, %0
br label %23
18: ; preds = %13
%19 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = sdiv i64 %0, %2
br label %23
23: ; preds = %18, %21, %16, %11, %6
%24 = phi i64 [ %7, %6 ], [ %12, %11 ], [ %17, %16 ], [ %22, %21 ], [ 0, %18 ]
ret i64 %24
}