#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 main(void) {
  printf("\n");
  int month, day, res, y, m, d, yd;
  y = 1988;
  m = 2;
  d = 29;
  res = day_of_year(y, m, d);
  if (res == -1) {
    printf("invalid input\n");
  } else
    printf("date %i %i %i  : day %i\n", y, m, d, res);
  y = 1988;
  yd = 60;
  res = month_day(y, yd, &month, &day);
  if (res == -1) {
    printf("invalid input\n");
  } else
    printf("day %i from %i: month %i day %i\n", yd, y, month, day);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x7c4,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x1d,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1190 <main+0x60>
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ab <main+0x7b>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x7c4,-0x14(%rbp)
movl   $0x3c,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
lea    -0x8(%rbp),%rdx
lea    -0xc(%rbp),%rcx
call   1030 <month_day@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    11ec <main+0xbc>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1207 <main+0xd7>
mov    -0x20(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x7c4,%edi
mov    $0x2,%esi
mov    $0x1d,%edx
call   1070 <day_of_year@plt>
cmp    $0xffffffff,%eax
je     1196 <main+0x46>
lea    0xe85(%rip),%rdi
mov    $0x7c4,%esi
mov    $0x2,%edx
mov    $0x1d,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11a2 <main+0x52>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
lea    0x4(%rsp),%rdx
mov    %rsp,%rcx
mov    $0x7c4,%edi
mov    $0x3c,%esi
call   1050 <month_day@plt>
cmp    $0xffffffff,%eax
je     11e0 <main+0x90>
mov    0x4(%rsp),%ecx
mov    (%rsp),%r8d
lea    0xe4c(%rip),%rdi
mov    $0x3c,%esi
mov    $0x7c4,%edx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11ec <main+0x9c>
lea    0xe53(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [15 x i8] c"invalid input\0A\00"
@.str.2 = [25 x i8] c"date %i %i %i : day %i\0A\00"
@.str.3 = [33 x i8] c"day %i from %i: month %i day %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 1988, i32* %5
store i32 2, i32* %6
store i32 29, i32* %7
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @day_of_year(i32 %10, i32 %11, i32 %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, -1
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %24
18: ; preds = %0
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %20, i32 %21, i32 %22)
br label %24
24: ; preds = %18, %16
store i32 1988, i32* %5
store i32 60, i32* %8
%25 = load i32, i32* %5
%26 = load i32, i32* %8
%27 = call i32 @month_day(i32 %25, i32 %26, i32* %2, i32* %3)
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %38
32: ; preds = %24
%33 = load i32, i32* %8
%34 = load i32, i32* %5
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %33, i32 %34, i32 %35, i32 %36)
br label %38
38: ; preds = %32, %30
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [25 x i8] c"date %i %i %i : day %i\0A\00"
@.str.3 = [33 x i8] c"day %i from %i: month %i day %i\0A\00"
@str.4 = [14 x i8] c"invalid input\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @putchar(i32 10)
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = tail call i32 @day_of_year(i32 1988, i32 2, i32 29)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 1988, i32 2, i32 29, i32 %6)
br label %12
12: ; preds = %10, %8
%13 = call i32 @month_day(i32 1988, i32 60, i32* %1, i32* %2)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.4, i64 0, i64 0))
br label %21
17: ; preds = %12
%18 = load i32, i32* %1
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 60, i32 1988, i32 %18, i32 %19)
br label %21
21: ; preds = %17, %15
%22 = call i32 @putchar(i32 10)
ret i32 0
}