#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 month_day(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  int year, month, day, yearday;
  for (year = 1970; year <= 2000; ++year) {
    for (yearday = 1; yearday < 366; ++yearday) {
      if (month_day(year, yearday, &month, &day) == -1) {
        printf("month_day failed: %d %d\n", year, yearday);
      } else if (day_of_year(year, month, day) != yearday) {
        printf("bad result: %d %d\n", year, yearday);
        printf("month = %d, day = %d\n", month, day);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7b2,-0x8(%rbp)
cmpl   $0x7d0,-0x8(%rbp)
jg     1200 <main+0xd0>
movl   $0x1,-0x14(%rbp)
cmpl   $0x16e,-0x14(%rbp)
jge    11ed <main+0xbd>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1030 <month_day@plt>
cmp    $0xffffffff,%eax
jne    119a <main+0x6a>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
jmp    11da <main+0xaa>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <day_of_year@plt>
cmp    -0x14(%rbp),%eax
je     11d5 <main+0xa5>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe5b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
jmp    11da <main+0xaa>
jmp    11df <main+0xaf>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115a <main+0x2a>
jmp    11f2 <main+0xc2>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x7b2,%ebx
lea    0x4(%rsp),%r14
mov    %rsp,%r15
lea    0xeb1(%rip),%r12
lea    0xed6(%rip),%rbp
jmp    116b <main+0x3b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    $0x7d1,%ebx
je     11df <main+0xaf>
mov    $0x1,%r13d
jmp    119a <main+0x6a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <printf@plt>
add    $0x1,%r13d
cmp    $0x16e,%r13d
je     1160 <main+0x30>
mov    %ebx,%edi
mov    %r13d,%esi
mov    %r14,%rdx
mov    %r15,%rcx
call   1030 <month_day@plt>
cmp    $0xffffffff,%eax
je     1180 <main+0x50>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    %ebx,%edi
call   1050 <day_of_year@plt>
cmp    %eax,%r13d
je     118d <main+0x5d>
lea    0xe50(%rip),%rdi
mov    %ebx,%esi
mov    %r13d,%edx
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    %rbp,%rdi
jmp    1188 <main+0x58>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"month_day failed: %d %d\0A\00"
@.str.1 = [19 x i8] c"bad result: %d %d\0A\00"
@.str.2 = [22 x i8] c"month = %d, day = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 1970, i32* %2
br label %6
6: ; preds = %42, %0
%7 = load i32, i32* %2
%8 = icmp sle i32 %7, 2000
br i1 %8, label %9, label %45
9: ; preds = %6
store i32 1, i32* %5
br label %10
10: ; preds = %38, %9
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 366
br i1 %12, label %13, label %41
13: ; preds = %10
%14 = load i32, i32* %2
%15 = load i32, i32* %5
%16 = call i32 @month_day(i32 %14, i32 %15, i32* %3, i32* %4)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %22
18: ; preds = %13
%19 = load i32, i32* %2
%20 = load i32, i32* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20)
br label %37
22: ; preds = %13
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = call i32 @day_of_year(i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %5
%28 = icmp ne i32 %26, %27
br i1 %28, label %29, label %36
29: ; preds = %22
%30 = load i32, i32* %2
%31 = load i32, i32* %5
%32 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %30, i32 %31)
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %33, i32 %34)
br label %36
36: ; preds = %29, %22
br label %37
37: ; preds = %36, %18
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %10
41: ; preds = %10
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %6
45: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"month_day failed: %d %d\0A\00"
@.str.1 = [19 x i8] c"bad result: %d %d\0A\00"
@.str.2 = [22 x i8] c"month = %d, day = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %26
%6 = phi i32 [ 1970, %0 ], [ %27, %26 ]
br label %7
7: ; preds = %5, %23
%8 = phi i32 [ 1, %5 ], [ %24, %23 ]
%9 = call i32 @month_day(i32 %6, i32 %8, i32* %1, i32* %2)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8)
br label %23
13: ; preds = %7
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @day_of_year(i32 %6, i32 %14, i32 %15)
%17 = icmp eq i32 %16, %8
br i1 %17, label %23, label %18
18: ; preds = %13
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %8)
%20 = load i32, i32* %1
%21 = load i32, i32* %2
%22 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %21)
br label %23
23: ; preds = %11, %18, %13
%24 = add nuw nsw i32 %8, 1
%25 = icmp eq i32 %24, 366
br i1 %25, label %26, label %7
26: ; preds = %23
%27 = add nuw nsw i32 %6, 1
%28 = icmp eq i32 %27, 2001
br i1 %28, label %29, label %5
29: ; preds = %26
ret i32 0
}