#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int check_date(int day, int month, int year) {
  int check = 0, keish_age = 1987, my_age = 1988, a_year = 2009;
  char c;
  FILE *fd2;
  keish_age = year - keish_age;
  my_age = year - my_age;
  a_year = year - a_year;
  if (day == 26 && (month + 1) == 1) {
    fd2 = fopen("b_day.aa", "r");
    while ((c = fgetc(fd2)) != EOF)
      putchar(c);
    fclose(fd2);
    printf("\n\tThats Your BIRTHDAY!!!... You will be %d years old, ",
           keish_age);
    printf("\n\t\t\tWowiee old as hell\n\t\tImma get u something nice :-)\n\n");
    check = 1;
  }
  if (day == 26 && (month + 1) == 10) {
    printf("\n\tThats my birthday, nothing special... I will be %d years old, ",
           my_age);
    printf("\n\t\tYou dont have to get me anything\n\n");
    check = 2;
    if (year == 2012)
      check = 3;
  }
  if (day == 22 && (month + 1) == 2) {
    fd2 = fopen("anniversary.aa", "r");
    while ((c = fgetc(fd2)) != EOF)
      putchar(c);
    fclose(fd2);
    printf("\n\t\tThats our ANNIVERSARY!!!... %d years huh?, ", a_year);
    printf("\n\tWe have many more after this, but each one is just as "
           "important\n\n");
    check = 4;
  }
  if (day == 14 && (month + 1) == 2 && year == 2011) {
    printf("\n\n\tDang... we missed valentines day but...\n\n");
    check = 5;
  }
  return check;
}


