#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*/ printf(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int ver_cmp(char *, char *);
int vercmp_func(char *arg1, char *arg2, char *arg3) {
  int r, res;
  r = ver_cmp(arg1, arg3);
  if (!strcmp(arg2, "le"))
    res = !(r <= 0);
  else if (!strcmp(arg2, "ge"))
    res = !(r >= 0);
  else if (!strcmp(arg2, "lt"))
    res = !(r < 0);
  else if (!strcmp(arg2, "gt"))
    res = !(r > 0);
  else if (!strcmp(arg2, "eq"))
    res = !(r == 0);
  else {
    printf("unknown operator: %s", arg2);
    return 1;
  }
  return res;
}


x86 assembly (clang, -O0):
<vercmp_func>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <ver_cmp@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1183 <vercmp_func+0x53>
cmpl   $0x0,-0x24(%rbp)
setle  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    126f <vercmp_func+0x13f>
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11b2 <vercmp_func+0x82>
cmpl   $0x0,-0x24(%rbp)
setge  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    126a <vercmp_func+0x13a>
mov    -0x18(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e1 <vercmp_func+0xb1>
cmpl   $0x0,-0x24(%rbp)
setl   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    1265 <vercmp_func+0x135>
mov    -0x18(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1210 <vercmp_func+0xe0>
cmpl   $0x0,-0x24(%rbp)
setg   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    1260 <vercmp_func+0x130>
mov    -0x18(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    123f <vercmp_func+0x10f>
cmpl   $0x0,-0x24(%rbp)
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x28(%rbp)
jmp    125b <vercmp_func+0x12b>
mov    -0x18(%rbp),%rsi
lea    0xdc5(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1275 <vercmp_func+0x145>
jmp    1260 <vercmp_func+0x130>
jmp    1265 <vercmp_func+0x135>
jmp    126a <vercmp_func+0x13a>
jmp    126f <vercmp_func+0x13f>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vercmp_func>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdx,%rsi
call   1050 <ver_cmp@plt>
mov    %eax,%ebp
lea    0xeb9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b5 <vercmp_func+0x85>
lea    0xea9(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11bd <vercmp_func+0x8d>
lea    0xe99(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c2 <vercmp_func+0x92>
lea    0xe89(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11ca <vercmp_func+0x9a>
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d2 <vercmp_func+0xa2>
lea    0xe69(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    11dc <vercmp_func+0xac>
test   %ebp,%ebp
setg   %bpl
jmp    11d8 <vercmp_func+0xa8>
shr    $0x1f,%ebp
jmp    11d8 <vercmp_func+0xa8>
test   %ebp,%ebp
setns  %bpl
jmp    11d8 <vercmp_func+0xa8>
test   %ebp,%ebp
setle  %bpl
jmp    11d8 <vercmp_func+0xa8>
test   %ebp,%ebp
setne  %bpl
movzbl %bpl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"le\00"
@.str.1 = [3 x i8] c"ge\00"
@.str.2 = [3 x i8] c"lt\00"
@.str.3 = [3 x i8] c"gt\00"
@.str.4 = [3 x i8] c"eq\00"
@.str.5 = [21 x i8] c"unknown operator: %s\00"
define i32 @vercmp_func(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @ver_cmp(i8* %0, i8* %2)
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = icmp sgt i32 %4, 0
br label %31
9: ; preds = %3
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = icmp slt i32 %4, 0
br label %31
14: ; preds = %9
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = icmp sgt i32 %4, -1
br label %31
19: ; preds = %14
%20 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = icmp slt i32 %4, 1
br label %31
24: ; preds = %19
%25 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %24
%28 = icmp ne i32 %4, 0
br label %31
29: ; preds = %24
%30 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %1)
br label %34
31: ; preds = %12, %22, %27, %17, %7
%32 = phi i1 [ %28, %27 ], [ %23, %22 ], [ %18, %17 ], [ %13, %12 ], [ %8, %7 ]
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %31, %29
%35 = phi i32 [ 1, %29 ], [ %33, %31 ]
ret i32 %35
}