#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 find_year(char *, int);
int check_year(char *dob1, int len1, char *dob2, int len2) {
  int year1, year2;
  year1 = find_year(dob1, len1);
  year2 = find_year(dob2, len2);
  if ((year1 < 0) || (year2 < 0)) {
    return -1;
  } else if ((year1 - year2) > 0) {
    return 2;
  } else if ((year1 - year2) < 0) {
    return 1;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<check_year>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <find_year@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1030 <find_year@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1158 <check_year+0x48>
cmpl   $0x0,-0x2c(%rbp)
jge    1164 <check_year+0x54>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a1 <check_year+0x91>
mov    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
cmp    $0x0,%eax
jle    117f <check_year+0x6f>
movl   $0x2,-0x4(%rbp)
jmp    11a1 <check_year+0x91>
mov    -0x28(%rbp),%eax
sub    -0x2c(%rbp),%eax
cmp    $0x0,%eax
jge    119a <check_year+0x8a>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <check_year+0x91>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_year>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbp
call   1030 <find_year@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <find_year@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ebx,%ebx
js     114a <check_year+0x3a>
test   %ecx,%ecx
js     114a <check_year+0x3a>
mov    $0x2,%eax
sub    %ecx,%ebx
jg     114a <check_year+0x3a>
setne  %al
movzbl %al,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_year(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i32 @find_year(i8* %12, i32 %13)
store i32 %14, i32* %10
%15 = load i8*, i8** %8
%16 = load i32, i32* %9
%17 = call i32 @find_year(i8* %15, i32 %16)
store i32 %17, i32* %11
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %4
%21 = load i32, i32* %11
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20, %4
store i32 -1, i32* %5
br label %37
24: ; preds = %20
%25 = load i32, i32* %10
%26 = load i32, i32* %11
%27 = sub nsw i32 %25, %26
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 2, i32* %5
br label %37
30: ; preds = %24
%31 = load i32, i32* %10
%32 = load i32, i32* %11
%33 = sub nsw i32 %31, %32
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %30
store i32 1, i32* %5
br label %37
36: ; preds = %30
store i32 0, i32* %5
br label %37
37: ; preds = %36, %35, %29, %23
%38 = load i32, i32* %5
ret i32 %38
}

LLVM IR (-O2):
define i32 @check_year(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32 @find_year(i8* %0, i32 %1)
%6 = tail call i32 @find_year(i8* %2, i32 %3)
%7 = icmp slt i32 %5, 0
%8 = icmp slt i32 %6, 0
%9 = select i1 %7, i1 true, i1 %8
br i1 %9, label %16, label %10
10: ; preds = %4
%11 = sub nsw i32 %5, %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = icmp ne i32 %11, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %13, %10, %4
%17 = phi i32 [ -1, %4 ], [ 2, %10 ], [ %15, %13 ]
ret i32 %17
}