x86 assembly (clang, -O0):
<check_date>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x7c3,-0x14(%rbp)
movl   $0x7c4,-0x18(%rbp)
movl   $0x7d9,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1a,-0x4(%rbp)
jne    1226 <check_date+0xd6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    $0x1,%eax
jne    1226 <check_date+0xd6>
lea    0xe48(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2e0a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     11f7 <check_date+0xa7>
movsbl -0x1d(%rbp),%edi
call   1030 <putchar@plt>
jmp    11c8 <check_date+0x78>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x1a,-0x4(%rbp)
jne    127e <check_date+0x12e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    $0xa,%eax
jne    127e <check_date+0x12e>
mov    -0x18(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x2,-0x10(%rbp)
cmpl   $0x7dc,-0xc(%rbp)
jne    1279 <check_date+0x129>
movl   $0x3,-0x10(%rbp)
jmp    127e <check_date+0x12e>
cmpl   $0x16,-0x4(%rbp)
jne    130c <check_date+0x1bc>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    $0x2,%eax
jne    130c <check_date+0x1bc>
lea    0xe44(%rip),%rdi
lea    0xd64(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x1d(%rbp)
movsbl %al,%eax
mov    0x2d24(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     12dd <check_date+0x18d>
movsbl -0x1d(%rbp),%edi
call   1030 <putchar@plt>
jmp    12ae <check_date+0x15e>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x1c(%rbp),%esi
lea    0xe01(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x4,-0x10(%rbp)
cmpl   $0xe,-0x4(%rbp)
jne    1347 <check_date+0x1f7>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cmp    $0x2,%eax
jne    1347 <check_date+0x1f7>
cmpl   $0x7db,-0xc(%rbp)
jne    1347 <check_date+0x1f7>
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x5,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_date>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r12d
mov    %edi,%r13d
xor    %eax,%eax
cmp    $0x1a,%edi
jne    11ee <check_date+0x8e>
test   %r12d,%r12d
jne    11ee <check_date+0x8e>
lea    -0x7c3(%r14),%r15d
lea    0xe72(%rip),%rdi
lea    0xe74(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    0x2e3c(%rip),%rbx
cmp    (%rbx),%al
je     11c4 <check_date+0x64>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbp,%rdi
call   1070 <fgetc@plt>
cmp    (%rbx),%al
jne    11b0 <check_date+0x50>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xe38(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf71(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
cmp    $0x1a,%r13d
jne    122f <check_date+0xcf>
cmp    $0x9,%r12d
jne    122f <check_date+0xcf>
lea    -0x7c4(%r14),%esi
lea    0xe3a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf1a(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
cmp    $0x7dc,%r14d
sete   %al
or     $0x2,%eax
jmp    12d4 <check_date+0x174>
cmp    $0x16,%r13d
jne    12ae <check_date+0x14e>
cmp    $0x1,%r12d
jne    12ae <check_date+0x14e>
lea    -0x7d9(%r14),%r15d
lea    0xe3a(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1070 <fgetc@plt>
mov    0x2d81(%rip),%rbx
cmp    (%rbx),%al
je     1284 <check_date+0x124>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1030 <putchar@plt>
mov    %rbp,%rdi
call   1070 <fgetc@plt>
cmp    (%rbx),%al
jne    1270 <check_date+0x110>
mov    %rbp,%rdi
call   1050 <fclose@plt>
lea    0xdff(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe49(%rip),%rdi
call   1040 <puts@plt>
mov    $0x4,%eax
cmp    $0xe,%r13d
jne    12d4 <check_date+0x174>
cmp    $0x1,%r12d
jne    12d4 <check_date+0x174>
cmp    $0x7db,%r14d
jne    12d4 <check_date+0x174>
lea    0xdf7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x5,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"b_day.aa\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [55 x i8] c"\0A\09Thats Your BIRTHDAY!!!... You will be %d years old, \00"
@.str.3 = [57 x i8] c"\0A\09\09\09Wowiee old as hell\0A\09\09Imma get u something nice :-)\0A\0A\00"
@.str.4 = [65 x i8] c"\0A\09Thats my birthday, nothing special... I will be %d years old, \00"
@.str.5 = [38 x i8] c"\0A\09\09You dont have to get me anything\0A\0A\00"
@.str.6 = [15 x i8] c"anniversary.aa\00"
@.str.7 = [47 x i8] c"\0A\09\09Thats our ANNIVERSARY!!!... %d years huh?, \00"
@.str.8 = [68 x i8] c"\0A\09We have many more after this, but each one is just as important\0A\0A\00"
@.str.9 = [45 x i8] c"\0A\0A\09Dang... we missed valentines day but...\0A\0A\00"
define i32 @check_date(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8
%12 = alloca i32*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 1987, i32* %8
store i32 1988, i32* %9
store i32 2009, i32* %10
%13 = load i32, i32* %6
%14 = load i32, i32* %8
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %8
%16 = load i32, i32* %6
%17 = load i32, i32* %9
%18 = sub nsw i32 %16, %17
store i32 %18, i32* %9
%19 = load i32, i32* %6
%20 = load i32, i32* %10
%21 = sub nsw i32 %19, %20
store i32 %21, i32* %10
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 26
br i1 %23, label %24, label %46
24: ; preds = %3
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %46
28: ; preds = %24
%29 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %12
br label %30
30: ; preds = %37, %28
%31 = load i32*, i32** %12
%32 = call signext i8 @fgetc(i32* %31)
store i8 %32, i8* %11
%33 = sext i8 %32 to i32
%34 = load i8, i8* @EOF
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %33, %35
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i8, i8* %11
%39 = call i32 @putchar(i8 signext %38)
br label %30
40: ; preds = %30
%41 = load i32*, i32** %12
%42 = call i32 @fclose(i32* %41)
%43 = load i32, i32* %8
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %7
br label %46
46: ; preds = %40, %24, %3
%47 = load i32, i32* %4
%48 = icmp eq i32 %47, 26
br i1 %48, label %49, label %61
49: ; preds = %46
%50 = load i32, i32* %5
%51 = add nsw i32 %50, 1
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %61
53: ; preds = %49
%54 = load i32, i32* %9
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), i32 %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
store i32 2, i32* %7
%57 = load i32, i32* %6
%58 = icmp eq i32 %57, 2012
br i1 %58, label %59, label %60
59: ; preds = %53
store i32 3, i32* %7
br label %60
60: ; preds = %59, %53
br label %61
61: ; preds = %60, %49, %46
%62 = load i32, i32* %4
%63 = icmp eq i32 %62, 22
br i1 %63, label %64, label %86
64: ; preds = %61
%65 = load i32, i32* %5
%66 = add nsw i32 %65, 1
%67 = icmp eq i32 %66, 2
br i1 %67, label %68, label %86
68: ; preds = %64
%69 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %69, i32** %12
br label %70
70: ; preds = %77, %68
%71 = load i32*, i32** %12
%72 = call signext i8 @fgetc(i32* %71)
store i8 %72, i8* %11
%73 = sext i8 %72 to i32
%74 = load i8, i8* @EOF
%75 = sext i8 %74 to i32
%76 = icmp ne i32 %73, %75
br i1 %76, label %77, label %80
77: ; preds = %70
%78 = load i8, i8* %11
%79 = call i32 @putchar(i8 signext %78)
br label %70
80: ; preds = %70
%81 = load i32*, i32** %12
%82 = call i32 @fclose(i32* %81)
%83 = load i32, i32* %10
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %83)
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.8, i64 0, i64 0))
store i32 4, i32* %7
br label %86
86: ; preds = %80, %64, %61
%87 = load i32, i32* %4
%88 = icmp eq i32 %87, 14
br i1 %88, label %89, label %98
89: ; preds = %86
%90 = load i32, i32* %5
%91 = add nsw i32 %90, 1
%92 = icmp eq i32 %91, 2
br i1 %92, label %93, label %98
93: ; preds = %89
%94 = load i32, i32* %6
%95 = icmp eq i32 %94, 2011
br i1 %95, label %96, label %98
96: ; preds = %93
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0))
store i32 5, i32* %7
br label %98
98: ; preds = %96, %93, %89, %86
%99 = load i32, i32* %7
ret i32 %99
}

LLVM IR (-O2):
@.str = [9 x i8] c"b_day.aa\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [55 x i8] c"\0A\09Thats Your BIRTHDAY!!!... You will be %d years old, \00"
@.str.4 = [65 x i8] c"\0A\09Thats my birthday, nothing special... I will be %d years old, \00"
@.str.6 = [15 x i8] c"anniversary.aa\00"
@.str.7 = [47 x i8] c"\0A\09\09Thats our ANNIVERSARY!!!... %d years huh?, \00"
@str = [44 x i8] c"\0A\0A\09Dang... we missed valentines day but...\0A\00"
@str.10 = [67 x i8] c"\0A\09We have many more after this, but each one is just as important\0A\00"
@str.11 = [37 x i8] c"\0A\09\09You dont have to get me anything\0A\00"
@str.12 = [56 x i8] c"\0A\09\09\09Wowiee old as hell\0A\09\09Imma get u something nice :-)\0A\00"
define i32 @check_date(i32 %0, i32 %1, i32 %2) {
%4 = add nsw i32 %2, -1987
%5 = add nsw i32 %2, -1988
%6 = add nsw i32 %2, -2009
%7 = icmp eq i32 %0, 26
%8 = icmp eq i32 %1, 0
%9 = and i1 %7, %8
br i1 %9, label %10, label %25
10: ; preds = %3
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call signext i8 @fgetc(i32* %11)
%13 = load i8, i8* @EOF
%14 = icmp eq i8 %12, %13
br i1 %14, label %21, label %15
15: ; preds = %10, %15
%16 = phi i8 [ %18, %15 ], [ %12, %10 ]
%17 = tail call i32 @putchar(i8 signext %16)
%18 = tail call signext i8 @fgetc(i32* %11)
%19 = load i8, i8* @EOF
%20 = icmp eq i8 %18, %19
br i1 %20, label %21, label %15
21: ; preds = %15, %10
%22 = tail call i32 @fclose(i32* %11)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.12, i64 0, i64 0))
br label %25
25: ; preds = %21, %3
%26 = phi i32 [ 1, %21 ], [ 0, %3 ]
%27 = icmp eq i32 %1, 9
%28 = and i1 %7, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
%32 = icmp eq i32 %2, 2012
%33 = select i1 %32, i32 3, i32 2
br label %61
34: ; preds = %25
%35 = icmp eq i32 %0, 22
%36 = icmp eq i32 %1, 1
%37 = and i1 %35, %36
br i1 %37, label %38, label %53
38: ; preds = %34
%39 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%40 = tail call signext i8 @fgetc(i32* %39)
%41 = load i8, i8* @EOF
%42 = icmp eq i8 %40, %41
br i1 %42, label %49, label %43
43: ; preds = %38, %43
%44 = phi i8 [ %46, %43 ], [ %40, %38 ]
%45 = tail call i32 @putchar(i8 signext %44)
%46 = tail call signext i8 @fgetc(i32* %39)
%47 = load i8, i8* @EOF
%48 = icmp eq i8 %46, %47
br i1 %48, label %49, label %43
49: ; preds = %43, %38
%50 = tail call i32 @fclose(i32* %39)
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0), i32 %6)
%52 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @str.10, i64 0, i64 0))
br label %53
53: ; preds = %49, %34
%54 = phi i32 [ 4, %49 ], [ %26, %34 ]
%55 = icmp eq i32 %0, 14
%56 = icmp eq i32 %2, 2011
%57 = and i1 %36, %56
%58 = and i1 %55, %57
br i1 %58, label %59, label %61
59: ; preds = %53
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str, i64 0, i64 0))
br label %61
61: ; preds = %29, %59, %53
%62 = phi i32 [ 5, %59 ], [ %54, %53 ], [ %33, %29 ]
ret i32 %62
}