#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*/ errx(int, char *, char const *);
scalar_t__ strcmp(char const *, char const *);
scalar_t__ toInteger(char const *);
bool binary(const char *operand1, const char *operator, const char * operand2) {
  if (strcmp(operator, "=") == 0) {
    return strcmp(operand1, operand2) == 0;
  } else if (strcmp(operator, "!=") == 0) {
    return strcmp(operand1, operand2) != 0;
  } else if (strcmp(operator, "-eq") == 0) {
    return toInteger(operand1) == toInteger(operand2);
  } else if (strcmp(operator, "-ne") == 0) {
    return toInteger(operand1) != toInteger(operand2);
  } else if (strcmp(operator, "-gt") == 0) {
    return toInteger(operand1) > toInteger(operand2);
  } else if (strcmp(operator, "-ge") == 0) {
    return toInteger(operand1) >= toInteger(operand2);
  } else if (strcmp(operator, "-lt") == 0) {
    return toInteger(operand1) < toInteger(operand2);
  } else if (strcmp(operator, "-le") == 0) {
    return toInteger(operand1) <= toInteger(operand2);
  } else {
    errx(2, "invalid binary operator '%s'", operator);
  }
}


x86 assembly (clang, -O0):
<binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    117f <binary+0x4f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ba <binary+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xe3e(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1204 <binary+0xd4>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124e <binary+0x11e>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xdb2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1298 <binary+0x168>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
cmp    %rcx,%rax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xd6c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12e2 <binary+0x1b2>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cmp    %rcx,%rax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xd26(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    132c <binary+0x1fc>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cmp    %rcx,%rax
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1376 <binary+0x246>
mov    -0x10(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
cmp    %rcx,%rax
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    13ae <binary+0x27e>
mov    -0x18(%rbp),%rdx
mov    $0x2,%edi
lea    0xc95(%rip),%rsi
call   1030 <errx@plt>
jmp    1390 <binary+0x260>
jmp    1395 <binary+0x265>
jmp    139a <binary+0x26a>
jmp    139f <binary+0x26f>
jmp    13a4 <binary+0x274>
jmp    13a9 <binary+0x279>
jmp    13ae <binary+0x27e>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<binary>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1217 <binary+0xe7>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1232 <binary+0x102>
lea    0xe8e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     124d <binary+0x11d>
lea    0xe7a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1270 <binary+0x140>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1290 <binary+0x160>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12b0 <binary+0x180>
lea    0xe3e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12d0 <binary+0x1a0>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12f0 <binary+0x1c0>
lea    0xe16(%rip),%rsi
mov    $0x2,%edi
mov    %rbx,%rdx
call   1030 <errx@plt>
jmp    130e <binary+0x1de>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
sete   %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setne  %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setg   %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setge  %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setl   %al
jmp    130e <binary+0x1de>
mov    %r15,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1050 <toInteger@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rbx
setle  %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@.str.1 = [3 x i8] c"!=\00"
@.str.2 = [4 x i8] c"-eq\00"
@.str.3 = [4 x i8] c"-ne\00"
@.str.4 = [4 x i8] c"-gt\00"
@.str.5 = [4 x i8] c"-ge\00"
@.str.6 = [4 x i8] c"-lt\00"
@.str.7 = [4 x i8] c"-le\00"
@.str.8 = [29 x i8] c"invalid binary operator '%s'\00"
define i32 @binary(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %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 %17
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = load i8*, i8** %7
%14 = call i64 @strcmp(i8* %12, i8* %13)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
store i32 %16, i32* %4
br label %103
17: ; preds = %3
%18 = load i8*, i8** %6
%19 = call i64 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = load i8*, i8** %7
%24 = call i64 @strcmp(i8* %22, i8* %23)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i32
store i32 %26, i32* %4
br label %103
27: ; preds = %17
%28 = load i8*, i8** %6
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %27
%32 = load i8*, i8** %5
%33 = call i64 @toInteger(i8* %32)
%34 = load i8*, i8** %7
%35 = call i64 @toInteger(i8* %34)
%36 = icmp eq i64 %33, %35
%37 = zext i1 %36 to i32
store i32 %37, i32* %4
br label %103
38: ; preds = %27
%39 = load i8*, i8** %6
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %38
%43 = load i8*, i8** %5
%44 = call i64 @toInteger(i8* %43)
%45 = load i8*, i8** %7
%46 = call i64 @toInteger(i8* %45)
%47 = icmp ne i64 %44, %46
%48 = zext i1 %47 to i32
store i32 %48, i32* %4
br label %103
49: ; preds = %38
%50 = load i8*, i8** %6
%51 = call i64 @strcmp(i8* %50, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %60
53: ; preds = %49
%54 = load i8*, i8** %5
%55 = call i64 @toInteger(i8* %54)
%56 = load i8*, i8** %7
%57 = call i64 @toInteger(i8* %56)
%58 = icmp sgt i64 %55, %57
%59 = zext i1 %58 to i32
store i32 %59, i32* %4
br label %103
60: ; preds = %49
%61 = load i8*, i8** %6
%62 = call i64 @strcmp(i8* %61, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %71
64: ; preds = %60
%65 = load i8*, i8** %5
%66 = call i64 @toInteger(i8* %65)
%67 = load i8*, i8** %7
%68 = call i64 @toInteger(i8* %67)
%69 = icmp sge i64 %66, %68
%70 = zext i1 %69 to i32
store i32 %70, i32* %4
br label %103
71: ; preds = %60
%72 = load i8*, i8** %6
%73 = call i64 @strcmp(i8* %72, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %82
75: ; preds = %71
%76 = load i8*, i8** %5
%77 = call i64 @toInteger(i8* %76)
%78 = load i8*, i8** %7
%79 = call i64 @toInteger(i8* %78)
%80 = icmp slt i64 %77, %79
%81 = zext i1 %80 to i32
store i32 %81, i32* %4
br label %103
82: ; preds = %71
%83 = load i8*, i8** %6
%84 = call i64 @strcmp(i8* %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %93
86: ; preds = %82
%87 = load i8*, i8** %5
%88 = call i64 @toInteger(i8* %87)
%89 = load i8*, i8** %7
%90 = call i64 @toInteger(i8* %89)
%91 = icmp sle i64 %88, %90
%92 = zext i1 %91 to i32
store i32 %92, i32* %4
br label %103
93: ; preds = %82
%94 = load i8*, i8** %6
%95 = call i32 @errx(i32 2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %94)
br label %96
96: ; preds = %93
br label %97
97: ; preds = %96
br label %98
98: ; preds = %97
br label %99
99: ; preds = %98
br label %100
100: ; preds = %99
br label %101
101: ; preds = %100
br label %102
102: ; preds = %101
br label %103
103: ; preds = %11, %21, %31, %42, %53, %64, %75, %86, %102
%104 = load i32, i32* %4
ret i32 %104
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@.str.1 = [3 x i8] c"!=\00"
@.str.2 = [4 x i8] c"-eq\00"
@.str.3 = [4 x i8] c"-ne\00"
@.str.4 = [4 x i8] c"-gt\00"
@.str.5 = [4 x i8] c"-ge\00"
@.str.6 = [4 x i8] c"-lt\00"
@.str.7 = [4 x i8] c"-le\00"
@.str.8 = [29 x i8] c"invalid binary operator '%s'\00"
define i32 @binary(i8* %0, i8* %1, i8* %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 %10
6: ; preds = %3
%7 = tail call i64 @strcmp(i8* %0, i8* %2)
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
br label %67
10: ; preds = %3
%11 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i64 @strcmp(i8* %0, i8* %2)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i32
br label %67
17: ; preds = %10
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = tail call i64 @toInteger(i8* %0)
%22 = tail call i64 @toInteger(i8* %2)
%23 = icmp eq i64 %21, %22
%24 = zext i1 %23 to i32
br label %67
25: ; preds = %17
%26 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = tail call i64 @toInteger(i8* %0)
%30 = tail call i64 @toInteger(i8* %2)
%31 = icmp ne i64 %29, %30
%32 = zext i1 %31 to i32
br label %67
33: ; preds = %25
%34 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = tail call i64 @toInteger(i8* %0)
%38 = tail call i64 @toInteger(i8* %2)
%39 = icmp sgt i64 %37, %38
%40 = zext i1 %39 to i32
br label %67
41: ; preds = %33
%42 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = tail call i64 @toInteger(i8* %0)
%46 = tail call i64 @toInteger(i8* %2)
%47 = icmp sge i64 %45, %46
%48 = zext i1 %47 to i32
br label %67
49: ; preds = %41
%50 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %49
%53 = tail call i64 @toInteger(i8* %0)
%54 = tail call i64 @toInteger(i8* %2)
%55 = icmp slt i64 %53, %54
%56 = zext i1 %55 to i32
br label %67
57: ; preds = %49
%58 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = tail call i64 @toInteger(i8* %0)
%62 = tail call i64 @toInteger(i8* %2)
%63 = icmp sle i64 %61, %62
%64 = zext i1 %63 to i32
br label %67
65: ; preds = %57
%66 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.8, i64 0, i64 0), i8* %1)
br label %67
67: ; preds = %6, %13, %20, %28, %36, %44, %52, %60, %65
%68 = phi i32 [ %9, %6 ], [ %16, %13 ], [ %24, %20 ], [ %32, %28 ], [ %40, %36 ], [ %48, %44 ], [ %56, %52 ], [ %64, %60 ], [ undef, %65 ]
ret i32 %68
}