#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 day_of_year(int, int, int);
int /*<<< orphan*/ month_day(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, int, ...);
int main() {
  int month, day, yearday, year, ret;
  day = 15;
  month = 13;
  year = 1981;
  ret = day_of_year(year, month, day);
  printf("13th month exists? %d\n", ret);
  day = 32;
  month = 6;
  ret = day_of_year(year, month, day);
  printf("32nd day exists? %d\n", ret);
  day = 15;
  month = 1;
  ret = day_of_year(year, month, day);
  printf("15th of January 1981 valid? Day of year = %d\n", ret);
  yearday = 370;
  month_day(year, yearday, &month, &day);
  printf("370th yearday in 1981 exists? day = %d, month = %d\n", day, month);
  yearday = 15;
  month_day(year, yearday, &month, &day);
  printf("15th yearday in 1981 is on %d/%d/%d\n", day, month, year);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xf,-0xc(%rbp)
movl   $0xd,-0x8(%rbp)
movl   $0x7bd,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x20,-0xc(%rbp)
movl   $0x6,-0x8(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xf,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x172,-0x10(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <month_day@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xf,-0x10(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <month_day@plt>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x14(%rbp),%ecx
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x7bd,%edi
mov    $0xd,%esi
mov    $0xf,%edx
call   1050 <day_of_year@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7bd,%edi
mov    $0x6,%esi
mov    $0x20,%edx
call   1050 <day_of_year@plt>
lea    0xea4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0xf,(%rsp)
movl   $0x1,0x4(%rsp)
mov    $0x7bd,%edi
mov    $0x1,%esi
mov    $0xf,%edx
call   1050 <day_of_year@plt>
lea    0xe86(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rbx
mov    %rsp,%r14
mov    $0x7bd,%edi
mov    $0x172,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <month_day@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xe80(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x7bd,%edi
mov    $0xf,%esi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1030 <month_day@plt>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xe8a(%rip),%rdi
mov    $0x7bd,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [23 x i8] c"13th month exists? %d\0A\00"
@.str.1 = [21 x i8] c"32nd day exists? %d\0A\00"
@.str.2 = [46 x i8] c"15th of January 1981 valid? Day of year = %d\0A\00"
@.str.3 = [52 x i8] c"370th yearday in 1981 exists? day = %d, month = %d\0A\00"
@.str.4 = [37 x i8] c"15th yearday in 1981 is on %d/%d/%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 15, i32* %3
store i32 13, i32* %2
store i32 1981, i32* %5
%7 = load i32, i32* %5
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = call i32 @day_of_year(i32 %7, i32 %8, i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 32, i32* %3
store i32 6, i32* %2
%13 = load i32, i32* %5
%14 = load i32, i32* %2
%15 = load i32, i32* %3
%16 = call i32 @day_of_year(i32 %13, i32 %14, i32 %15)
store i32 %16, i32* %6
%17 = load i32, i32* %6
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 15, i32* %3
store i32 1, i32* %2
%19 = load i32, i32* %5
%20 = load i32, i32* %2
%21 = load i32, i32* %3
%22 = call i32 @day_of_year(i32 %19, i32 %20, i32 %21)
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %23)
store i32 370, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %4
%27 = call i32 @month_day(i32 %25, i32 %26, i32* %2, i32* %3)
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
store i32 15, i32* %4
%31 = load i32, i32* %5
%32 = load i32, i32* %4
%33 = call i32 @month_day(i32 %31, i32 %32, i32* %2, i32* %3)
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = load i32, i32* %5
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %35, i32 %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"13th month exists? %d\0A\00"
@.str.1 = [21 x i8] c"32nd day exists? %d\0A\00"
@.str.2 = [46 x i8] c"15th of January 1981 valid? Day of year = %d\0A\00"
@.str.3 = [52 x i8] c"370th yearday in 1981 exists? day = %d, month = %d\0A\00"
@.str.4 = [37 x i8] c"15th yearday in 1981 is on %d/%d/%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @day_of_year(i32 1981, i32 13, i32 15)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @day_of_year(i32 1981, i32 6, i32 32)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %7)
store i32 15, i32* %2
store i32 1, i32* %1
%9 = tail call i32 @day_of_year(i32 1981, i32 1, i32 15)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = call i32 @month_day(i32 1981, i32 370, i32* %1, i32* %2)
%12 = load i32, i32* %2
%13 = load i32, i32* %1
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 %13)
%15 = call i32 @month_day(i32 1981, i32 15, i32* %1, i32* %2)
%16 = load i32, i32* %2
%17 = load i32, i32* %1
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %16, i32 %17, i32 1981)
ret i32 0
}