#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 */
struct versionrevision {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
int versioncompare(struct versionrevision const *,
                   struct versionrevision const *);
int versionsatisfied3(const struct versionrevision *it,
                      const struct versionrevision *ref, const char *op) {
  int r;
  r = versioncompare(it, ref);
  if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0)
    return r <= 0;
  if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0)
    return r >= 0;
  if (strcmp(op, "<<") == 0)
    return r < 0;
  if (strcmp(op, ">>") == 0)
    return r > 0;
  if (strcmp(op, "=") == 0)
    return r == 0;
  fprintf(stderr, "unknown operator: %s", op);
  exit(1);
}


x86 assembly (clang, -O0):
<versionsatisfied3>:
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    -0x18(%rbp),%rsi
call   1050 <versioncompare@plt>
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe91(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     1198 <versionsatisfied3+0x58>
mov    -0x20(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <versionsatisfied3+0x6c>
cmpl   $0x0,-0x24(%rbp)
setle  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a1 <versionsatisfied3+0x161>
mov    -0x20(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11e0 <versionsatisfied3+0xa0>
mov    -0x20(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11f4 <versionsatisfied3+0xb4>
cmpl   $0x0,-0x24(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a1 <versionsatisfied3+0x161>
mov    -0x20(%rbp),%rdi
lea    0xe07(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <versionsatisfied3+0xe2>
cmpl   $0x0,-0x24(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a1 <versionsatisfied3+0x161>
mov    -0x20(%rbp),%rdi
lea    0xddc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1250 <versionsatisfied3+0x110>
cmpl   $0x0,-0x24(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a1 <versionsatisfied3+0x161>
mov    -0x20(%rbp),%rdi
lea    0xda6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    127e <versionsatisfied3+0x13e>
cmpl   $0x0,-0x24(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    12a1 <versionsatisfied3+0x161>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xd7a(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<versionsatisfied3>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
call   1050 <versioncompare@plt>
mov    %eax,%ebx
lea    0xeab(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e1 <versionsatisfied3+0xa1>
lea    0xe9e(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e1 <versionsatisfied3+0xa1>
lea    0xe86(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e8 <versionsatisfied3+0xa8>
lea    0xe79(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e8 <versionsatisfied3+0xa8>
lea    0xe61(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11f8 <versionsatisfied3+0xb8>
lea    0xe50(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11fd <versionsatisfied3+0xbd>
lea    0xe34(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1204 <versionsatisfied3+0xc4>
test   %ebx,%ebx
sete   %bl
jmp    11ed <versionsatisfied3+0xad>
test   %ebx,%ebx
setle  %bl
jmp    11ed <versionsatisfied3+0xad>
test   %ebx,%ebx
setns  %bl
movzbl %bl,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
shr    $0x1f,%ebx
jmp    11ed <versionsatisfied3+0xad>
test   %ebx,%ebx
setg   %bl
jmp    11ed <versionsatisfied3+0xad>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
lea    0xdf8(%rip),%rsi
mov    %r14,%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.versionrevision = type { i32 }
@.str = [3 x i8] c"<=\00"
@.str.1 = [2 x i8] c"<\00"
@.str.2 = [3 x i8] c">=\00"
@.str.3 = [2 x i8] c">\00"
@.str.4 = [3 x i8] c"<<\00"
@.str.5 = [3 x i8] c">>\00"
@.str.6 = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.7 = [21 x i8] c"unknown operator: %s\00"
define i32 @versionsatisfied3(%struct.versionrevision* %0, %struct.versionrevision* %1, i8* %2) {
%4 = alloca i32
%5 = alloca %struct.versionrevision*
%6 = alloca %struct.versionrevision*
%7 = alloca i8*
%8 = alloca i32
store %struct.versionrevision* %0, %struct.versionrevision** %5
store %struct.versionrevision* %1, %struct.versionrevision** %6
store i8* %2, i8** %7
%9 = load %struct.versionrevision*, %struct.versionrevision** %5
%10 = load %struct.versionrevision*, %struct.versionrevision** %6
%11 = call i32 @versioncompare(%struct.versionrevision* %9, %struct.versionrevision* %10)
store i32 %11, i32* %8
%12 = load i8*, i8** %7
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = load i8*, i8** %7
%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, %3
%20 = load i32, i32* %8
%21 = icmp sle i32 %20, 0
%22 = zext i1 %21 to i32
store i32 %22, i32* %4
br label %64
23: ; preds = %15
%24 = load i8*, i8** %7
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8*, i8** %7
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %35
31: ; preds = %27, %23
%32 = load i32, i32* %8
%33 = icmp sge i32 %32, 0
%34 = zext i1 %33 to i32
store i32 %34, i32* %4
br label %64
35: ; preds = %27
%36 = load i8*, i8** %7
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %35
%40 = load i32, i32* %8
%41 = icmp slt i32 %40, 0
%42 = zext i1 %41 to i32
store i32 %42, i32* %4
br label %64
43: ; preds = %35
%44 = load i8*, i8** %7
%45 = call i64 @strcmp(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = load i32, i32* %8
%49 = icmp sgt i32 %48, 0
%50 = zext i1 %49 to i32
store i32 %50, i32* %4
br label %64
51: ; preds = %43
%52 = load i8*, i8** %7
%53 = call i64 @strcmp(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %51
%56 = load i32, i32* %8
%57 = icmp eq i32 %56, 0
%58 = zext i1 %57 to i32
store i32 %58, i32* %4
br label %64
59: ; preds = %51
%60 = load i32, i32* @stderr
%61 = load i8*, i8** %7
%62 = call i32 @fprintf(i32 %60, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %61)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %55, %47, %39, %31, %19
%65 = load i32, i32* %4
ret i32 %65
}

LLVM IR (-O2):
%struct.versionrevision = type { i32 }
@.str = [3 x i8] c"<=\00"
@.str.1 = [2 x i8] c"<\00"
@.str.2 = [3 x i8] c">=\00"
@.str.3 = [2 x i8] c">\00"
@.str.4 = [3 x i8] c"<<\00"
@.str.5 = [3 x i8] c">>\00"
@.str.6 = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.7 = [21 x i8] c"unknown operator: %s\00"
define i32 @versionsatisfied3(%struct.versionrevision* %0, %struct.versionrevision* %1, i8* %2) {
%4 = tail call i32 @versioncompare(%struct.versionrevision* %0, %struct.versionrevision* %1)
%5 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7, %3
%11 = icmp slt i32 %4, 1
br label %39
12: ; preds = %7
%13 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15, %12
%19 = icmp sgt i32 %4, -1
br label %39
20: ; preds = %15
%21 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = icmp slt i32 %4, 0
br label %39
25: ; preds = %20
%26 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = icmp sgt i32 %4, 0
br label %39
30: ; preds = %25
%31 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = icmp eq i32 %4, 0
br label %39
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = tail call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%38 = tail call i32 @exit(i32 1)
unreachable
39: ; preds = %33, %28, %23, %18, %10
%40 = phi i1 [ %11, %10 ], [ %19, %18 ], [ %24, %23 ], [ %29, %28 ], [ %34, %33 ]
%41 = zext i1 %40 to i32
ret i32 %41
}