#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 *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int ver_cmp(char *, char *);
int main(int argc, char **argv) {
  int r, res;
  if (argc < 4 || *argv[1] == '\0' || *argv[3] == '\0') {
    printf("version1 lt|gt|le|ge|eq version2\n");
    printf("return value 0 if true, else 1\n\n");
    printf("l = less, g = greater, t = than, e|eq = equal\n");
    return 1;
  }
  r = ver_cmp(argv[1], argv[3]);
  if (!strcmp(argv[2], "le"))
    res = !(r <= 0);
  else if (!strcmp(argv[2], "ge"))
    res = !(r >= 0);
  else if (!strcmp(argv[2], "lt"))
    res = !(r < 0);
  else if (!strcmp(argv[2], "gt"))
    res = !(r > 0);
  else if (!strcmp(argv[2], "eq"))
    res = !(r == 0);
  else {
    printf("unknown operator: %s", argv[2]);
    return 1;
  }
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     1178 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1178 <main+0x48>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11ae <main+0x7e>
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1301 <main+0x1d1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1050 <ver_cmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe9d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11f9 <main+0xc9>
cmpl   $0x0,-0x14(%rbp)
setle  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    12fb <main+0x1cb>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    122c <main+0xfc>
cmpl   $0x0,-0x14(%rbp)
setge  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    12f6 <main+0x1c6>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe3d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    125f <main+0x12f>
cmpl   $0x0,-0x14(%rbp)
setl   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    12f1 <main+0x1c1>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe0d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1292 <main+0x162>
cmpl   $0x0,-0x14(%rbp)
setg   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    12ec <main+0x1bc>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddd(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12c5 <main+0x195>
cmpl   $0x0,-0x14(%rbp)
sete   %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    12e7 <main+0x1b7>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xdad(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1301 <main+0x1d1>
jmp    12ec <main+0x1bc>
jmp    12f1 <main+0x1c1>
jmp    12f6 <main+0x1c6>
jmp    12fb <main+0x1cb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x4,%edi
jl     11ee <main+0xae>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
cmpb   $0x0,(%rdi)
je     11ee <main+0xae>
mov    0x18(%rbx),%rsi
cmpb   $0x0,(%rsi)
je     11ee <main+0xae>
call   1060 <ver_cmp@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rbx
lea    0xe85(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     121e <main+0xde>
lea    0xe71(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1226 <main+0xe6>
lea    0xe5d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     122b <main+0xeb>
lea    0xe4d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1233 <main+0xf3>
lea    0xe3d(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     123b <main+0xfb>
lea    0xe2d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1212 <main+0xd2>
lea    0xe2f(%rip),%rdi
call   1030 <puts@plt>
lea    0xe44(%rip),%rdi
call   1030 <puts@plt>
lea    0xe58(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
test   %ebp,%ebp
setg   %bpl
jmp    1241 <main+0x101>
shr    $0x1f,%ebp
jmp    1241 <main+0x101>
test   %ebp,%ebp
setns  %bpl
jmp    1241 <main+0x101>
test   %ebp,%ebp
setle  %bpl
jmp    1241 <main+0x101>
test   %ebp,%ebp
setne  %bpl
movzbl %bpl,%eax
jmp    1217 <main+0xd7>

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

LLVM IR (-O2):
@.str.3 = [3 x i8] c"le\00"
@.str.4 = [3 x i8] c"ge\00"
@.str.5 = [3 x i8] c"lt\00"
@.str.6 = [3 x i8] c"gt\00"
@.str.7 = [3 x i8] c"eq\00"
@.str.8 = [21 x i8] c"unknown operator: %s\00"
@str = [33 x i8] c"version1 lt|gt|le|ge|eq version2\00"
@str.9 = [32 x i8] c"return value 0 if true, else 1\0A\00"
@str.10 = [46 x i8] c"l = less, g = greater, t = than, e|eq = equal\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %4
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9, %4, %2
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.9, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.10, i64 0, i64 0))
br label %51
18: ; preds = %9
%19 = tail call i32 @ver_cmp(i8* %6, i8* %11)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %18
%25 = icmp sgt i32 %19, 0
br label %48
26: ; preds = %18
%27 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = icmp slt i32 %19, 0
br label %48
31: ; preds = %26
%32 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = icmp sgt i32 %19, -1
br label %48
36: ; preds = %31
%37 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0))
%38 = icmp eq i32 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = icmp slt i32 %19, 1
br label %48
41: ; preds = %36
%42 = tail call i32 @strcmp(i8* dereferenceable(1) %21, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = icmp ne i32 %19, 0
br label %48
46: ; preds = %41
%47 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %21)
br label %51
48: ; preds = %29, %39, %44, %34, %24
%49 = phi i1 [ %45, %44 ], [ %40, %39 ], [ %35, %34 ], [ %30, %29 ], [ %25, %24 ]
%50 = zext i1 %49 to i32
br label %51
51: ; preds = %48, %46, %14
%52 = phi i32 [ 1, %14 ], [ 1, %46 ], [ %50, %48 ]
ret i32 %52
}