#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 grecs_version_info {
  int dummy;
};

/* Variables and functions */
int grecs_version_info_cmp(struct grecs_version_info *,
                           struct grecs_version_info *, int *);
int /*<<< orphan*/ grecs_version_info_free(struct grecs_version_info *);
struct grecs_version_info *grecs_version_split(char const *);
int grecs_version_cmp(const char *vstr1, const char *vstr2, int *pres) {
  struct grecs_version_info *v1, *v2;
  int rc;
  if (!vstr1 || !vstr2)
    return -1;
  v1 = grecs_version_split(vstr1);
  if (!v1)
    return -1;
  v2 = grecs_version_split(vstr2);
  if (!v2) {
    grecs_version_info_free(v1);
    return -1;
  }
  rc = grecs_version_info_cmp(v1, v2, pres);
  grecs_version_info_free(v1);
  grecs_version_info_free(v2);
  return rc;
}


x86 assembly (clang, -O0):
<grecs_version_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115a <grecs_version_cmp+0x2a>
cmpq   $0x0,-0x18(%rbp)
jne    1166 <grecs_version_cmp+0x36>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <grecs_version_cmp+0xb3>
mov    -0x10(%rbp),%rdi
call   1030 <grecs_version_split@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118a <grecs_version_cmp+0x5a>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <grecs_version_cmp+0xb3>
mov    -0x18(%rbp),%rdi
call   1030 <grecs_version_split@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b7 <grecs_version_cmp+0x87>
mov    -0x28(%rbp),%rdi
call   1040 <grecs_version_info_free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e3 <grecs_version_cmp+0xb3>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <grecs_version_info_cmp@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <grecs_version_info_free@plt>
mov    -0x30(%rbp),%rdi
call   1040 <grecs_version_info_free@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grecs_version_cmp>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1193 <grecs_version_cmp+0x63>
mov    %rsi,%rbx
test   %rsi,%rsi
je     1193 <grecs_version_cmp+0x63>
mov    %rdx,%r15
call   1030 <grecs_version_split@plt>
test   %rax,%rax
je     1193 <grecs_version_cmp+0x63>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <grecs_version_split@plt>
test   %rax,%rax
je     1186 <grecs_version_cmp+0x56>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    %r15,%rdx
call   1050 <grecs_version_info_cmp@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1040 <grecs_version_info_free@plt>
mov    %rbx,%r14
jmp    118b <grecs_version_cmp+0x5b>
mov    $0xffffffff,%ebp
mov    %r14,%rdi
call   1040 <grecs_version_info_free@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.grecs_version_info = type { i32 }
define i32 @grecs_version_cmp(i8* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.grecs_version_info*
%9 = alloca %struct.grecs_version_info*
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %17, label %16
16: ; preds = %13, %3
store i32 -1, i32* %4
br label %41
17: ; preds = %13
%18 = load i8*, i8** %5
%19 = call %struct.grecs_version_info* @grecs_version_split(i8* %18)
store %struct.grecs_version_info* %19, %struct.grecs_version_info** %8
%20 = load %struct.grecs_version_info*, %struct.grecs_version_info** %8
%21 = icmp ne %struct.grecs_version_info* %20, null
br i1 %21, label %23, label %22
22: ; preds = %17
store i32 -1, i32* %4
br label %41
23: ; preds = %17
%24 = load i8*, i8** %6
%25 = call %struct.grecs_version_info* @grecs_version_split(i8* %24)
store %struct.grecs_version_info* %25, %struct.grecs_version_info** %9
%26 = load %struct.grecs_version_info*, %struct.grecs_version_info** %9
%27 = icmp ne %struct.grecs_version_info* %26, null
br i1 %27, label %31, label %28
28: ; preds = %23
%29 = load %struct.grecs_version_info*, %struct.grecs_version_info** %8
%30 = call i32 @grecs_version_info_free(%struct.grecs_version_info* %29)
store i32 -1, i32* %4
br label %41
31: ; preds = %23
%32 = load %struct.grecs_version_info*, %struct.grecs_version_info** %8
%33 = load %struct.grecs_version_info*, %struct.grecs_version_info** %9
%34 = load i32*, i32** %7
%35 = call i32 @grecs_version_info_cmp(%struct.grecs_version_info* %32, %struct.grecs_version_info* %33, i32* %34)
store i32 %35, i32* %10
%36 = load %struct.grecs_version_info*, %struct.grecs_version_info** %8
%37 = call i32 @grecs_version_info_free(%struct.grecs_version_info* %36)
%38 = load %struct.grecs_version_info*, %struct.grecs_version_info** %9
%39 = call i32 @grecs_version_info_free(%struct.grecs_version_info* %38)
%40 = load i32, i32* %10
store i32 %40, i32* %4
br label %41
41: ; preds = %31, %28, %22, %16
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
%struct.grecs_version_info = type { i32 }
define i32 @grecs_version_cmp(i8* %0, i8* %1, i32* %2) {
%4 = icmp ne i8* %0, null
%5 = icmp ne i8* %1, null
%6 = and i1 %4, %5
br i1 %6, label %7, label %20
7: ; preds = %3
%8 = tail call %struct.grecs_version_info* @grecs_version_split(i8* %0)
%9 = icmp eq %struct.grecs_version_info* %8, null
br i1 %9, label %20, label %10
10: ; preds = %7
%11 = tail call %struct.grecs_version_info* @grecs_version_split(i8* %1)
%12 = icmp eq %struct.grecs_version_info* %11, null
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = tail call i32 @grecs_version_info_cmp(%struct.grecs_version_info* %8, %struct.grecs_version_info* %11, i32* %2)
%15 = tail call i32 @grecs_version_info_free(%struct.grecs_version_info* %8)
br label %16
16: ; preds = %10, %13
%17 = phi %struct.grecs_version_info* [ %11, %13 ], [ %8, %10 ]
%18 = phi i32 [ %14, %13 ], [ -1, %10 ]
%19 = tail call i32 @grecs_version_info_free(%struct.grecs_version_info* %17)
br label %20
20: ; preds = %16, %7, %3
%21 = phi i32 [ -1, %3 ], [ -1, %7 ], [ %18, %16 ]
ret i32 %21
}