#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int alpm_pkg_vercmp(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int ret;
  if (argc == 1) {
    usage();
    return 2;
  }
  if (argc > 1 &&
      (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)) {
    usage();
    return 0;
  }
  if (argc != 3) {
    fprintf(stderr,
            "error: %d argument(s) specified\n\n"
            "Usage: vercmp <ver1> <ver2>\n",
            argc - 1);
    return EXIT_FAILURE;
  }
  ret = alpm_pkg_vercmp(argv[1], argv[2]);
  printf("%d\n", ret);
  return EXIT_SUCCESS;
}


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   $0x1,-0x8(%rbp)
jne    1183 <main+0x33>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x2,-0x4(%rbp)
jmp    1245 <main+0xf5>
cmpl   $0x1,-0x8(%rbp)
jle    11dc <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11c9 <main+0x79>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe49(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11dc <main+0x8c>
mov    $0x0,%al
call   1070 <usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1245 <main+0xf5>
cmpl   $0x3,-0x8(%rbp)
je     1212 <main+0xc2>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
lea    0xe0e(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1245 <main+0xf5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
call   1060 <alpm_pkg_vercmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    116a <main+0x1a>
xor    %eax,%eax
call   1070 <usage@plt>
mov    $0x2,%ebx
jmp    11f2 <main+0xa2>
mov    %edi,%ebx
jle    11c4 <main+0x74>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe84(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e9 <main+0x99>
mov    0x8(%r14),%rdi
lea    0xe72(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11e9 <main+0x99>
cmp    $0x3,%ebx
jne    11c4 <main+0x74>
mov    0x8(%r14),%rdi
mov    0x10(%r14),%rsi
call   1060 <alpm_pkg_vercmp@plt>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e0e(%rip),%rax
jmp    11e5 <main+0x95>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
add    $0xffffffff,%ebx
lea    0xe33(%rip),%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%ebx
jmp    11f2 <main+0xa2>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <usage@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.2 = [62 x i8] c"error: %d argument(s) specified\0A\0AUsage: vercmp <ver1> <ver2>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 (...) @usage()
store i32 2, i32* %3
br label %48
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp sgt i32 %12, 1
br i1 %13, label %14, label %28
14: ; preds = %11
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %26, label %20
20: ; preds = %14
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strcmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20, %14
%27 = call i32 (...) @usage()
store i32 0, i32* %3
br label %48
28: ; preds = %20, %11
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 3
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* @stderr
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* @EXIT_FAILURE
store i32 %36, i32* %3
br label %48
37: ; preds = %28
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 2
%43 = load i8*, i8** %42
%44 = call i32 @alpm_pkg_vercmp(i8* %40, i8* %43)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* @EXIT_SUCCESS
store i32 %47, i32* %3
br label %48
48: ; preds = %37, %31, %26, %9
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@stderr = global i32 0
@.str.2 = [62 x i8] c"error: %d argument(s) specified\0A\0AUsage: vercmp <ver1> <ver2>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [4 x i8] c"%d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %33
6: ; preds = %2
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %21
8: ; preds = %6
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i8*, i8** %9
%15 = tail call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13, %8
%18 = tail call i32 (...) @usage()
br label %33
19: ; preds = %13
%20 = icmp eq i32 %0, 3
br i1 %20, label %26, label %21
21: ; preds = %6, %19
%22 = load i32, i32* @stderr
%23 = add nsw i32 %0, -1
%24 = tail call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @EXIT_FAILURE
br label %33
26: ; preds = %19
%27 = load i8*, i8** %9
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = tail call i32 @alpm_pkg_vercmp(i8* %27, i8* %29)
%31 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* @EXIT_SUCCESS
br label %33
33: ; preds = %26, %21, %17, %4
%34 = phi i32 [ 2, %4 ], [ 0, %17 ], [ %25, %21 ], [ %32, %26 ]
ret i32 %34
}