#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 EXIT_SUCCESS;
int day_of_year(int, int, int);
int /*<<< orphan*/ month_day(int, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int year = 2015, month = 10, day = 1;
  int days = day_of_year(year, month, day);
  if (days == -1) {
    printf("error:wrong input.\n");
  } else {
    printf("%d-%d-%d is the %dth day in %d\n", year, month, day, days, year);
  }
  days += 1;
  month_day(year, days, &month, &day);
  printf("The %dth day in %d is %d-%d\n", days, year, month, day);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x7df,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1050 <day_of_year@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1182 <main+0x52>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a1 <main+0x71>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x8(%rbp),%r9d
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1030 <month_day@plt>
mov    -0x14(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x10(%rbp),%r8d
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e01(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0xa,0xc(%rsp)
movl   $0x1,0x8(%rsp)
mov    $0x7df,%edi
mov    $0xa,%esi
mov    $0x1,%edx
call   1060 <day_of_year@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
je     1198 <main+0x58>
lea    0xe89(%rip),%rdi
mov    $0x7df,%esi
mov    $0xa,%edx
mov    $0x1,%ecx
mov    %ebx,%r8d
mov    $0x7df,%r9d
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11a4 <main+0x64>
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
add    $0x1,%ebx
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    $0x7df,%edi
mov    %ebx,%esi
call   1040 <month_day@plt>
mov    0xc(%rsp),%ecx
mov    0x8(%rsp),%r8d
lea    0xe53(%rip),%rdi
mov    %ebx,%esi
mov    $0x7df,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [20 x i8] c"error:wrong input.\0A\00"
@.str.1 = [32 x i8] c"%d-%d-%d is the %dth day in %d\0A\00"
@.str.2 = [29 x i8] c"The %dth day in %d is %d-%d\0A\00"
@EXIT_SUCCESS = global i32 0
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 2015, i32* %2
store i32 10, i32* %3
store i32 1, i32* %4
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = load i32, i32* %4
%9 = call i32 @day_of_year(i32 %6, i32 %7, i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* %5
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
br label %21
14: ; preds = %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = load i32, i32* %5
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16, i32 %17, i32 %18, i32 %19)
br label %21
21: ; preds = %14, %12
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = load i32, i32* %5
%26 = call i32 @month_day(i32 %24, i32 %25, i32* %3, i32* %4)
%27 = load i32, i32* %5
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = load i32, i32* %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %28, i32 %29, i32 %30)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}

LLVM IR (-O2):
@.str.1 = [32 x i8] c"%d-%d-%d is the %dth day in %d\0A\00"
@.str.2 = [29 x i8] c"The %dth day in %d is %d-%d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [19 x i8] c"error:wrong input.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 10, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = tail call i32 @day_of_year(i32 2015, i32 10, i32 1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %11
9: ; preds = %0
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 2015, i32 10, i32 1, i32 %5, i32 2015)
br label %11
11: ; preds = %9, %7
%12 = add nsw i32 %5, 1
%13 = call i32 @month_day(i32 2015, i32 %12, i32* %1, i32* %2)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 2015, i32 %14, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}