#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 */
typedef int uint32_t;
typedef int uint16_t;

/* Variables and functions */
#define BPF_JEQ 131
#define BPF_JGE 130
#define BPF_JGT 129
#define BPF_JSET 128
int /*<<< orphan*/ abort();
bool evaluate_cmp(uint16_t cmp, uint32_t a, uint32_t b) {
  switch (cmp) {
  case BPF_JEQ:
    return a == b;
  case BPF_JGT:
    return a > b;
  case BPF_JGE:
    return a >= b;
  case BPF_JSET:
    return (a & b) != 0;
  default:
    abort();
  }
}


x86 assembly (clang, -O0):
<evaluate_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11a5 <evaluate_cmp+0x95>
mov    -0x18(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <evaluate_cmp+0x9c>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <evaluate_cmp+0x9c>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <evaluate_cmp+0x9c>
mov    -0xc(%rbp),%eax
and    -0x10(%rbp),%eax
cmp    $0x0,%eax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <evaluate_cmp+0x9c>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evaluate_cmp>:
push   %rax
add    $0xffffff80,%edi
cmp    $0x3,%edi
ja     1148 <evaluate_cmp+0x38>
lea    0xee0(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
test   %esi,%edx
setne  %al
jmp    1143 <evaluate_cmp+0x33>
cmp    %edx,%esi
setge  %al
jmp    1143 <evaluate_cmp+0x33>
cmp    %edx,%esi
setg   %al
jmp    1143 <evaluate_cmp+0x33>
cmp    %edx,%esi
sete   %al
movzbl %al,%eax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @evaluate_cmp(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %5
switch i32 %8, label %30 [
i32 131, label %9
i32 129, label %14
i32 130, label %19
i32 128, label %24
]
9: ; preds = %3
%10 = load i32, i32* %6
%11 = load i32, i32* %7
%12 = icmp eq i32 %10, %11
%13 = zext i1 %12 to i32
store i32 %13, i32* %4
br label %32
14: ; preds = %3
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = icmp sgt i32 %15, %16
%18 = zext i1 %17 to i32
store i32 %18, i32* %4
br label %32
19: ; preds = %3
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = icmp sge i32 %20, %21
%23 = zext i1 %22 to i32
store i32 %23, i32* %4
br label %32
24: ; preds = %3
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = and i32 %25, %26
%28 = icmp ne i32 %27, 0
%29 = zext i1 %28 to i32
store i32 %29, i32* %4
br label %32
30: ; preds = %3
%31 = call i32 (...) @abort()
unreachable
32: ; preds = %24, %19, %14, %9
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @evaluate_cmp(i32 %0, i32 %1, i32 %2) {
switch i32 %0, label %13 [
i32 131, label %4
i32 129, label %6
i32 130, label %8
i32 128, label %10
]
4: ; preds = %3
%5 = icmp eq i32 %1, %2
br label %15
6: ; preds = %3
%7 = icmp sgt i32 %1, %2
br label %15
8: ; preds = %3
%9 = icmp sge i32 %1, %2
br label %15
10: ; preds = %3
%11 = and i32 %2, %1
%12 = icmp ne i32 %11, 0
br label %15
13: ; preds = %3
%14 = tail call i32 (...) @abort()
unreachable
15: ; preds = %10, %8, %6, %4
%16 = phi i1 [ %12, %10 ], [ %9, %8 ], [ %7, %6 ], [ %5, %4 ]
%17 = zext i1 %16 to i32
ret i32 %17
}