#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 *);
int perform_operation(int arg1, int arg2, char *operation) {
  if (strcmp(operation, "+") == 0) {
    return arg1 + arg2;
  } else if (strcmp(operation, "++") == 0) {
    return ++arg1;
  } else if (strcmp(operation, "-") == 0 ||
             (operation[0] == '+' && operation[1] == '+')) {
    return arg1 - arg2;
  } else if (strcmp(operation, "*") == 0) {
    return arg1 * arg2;
  } else if (strcmp(operation, "/") == 0) {
    return arg1 / arg2;
  } else if (strcmp(operation, "%") == 0) {
    return arg1 % arg2;
  } else if (strcmp(operation, "!") == 0) {
    return !arg1;
  }
  return 42;
}


x86 assembly (clang, -O0):
<perform_operation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xed4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    114a <perform_operation+0x3a>
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1175 <perform_operation+0x65>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xe83(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11b0 <perform_operation+0xa0>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    11be <perform_operation+0xae>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x2b,%eax
jne    11be <perform_operation+0xae>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e7 <perform_operation+0xd7>
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xe15(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1210 <perform_operation+0x100>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xdee(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1239 <perform_operation+0x129>
mov    -0x8(%rbp),%eax
cltd
idivl  -0xc(%rbp)
mov    %edx,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
mov    -0x18(%rbp),%rdi
lea    0xdc7(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1269 <perform_operation+0x159>
cmpl   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    128e <perform_operation+0x17e>
jmp    126e <perform_operation+0x15e>
jmp    1273 <perform_operation+0x163>
jmp    1278 <perform_operation+0x168>
jmp    127d <perform_operation+0x16d>
jmp    1282 <perform_operation+0x172>
jmp    1287 <perform_operation+0x177>
movl   $0x2a,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<perform_operation>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbp
mov    %esi,%ebx
mov    %edi,%r14d
lea    0xede(%rip),%rsi
mov    %rdx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116f <perform_operation+0x5f>
lea    0xec9(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1177 <perform_operation+0x67>
lea    0xeb8(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1164 <perform_operation+0x54>
cmpb   $0x2b,0x0(%rbp)
jne    1180 <perform_operation+0x70>
cmpb   $0x2b,0x1(%rbp)
jne    1180 <perform_operation+0x70>
sub    %ebx,%r14d
mov    %r14d,%ebx
jmp    11f7 <perform_operation+0xe7>
add    %r14d,%ebx
jmp    11f7 <perform_operation+0xe7>
add    $0x1,%r14d
mov    %r14d,%ebx
jmp    11f7 <perform_operation+0xe7>
lea    0xe7e(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11df <perform_operation+0xcf>
lea    0xe6c(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e5 <perform_operation+0xd5>
lea    0xe5a(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ef <perform_operation+0xdf>
lea    0xe48(%rip),%rsi
mov    %rbp,%rdi
call   1030 <strcmp@plt>
mov    $0x2a,%ebx
test   %rax,%rax
jne    11f7 <perform_operation+0xe7>
xor    %ebx,%ebx
test   %r14d,%r14d
sete   %bl
jmp    11f7 <perform_operation+0xe7>
imul   %r14d,%ebx
jmp    11f7 <perform_operation+0xe7>
mov    %r14d,%eax
cltd
idiv   %ebx
mov    %eax,%ebx
jmp    11f7 <perform_operation+0xe7>
mov    %r14d,%eax
cltd
idiv   %ebx
mov    %edx,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"+\00"
@.str.1 = [3 x i8] c"++\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [2 x i8] c"%\00"
@.str.6 = [2 x i8] c"!\00"
define i32 @perform_operation(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%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 = 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 i32, i32* %5
%13 = load i32, i32* %6
%14 = add nsw i32 %12, %13
store i32 %14, i32* %4
br label %82
15: ; preds = %3
%16 = load i8*, i8** %7
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %15
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
store i32 %21, i32* %5
store i32 %21, i32* %4
br label %82
22: ; preds = %15
%23 = load i8*, i8** %7
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %38, label %26
26: ; preds = %22
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 43
br i1 %31, label %32, label %42
32: ; preds = %26
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i64 1
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 43
br i1 %37, label %38, label %42
38: ; preds = %32, %22
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = sub nsw i32 %39, %40
store i32 %41, i32* %4
br label %82
42: ; preds = %32, %26
%43 = load i8*, i8** %7
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = mul nsw i32 %47, %48
store i32 %49, i32* %4
br label %82
50: ; preds = %42
%51 = load i8*, i8** %7
%52 = call i64 @strcmp(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i32, i32* %5
%56 = load i32, i32* %6
%57 = sdiv i32 %55, %56
store i32 %57, i32* %4
br label %82
58: ; preds = %50
%59 = load i8*, i8** %7
%60 = call i64 @strcmp(i8* %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%61 = icmp eq i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* %5
%64 = load i32, i32* %6
%65 = srem i32 %63, %64
store i32 %65, i32* %4
br label %82
66: ; preds = %58
%67 = load i8*, i8** %7
%68 = call i64 @strcmp(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %75
70: ; preds = %66
%71 = load i32, i32* %5
%72 = icmp ne i32 %71, 0
%73 = xor i1 %72, true
%74 = zext i1 %73 to i32
store i32 %74, i32* %4
br label %82
75: ; preds = %66
br label %76
76: ; preds = %75
br label %77
77: ; preds = %76
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
br label %80
80: ; preds = %79
br label %81
81: ; preds = %80
store i32 42, i32* %4
br label %82
82: ; preds = %81, %70, %62, %54, %46, %38, %19, %11
%83 = load i32, i32* %4
ret i32 %83
}

LLVM IR (-O2):
@.str = [2 x i8] c"+\00"
@.str.1 = [3 x i8] c"++\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [2 x i8] c"*\00"
@.str.4 = [2 x i8] c"/\00"
@.str.5 = [2 x i8] c"%\00"
@.str.6 = [2 x i8] c"!\00"
define i32 @perform_operation(i32 %0, i32 %1, i8* %2) {
%4 = tail call i64 @strcmp(i8* %2, 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 i32 %1, %0
br label %46
8: ; preds = %3
%9 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 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 = add nsw i32 %0, 1
br label %46
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %2, 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 %23, label %16
16: ; preds = %13
%17 = load i8, i8* %2
%18 = icmp eq i8 %17, 43
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = getelementptr inbounds i8, i8* %2, i64 1
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 43
br i1 %22, label %23, label %25
23: ; preds = %19, %13
%24 = sub nsw i32 %0, %1
br label %46
25: ; preds = %19, %16
%26 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = mul nsw i32 %1, %0
br label %46
30: ; preds = %25
%31 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = sdiv i32 %0, %1
br label %46
35: ; preds = %30
%36 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = srem i32 %0, %1
br label %46
40: ; preds = %35
%41 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40
%44 = icmp eq i32 %0, 0
%45 = zext i1 %44 to i32
br label %46
46: ; preds = %40, %43, %38, %33, %28, %23, %11, %6
%47 = phi i32 [ %7, %6 ], [ %12, %11 ], [ %24, %23 ], [ %29, %28 ], [ %34, %33 ], [ %39, %38 ], [ %45, %43 ], [ 42, %40 ]
ret i32 %47
}