#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 getFirstDayOfYear(int);
int printMonth(int, int, char *);
int /*<<< orphan*/ printf(char *, ...);
void printYear(int year) {
  int currentDay = getFirstDayOfYear(year);
  printf("---------------------------------------------------\n");
  printf("\tCALENDER FOR THE YEAR %d\n", year);
  printf("---------------------------------------------------\n");
  currentDay = printMonth(currentDay, 31, "JANUARY");
  if (year == 1996 || ((year - 1996) % 4 == 0)) {
    printf("%d is a leap year\n", year);
    currentDay = printMonth(currentDay, 29, "FEBRUARY");
  } else
    currentDay = printMonth(currentDay, 28, "FEBRUARY");
  currentDay = printMonth(currentDay, 31, "MARCH");
  currentDay = printMonth(currentDay, 30, "APRIL");
  currentDay = printMonth(currentDay, 31, "MAY");
  currentDay = printMonth(currentDay, 30, "JUNE");
  currentDay = printMonth(currentDay, 31, "JULY");
  currentDay = printMonth(currentDay, 31, "AUGUST");
  currentDay = printMonth(currentDay, 30, "SEPTEMBER");
  currentDay = printMonth(currentDay, 31, "OCTOBER");
  currentDay = printMonth(currentDay, 30, "NOVEMBER");
  currentDay = printMonth(currentDay, 31, "DECEMBER");
}


