#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 main() {
  int m, d, doy;
  m = d = 0;
  doy = 0;
  printf("Calling day_of_year(1973, 10, 32)\n> ");
  if ((doy = day_of_year(1973, 10, 32)) > 0) {
    printf("Oct 12nd, 1973 is day %d\n", doy);
  } else {
    printf("The month or day is out of range!\n");
  }
  printf("Calling month_day(1985, 295, ...)\n> ");
  month_day(1985, 295, &m, &d);
  if (m > 0 && d > 0) {
    printf("Day 295 of year 1985 is month %d and day %d\n", m, d);
  } else {
    printf("month_day: day of year out of range!\n");
  }
  printf("Calling day_of_year(1492, 5, 14)\n> ");
  if ((doy = day_of_year(1492, 5, 14)) > 0) {
    printf("May 14th, 1492 is day %d\n", doy);
  } else {
    printf("The month or day is out of range!\n");
  }
  printf("Calling month_day(2012, 367, ...)\n> ");
  month_day(2012, 367, &m, &d);
  if (m > 0 && d > 0) {
    printf("Day 295 of year 1985 is month %d and day %d\n", m, d);
  } else {
    printf("month_day: day of year out of range!\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7b5,%edi
mov    $0xa,%esi
mov    $0x20,%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    1198 <main+0x68>
mov    -0x10(%rbp),%esi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a6 <main+0x76>
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7c1,%edi
mov    $0x127,%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <month_day@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11f8 <main+0xc8>
cmpl   $0x0,-0xc(%rbp)
jle    11f8 <main+0xc8>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1206 <main+0xd6>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x5d4,%edi
mov    $0x5,%esi
mov    $0xe,%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    124a <main+0x11a>
mov    -0x10(%rbp),%esi
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1258 <main+0x128>
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x7dc,%edi
mov    $0x16f,%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <month_day@plt>
cmpl   $0x0,-0x8(%rbp)
jle    12aa <main+0x17a>
cmpl   $0x0,-0xc(%rbp)
jle    12aa <main+0x17a>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xde9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b8 <main+0x188>
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
movl   $0x0,(%rsp)
movl   $0x0,0x4(%rsp)
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x7b5,%edi
mov    $0xa,%esi
mov    $0x20,%edx
call   1060 <day_of_year@plt>
test   %eax,%eax
jle    1188 <main+0x48>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1194 <main+0x54>
lea    0xf65(%rip),%rdi
call   1030 <puts@plt>
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    $0x7c1,%edi
mov    $0x127,%esi
call   1040 <month_day@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11d8 <main+0x98>
mov    (%rsp),%edx
test   %edx,%edx
jle    11d8 <main+0x98>
lea    0xe95(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e4 <main+0xa4>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x5d4,%edi
mov    $0x5,%esi
mov    $0xe,%edx
call   1060 <day_of_year@plt>
test   %eax,%eax
jle    121c <main+0xdc>
lea    0xea4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1228 <main+0xe8>
lea    0xed1(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    $0x7dc,%edi
mov    $0x16f,%esi
call   1040 <month_day@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    126c <main+0x12c>
mov    (%rsp),%edx
test   %edx,%edx
jle    126c <main+0x12c>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1278 <main+0x138>
lea    0xea3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Calling day_of_year(1973, 10, 32)\0A> \00"
@.str.1 = [26 x i8] c"Oct 12nd, 1973 is day %d\0A\00"
@.str.2 = [35 x i8] c"The month or day is out of range!\0A\00"
@.str.3 = [37 x i8] c"Calling month_day(1985, 295, ...)\0A> \00"
@.str.4 = [45 x i8] c"Day 295 of year 1985 is month %d and day %d\0A\00"
@.str.5 = [38 x i8] c"month_day: day of year out of range!\0A\00"
@.str.6 = [36 x i8] c"Calling day_of_year(1492, 5, 14)\0A> \00"
@.str.7 = [26 x i8] c"May 14th, 1492 is day %d\0A\00"
@.str.8 = [37 x i8] c"Calling month_day(2012, 367, ...)\0A> \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @day_of_year(i32 1973, i32 10, i32 32)
store i32 %6, i32* %4
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @month_day(i32 1985, i32 295, i32* %2, i32* %3)
%16 = load i32, i32* %2
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i32, i32* %3
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %22, i32 %23)
br label %27
25: ; preds = %18, %13
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %27
27: ; preds = %25, %21
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%29 = call i32 @day_of_year(i32 1492, i32 5, i32 14)
store i32 %29, i32* %4
%30 = icmp sgt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %4
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %27
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%38 = call i32 @month_day(i32 2012, i32 367, i32* %2, i32* %3)
%39 = load i32, i32* %2
%40 = icmp sgt i32 %39, 0
br i1 %40, label %41, label %48
41: ; preds = %36
%42 = load i32, i32* %3
%43 = icmp sgt i32 %42, 0
br i1 %43, label %44, label %48
44: ; preds = %41
%45 = load i32, i32* %2
%46 = load i32, i32* %3
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %45, i32 %46)
br label %50
48: ; preds = %41, %36
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %44
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Calling day_of_year(1973, 10, 32)\0A> \00"
@.str.1 = [26 x i8] c"Oct 12nd, 1973 is day %d\0A\00"
@.str.3 = [37 x i8] c"Calling month_day(1985, 295, ...)\0A> \00"
@.str.4 = [45 x i8] c"Day 295 of year 1985 is month %d and day %d\0A\00"
@.str.6 = [36 x i8] c"Calling day_of_year(1492, 5, 14)\0A> \00"
@.str.7 = [26 x i8] c"May 14th, 1492 is day %d\0A\00"
@.str.8 = [37 x i8] c"Calling month_day(2012, 367, ...)\0A> \00"
@str.10 = [34 x i8] c"The month or day is out of range!\00"
@str.11 = [37 x i8] c"month_day: day of year out of range!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
store i32 0, i32* %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @day_of_year(i32 1973, i32 10, i32 32)
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %0
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 @month_day(i32 1985, i32 295, i32* %1, i32* %2)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 0
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 0
%19 = select i1 %16, i1 %18, i1 false
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %15, i32 %17)
br label %24
22: ; preds = %12
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0))
%26 = call i32 @day_of_year(i32 1492, i32 5, i32 14)
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.7, i64 0, i64 0), i32 %26)
br label %32
30: ; preds = %24
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.10, i64 0, i64 0))
br label %32
32: ; preds = %30, %28
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32 @month_day(i32 2012, i32 367, i32* %1, i32* %2)
%35 = load i32, i32* %1
%36 = icmp sgt i32 %35, 0
%37 = load i32, i32* %2
%38 = icmp sgt i32 %37, 0
%39 = select i1 %36, i1 %38, i1 false
br i1 %39, label %40, label %42
40: ; preds = %32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %37)
br label %44
42: ; preds = %32
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.11, i64 0, i64 0))
br label %44
44: ; preds = %42, %40
ret i32 0
}