#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 i, m, d, doy;
  int tvals[][4] = {{2012, 2, 29, 60}, {2013, 3, 1, 60}, {1985, 10, 22, 295}};
  m = d = 0;
  doy = 0;
  for (i = 0; i < 3; i++) {
    doy = day_of_year(tvals[i][0], tvals[i][1], tvals[i][2]);
    month_day(tvals[i][0], doy, &m, &d);
    if (doy > 0 && m != 0 && d != 0) {
      printf("%4d-%02d-%02d is day %3d of the year. ", tvals[i][0], tvals[i][1],
             tvals[i][2], doy);
      printf("Day %3d of %4d is month %2d and day %3d.\n", doy, tvals[i][0], m,
             d);
    } else {
      printf("Out of range\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x30,%edx
call   1050 <memcpy@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    129c <main+0x15c>
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x4(%rax),%esi
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%edx
call   1060 <day_of_year@plt>
mov    %eax,-0x14(%rbp)
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1030 <month_day@plt>
cmpl   $0x0,-0x14(%rbp)
jle    127b <main+0x13b>
cmpl   $0x0,-0xc(%rbp)
je     127b <main+0x13b>
cmpl   $0x0,-0x10(%rbp)
je     127b <main+0x13b>
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%esi
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x4(%rax),%edx
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    0x8(%rax),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
movslq -0x8(%rbp),%rcx
lea    -0x50(%rbp),%rax
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1289 <main+0x149>
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128e <main+0x14e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x7dc,%edi
mov    $0x2,%esi
mov    $0x1d,%edx
call   1060 <day_of_year@plt>
mov    %eax,%ebx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x7dc,%edi
mov    %eax,%esi
call   1040 <month_day@plt>
test   %ebx,%ebx
jle    11d3 <main+0x93>
cmpl   $0x0,0xc(%rsp)
je     11d3 <main+0x93>
cmpl   $0x0,0x8(%rsp)
je     11d3 <main+0x93>
lea    0xe66(%rip),%rdi
mov    $0x7dc,%esi
mov    $0x2,%edx
mov    $0x1d,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
lea    0xe64(%rip),%rdi
mov    %ebx,%esi
mov    $0x7dc,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11df <main+0x9f>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7dd,%edi
mov    $0x3,%esi
mov    $0x1,%edx
call   1060 <day_of_year@plt>
mov    %eax,%ebx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x7dd,%edi
mov    %eax,%esi
call   1040 <month_day@plt>
test   %ebx,%ebx
jle    125d <main+0x11d>
cmpl   $0x0,0xc(%rsp)
je     125d <main+0x11d>
cmpl   $0x0,0x8(%rsp)
je     125d <main+0x11d>
lea    0xddc(%rip),%rdi
mov    $0x7dd,%esi
mov    $0x3,%edx
mov    $0x1,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
lea    0xdda(%rip),%rdi
mov    %ebx,%esi
mov    $0x7dd,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1269 <main+0x129>
lea    0xded(%rip),%rdi
call   1030 <puts@plt>
mov    $0x7c1,%edi
mov    $0xa,%esi
mov    $0x16,%edx
call   1060 <day_of_year@plt>
mov    %eax,%ebx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x7c1,%edi
mov    %eax,%esi
call   1040 <month_day@plt>
test   %ebx,%ebx
jle    12e7 <main+0x1a7>
cmpl   $0x0,0xc(%rsp)
je     12e7 <main+0x1a7>
cmpl   $0x0,0x8(%rsp)
je     12e7 <main+0x1a7>
lea    0xd52(%rip),%rdi
mov    $0x7c1,%esi
mov    $0xa,%edx
mov    $0x16,%ecx
mov    %ebx,%r8d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
lea    0xd50(%rip),%rdi
mov    %ebx,%esi
mov    $0x7c1,%edx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12f3 <main+0x1b3>
lea    0xd63(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.tvals = [3 x [4 x i32]] [[4 x i32] [i32 2012, i32 2, i32 29, i32 60], [4 x i32] [i32 2013, i32 3, i32 1, i32 60], [4 x i32] [i32 1985, i32 10, i32 22, i32 295]]
@.str = [39 x i8] c"%4d-%02d-%02d is day %3d of the year. \00"
@.str.1 = [42 x i8] c"Day %3d of %4d is month %2d and day %3d.\0A\00"
@.str.2 = [14 x i8] c"Out of range\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x [4 x i32]]
store i32 0, i32* %1
%7 = bitcast [3 x [4 x i32]]* %6 to i8*
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %2
br label %8
8: ; preds = %73, %0
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %76
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %13
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 0
%16 = load i32, i32* %15
%17 = load i32, i32* %2
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %18
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %19, i64 0, i64 1
%21 = load i32, i32* %20
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %23
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %24, i64 0, i64 2
%26 = load i32, i32* %25
%27 = call i32 @day_of_year(i32 %16, i32 %21, i32 %26)
store i32 %27, i32* %5
%28 = load i32, i32* %2
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %29
%31 = getelementptr inbounds [4 x i32], [4 x i32]* %30, i64 0, i64 0
%32 = load i32, i32* %31
%33 = load i32, i32* %5
%34 = call i32 @month_day(i32 %32, i32 %33, i32* %3, i32* %4)
%35 = load i32, i32* %5
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %70
37: ; preds = %11
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %70
40: ; preds = %37
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %70
43: ; preds = %40
%44 = load i32, i32* %2
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %45
%47 = getelementptr inbounds [4 x i32], [4 x i32]* %46, i64 0, i64 0
%48 = load i32, i32* %47
%49 = load i32, i32* %2
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %50
%52 = getelementptr inbounds [4 x i32], [4 x i32]* %51, i64 0, i64 1
%53 = load i32, i32* %52
%54 = load i32, i32* %2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %55
%57 = getelementptr inbounds [4 x i32], [4 x i32]* %56, i64 0, i64 2
%58 = load i32, i32* %57
%59 = load i32, i32* %5
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %48, i32 %53, i32 %58, i32 %59)
%61 = load i32, i32* %5
%62 = load i32, i32* %2
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [3 x [4 x i32]], [3 x [4 x i32]]* %6, i64 0, i64 %63
%65 = getelementptr inbounds [4 x i32], [4 x i32]* %64, i64 0, i64 0
%66 = load i32, i32* %65
%67 = load i32, i32* %3
%68 = load i32, i32* %4
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %61, i32 %66, i32 %67, i32 %68)
br label %72
70: ; preds = %40, %37, %11
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
br label %72
72: ; preds = %70, %43
br label %73
73: ; preds = %72
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
br label %8
76: ; preds = %8
ret i32 0
}

LLVM IR (-O2):
@.str = [39 x i8] c"%4d-%02d-%02d is day %3d of the year. \00"
@.str.1 = [42 x i8] c"Day %3d of %4d is month %2d and day %3d.\0A\00"
@str = [13 x i8] c"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 = call i32 @day_of_year(i32 2012, i32 2, i32 29)
%6 = call i32 @month_day(i32 2012, i32 %5, i32* %1, i32* %2)
%7 = icmp sgt i32 %5, 0
%8 = load i32, i32* %1
%9 = icmp ne i32 %8, 0
%10 = select i1 %7, i1 %9, i1 false
%11 = load i32, i32* %2
%12 = icmp ne i32 %11, 0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 2012, i32 2, i32 29, i32 %5)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 2012, i32 %16, i32 %17)
br label %21
19: ; preds = %0
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %14, %19
%22 = call i32 @day_of_year(i32 2013, i32 3, i32 1)
%23 = call i32 @month_day(i32 2013, i32 %22, i32* %1, i32* %2)
%24 = icmp sgt i32 %22, 0
%25 = load i32, i32* %1
%26 = icmp ne i32 %25, 0
%27 = select i1 %24, i1 %26, i1 false
%28 = load i32, i32* %2
%29 = icmp ne i32 %28, 0
%30 = select i1 %27, i1 %29, i1 false
br i1 %30, label %33, label %31
31: ; preds = %21
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %38
33: ; preds = %21
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 2013, i32 3, i32 1, i32 %22)
%35 = load i32, i32* %1
%36 = load i32, i32* %2
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 2013, i32 %35, i32 %36)
br label %38
38: ; preds = %33, %31
%39 = call i32 @day_of_year(i32 1985, i32 10, i32 22)
%40 = call i32 @month_day(i32 1985, i32 %39, i32* %1, i32* %2)
%41 = icmp sgt i32 %39, 0
%42 = load i32, i32* %1
%43 = icmp ne i32 %42, 0
%44 = select i1 %41, i1 %43, i1 false
%45 = load i32, i32* %2
%46 = icmp ne i32 %45, 0
%47 = select i1 %44, i1 %46, i1 false
br i1 %47, label %50, label %48
48: ; preds = %38
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %55
50: ; preds = %38
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 1985, i32 10, i32 22, i32 %39)
%52 = load i32, i32* %1
%53 = load i32, i32* %2
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 1985, i32 %52, i32 %53)
br label %55
55: ; preds = %50, %48
ret i32 0
}