x86 assembly (clang, -O0):
<printYear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <getFirstDayOfYear@plt>
mov    %eax,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xece(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x7cc,-0x4(%rbp)
je     11b0 <printYear+0x80>
mov    -0x4(%rbp),%eax
sub    $0x7cc,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11dd <printYear+0xad>
mov    -0x4(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x1d,%esi
lea    0xe9b(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
jmp    11f4 <printYear+0xc4>
mov    -0x8(%rbp),%edi
mov    $0x1c,%esi
lea    0xe7f(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xe71(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1e,%esi
lea    0xe60(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xe4f(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1e,%esi
lea    0xe3c(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xe2a(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xe18(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1e,%esi
lea    0xe08(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xdfb(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1e,%esi
lea    0xdec(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x1f,%esi
lea    0xdde(%rip),%rdx
call   1040 <printMonth@plt>
mov    %eax,-0x8(%rbp)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printYear>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
call   1060 <getFirstDayOfYear@plt>
mov    %eax,%ebp
lea    0xf30(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xe9d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdx
mov    %ebp,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
mov    %eax,%ebp
cmp    $0x7cc,%ebx
je     119d <printYear+0x5d>
mov    %ebx,%eax
mov    $0x1c,%esi
and    $0x3,%eax
jne    11b2 <printYear+0x72>
lea    0xe7f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1d,%esi
lea    0xe7d(%rip),%rdx
mov    %ebp,%edi
call   1050 <printMonth@plt>
lea    0xe78(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
lea    0xe6b(%rip),%rdx
mov    %eax,%edi
mov    $0x1e,%esi
call   1050 <printMonth@plt>
lea    0xe5e(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
lea    0xe4f(%rip),%rdx
mov    %eax,%edi
mov    $0x1e,%esi
call   1050 <printMonth@plt>
lea    0xe41(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
lea    0xe33(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
lea    0xe27(%rip),%rdx
mov    %eax,%edi
mov    $0x1e,%esi
call   1050 <printMonth@plt>
lea    0xe1e(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
call   1050 <printMonth@plt>
lea    0xe13(%rip),%rdx
mov    %eax,%edi
mov    $0x1e,%esi
call   1050 <printMonth@plt>
lea    0xe09(%rip),%rdx
mov    %eax,%edi
mov    $0x1f,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printMonth@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"---------------------------------------------------\0A\00"
@.str.1 = [27 x i8] c"\09CALENDER FOR THE YEAR %d\0A\00"
@.str.2 = [8 x i8] c"JANUARY\00"
@.str.3 = [19 x i8] c"%d is a leap year\0A\00"
@.str.4 = [9 x i8] c"FEBRUARY\00"
@.str.5 = [6 x i8] c"MARCH\00"
@.str.6 = [6 x i8] c"APRIL\00"
@.str.7 = [4 x i8] c"MAY\00"
@.str.8 = [5 x i8] c"JUNE\00"
@.str.9 = [5 x i8] c"JULY\00"
@.str.10 = [7 x i8] c"AUGUST\00"
@.str.11 = [10 x i8] c"SEPTEMBER\00"
@.str.12 = [8 x i8] c"OCTOBER\00"
@.str.13 = [9 x i8] c"NOVEMBER\00"
@.str.14 = [9 x i8] c"DECEMBER\00"
define void @printYear(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @getFirstDayOfYear(i32 %4)
store i32 %5, i32* %3
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* %3
%11 = call i32 @printMonth(i32 %10, i32 31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 %11, i32* %3
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 1996
br i1 %13, label %19, label %14
14: ; preds = %1
%15 = load i32, i32* %2
%16 = sub nsw i32 %15, 1996
%17 = srem i32 %16, 4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %14, %1
%20 = load i32, i32* %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %3
%23 = call i32 @printMonth(i32 %22, i32 29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 %23, i32* %3
br label %27
24: ; preds = %14
%25 = load i32, i32* %3
%26 = call i32 @printMonth(i32 %25, i32 28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
store i32 %26, i32* %3
br label %27
27: ; preds = %24, %19
%28 = load i32, i32* %3
%29 = call i32 @printMonth(i32 %28, i32 31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = call i32 @printMonth(i32 %30, i32 30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 %31, i32* %3
%32 = load i32, i32* %3
%33 = call i32 @printMonth(i32 %32, i32 31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
store i32 %33, i32* %3
%34 = load i32, i32* %3
%35 = call i32 @printMonth(i32 %34, i32 30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i32 %35, i32* %3
%36 = load i32, i32* %3
%37 = call i32 @printMonth(i32 %36, i32 31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
store i32 %37, i32* %3
%38 = load i32, i32* %3
%39 = call i32 @printMonth(i32 %38, i32 31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 @printMonth(i32 %40, i32 30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
store i32 %41, i32* %3
%42 = load i32, i32* %3
%43 = call i32 @printMonth(i32 %42, i32 31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
store i32 %43, i32* %3
%44 = load i32, i32* %3
%45 = call i32 @printMonth(i32 %44, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
store i32 %45, i32* %3
%46 = load i32, i32* %3
%47 = call i32 @printMonth(i32 %46, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
store i32 %47, i32* %3
ret void
}

LLVM IR (-O2):
@.str.1 = [27 x i8] c"\09CALENDER FOR THE YEAR %d\0A\00"
@.str.2 = [8 x i8] c"JANUARY\00"
@.str.3 = [19 x i8] c"%d is a leap year\0A\00"
@.str.4 = [9 x i8] c"FEBRUARY\00"
@.str.5 = [6 x i8] c"MARCH\00"
@.str.6 = [6 x i8] c"APRIL\00"
@.str.7 = [4 x i8] c"MAY\00"
@.str.8 = [5 x i8] c"JUNE\00"
@.str.9 = [5 x i8] c"JULY\00"
@.str.10 = [7 x i8] c"AUGUST\00"
@.str.11 = [10 x i8] c"SEPTEMBER\00"
@.str.12 = [8 x i8] c"OCTOBER\00"
@.str.13 = [9 x i8] c"NOVEMBER\00"
@.str.14 = [9 x i8] c"DECEMBER\00"
@str.15 = [52 x i8] c"---------------------------------------------------\00"
define void @printYear(i32 %0) {
%2 = tail call i32 @getFirstDayOfYear(i32 %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.15, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @str.15, i64 0, i64 0))
%6 = tail call i32 @printMonth(i32 %2, i32 31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%7 = icmp eq i32 %0, 1996
%8 = and i32 %0, 3
%9 = icmp eq i32 %8, 0
%10 = or i1 %7, %9
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %0)
br label %13
13: ; preds = %1, %11
%14 = phi i32 [ 29, %11 ], [ 28, %1 ]
%15 = tail call i32 @printMonth(i32 %6, i32 %14, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%16 = tail call i32 @printMonth(i32 %15, i32 31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%17 = tail call i32 @printMonth(i32 %16, i32 30, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%18 = tail call i32 @printMonth(i32 %17, i32 31, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%19 = tail call i32 @printMonth(i32 %18, i32 30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%20 = tail call i32 @printMonth(i32 %19, i32 31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%21 = tail call i32 @printMonth(i32 %20, i32 31, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%22 = tail call i32 @printMonth(i32 %21, i32 30, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0))
%23 = tail call i32 @printMonth(i32 %22, i32 31, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.12, i64 0, i64 0))
%24 = tail call i32 @printMonth(i32 %23, i32 30, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.13, i64 0, i64 0))
%25 = tail call i32 @printMonth(i32 %24, i32 31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.14, i64 0, i64 0))
ret void
}