#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 EOF;
int get_number();
scalar_t__ month_day(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int year_day(int, int, int);
int main() {
  int year, month, day, day_of_year;
  for (;;) {
    printf("Enter "
           "year"
           ": ");
    if ((year = get_number()) == EOF)
      break;
    ;
    printf("Enter "
           "month"
           ": ");
    if ((month = get_number()) == EOF)
      break;
    ;
    printf("Enter "
           "day"
           ": ");
    if ((day = get_number()) == EOF)
      break;
    ;
    day_of_year = year_day(year, month, day);
    if (day_of_year)
      printf("Day of year = [%d]\n", day_of_year);
    else
      printf("Bad date: %d-%02d-%02d\n", year, month, day);
    printf("Enter "
           "year"
           ": ");
    if ((year = get_number()) == EOF)
      break;
    ;
    printf("Enter "
           "day_of_year"
           ": ");
    if ((day_of_year = get_number()) == EOF)
      break;
    ;
    if (month_day(year, day_of_year, &month, &day))
      printf("Month = [%d], Day = [%d]\n", month, day);
    else
      printf("Bad date: %d-%03d\n", year, day_of_year);
  }
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <get_number@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e6a(%rip),%rcx
cmp    (%rcx),%eax
jne    118b <main+0x3b>
jmp    12d2 <main+0x182>
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <get_number@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e3e(%rip),%rcx
cmp    (%rcx),%eax
jne    11b7 <main+0x67>
jmp    12d2 <main+0x182>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <get_number@plt>
mov    %eax,-0x10(%rbp)
mov    0x2e12(%rip),%rcx
cmp    (%rcx),%eax
jne    11e3 <main+0x93>
jmp    12d2 <main+0x182>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <year_day@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1214 <main+0xc4>
mov    -0x14(%rbp),%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    122b <main+0xdb>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <get_number@plt>
mov    %eax,-0x8(%rbp)
mov    0x2d9e(%rip),%rcx
cmp    (%rcx),%eax
jne    1257 <main+0x107>
jmp    12d2 <main+0x182>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1070 <get_number@plt>
mov    %eax,-0x14(%rbp)
mov    0x2d72(%rip),%rcx
cmp    (%rcx),%eax
jne    1283 <main+0x133>
jmp    12d2 <main+0x182>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1050 <month_day@plt>
cmp    $0x0,%rax
je     12b9 <main+0x169>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12cd <main+0x17d>
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    115f <main+0xf>
mov    $0xa,%edi
call   1030 <putchar@plt>
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
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
mov    0x2e71(%rip),%r13
cmp    0x0(%r13),%eax
jne    1198 <main+0x48>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
lea    0xe6c(%rip),%r12
lea    0xe73(%rip),%r14
lea    0xe51(%rip),%rbx
jmp    11ec <main+0x9c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xeba(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
mov    %eax,%ebp
cmp    0x0(%r13),%eax
je     117d <main+0x2d>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
mov    %eax,(%rsp)
cmp    0x0(%r13),%eax
je     117d <main+0x2d>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
mov    %eax,0x4(%rsp)
cmp    0x0(%r13),%eax
je     117d <main+0x2d>
mov    (%rsp),%esi
mov    %ebp,%edi
mov    %eax,%edx
call   1040 <year_day@plt>
test   %eax,%eax
je     1250 <main+0x100>
lea    0xde7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1267 <main+0x117>
nopl   0x0(%rax,%rax,1)
mov    (%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xddd(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
cmp    0x0(%r13),%eax
je     117d <main+0x2d>
mov    %eax,%ebp
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <get_number@plt>
cmp    0x0(%r13),%eax
je     117d <main+0x2d>
mov    %eax,%r15d
mov    %ebp,%edi
mov    %eax,%esi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
call   1050 <month_day@plt>
test   %rax,%rax
je     11c0 <main+0x70>
mov    (%rsp),%esi
mov    0x4(%rsp),%edx
lea    0xd99(%rip),%rdi
jmp    11cc <main+0x7c>

LLVM IR (-O0):
@.str = [13 x i8] c"Enter year: \00"
@EOF = global i32 0
@.str.1 = [14 x i8] c"Enter month: \00"
@.str.2 = [12 x i8] c"Enter day: \00"
@.str.3 = [20 x i8] c"Day of year = [%d]\0A\00"
@.str.4 = [24 x i8] c"Bad date: %d-%02d-%02d\0A\00"
@.str.5 = [20 x i8] c"Enter day_of_year: \00"
@.str.6 = [26 x i8] c"Month = [%d], Day = [%d]\0A\00"
@.str.7 = [19 x i8] c"Bad date: %d-%03d\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
br label %6
6: ; preds = %64, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (...) @get_number()
store i32 %8, i32* %2
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %6
br label %65
12: ; preds = %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (...) @get_number()
store i32 %14, i32* %3
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %12
br label %65
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 (...) @get_number()
store i32 %20, i32* %4
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %18
br label %65
24: ; preds = %18
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @year_day(i32 %25, i32 %26, i32 %27)
store i32 %28, i32* %5
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %39
34: ; preds = %24
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = load i32, i32* %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %35, i32 %36, i32 %37)
br label %39
39: ; preds = %34, %31
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%41 = call i32 (...) @get_number()
store i32 %41, i32* %2
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %39
br label %65
45: ; preds = %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%47 = call i32 (...) @get_number()
store i32 %47, i32* %5
%48 = load i32, i32* @EOF
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %51
50: ; preds = %45
br label %65
51: ; preds = %45
%52 = load i32, i32* %2
%53 = load i32, i32* %5
%54 = call i64 @month_day(i32 %52, i32 %53, i32* %3, i32* %4)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = load i32, i32* %3
%58 = load i32, i32* %4
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 %58)
br label %64
60: ; preds = %51
%61 = load i32, i32* %2
%62 = load i32, i32* %5
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %61, i32 %62)
br label %64
64: ; preds = %60, %56
br label %6
65: ; preds = %50, %44, %23, %17, %11
%66 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Enter year: \00"
@EOF = global i32 0
@.str.1 = [14 x i8] c"Enter month: \00"
@.str.2 = [12 x i8] c"Enter day: \00"
@.str.3 = [20 x i8] c"Day of year = [%d]\0A\00"
@.str.4 = [24 x i8] c"Bad date: %d-%02d-%02d\0A\00"
@.str.5 = [20 x i8] c"Enter day_of_year: \00"
@.str.6 = [26 x i8] c"Month = [%d], Day = [%d]\0A\00"
@.str.7 = [19 x i8] c"Bad date: %d-%03d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @get_number()
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %54, label %9
9: ; preds = %0, %49
%10 = phi i32 [ %51, %49 ], [ %6, %0 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (...) @get_number()
store i32 %12, i32* %1
%13 = load i32, i32* @EOF
%14 = icmp eq i32 %12, %13
br i1 %14, label %54, label %15
15: ; preds = %9
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @get_number()
store i32 %17, i32* %2
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %54, label %20
20: ; preds = %15
%21 = load i32, i32* %1
%22 = call i32 @year_day(i32 %10, i32 %21, i32 %17)
%23 = icmp eq i32 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %20
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %30
26: ; preds = %20
%27 = load i32, i32* %1
%28 = load i32, i32* %2
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i32 %10, i32 %27, i32 %28)
br label %30
30: ; preds = %26, %24
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%32 = call i32 (...) @get_number()
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
br i1 %34, label %54, label %35
35: ; preds = %30
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 (...) @get_number()
%38 = load i32, i32* @EOF
%39 = icmp eq i32 %37, %38
br i1 %39, label %54, label %40
40: ; preds = %35
%41 = call i64 @month_day(i32 %32, i32 %37, i32* %1, i32* %2)
%42 = icmp eq i64 %41, 0
br i1 %42, label %47, label %43
43: ; preds = %40
%44 = load i32, i32* %1
%45 = load i32, i32* %2
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %44, i32 %45)
br label %49
47: ; preds = %40
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0), i32 %32, i32 %37)
br label %49
49: ; preds = %47, %43
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%51 = call i32 (...) @get_number()
%52 = load i32, i32* @EOF
%53 = icmp eq i32 %51, %52
br i1 %53, label %54, label %9
54: ; preds = %49, %9, %15, %30, %35, %0
%55 = call i32 @putchar(i8 signext 10)
ret i32 0
}