#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 Cmonth(int, int, int);
int Cyear(int, int);
int Rmonth(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  int startmonth = 1, endmonth = 1, startyear = 2001, endyear = 4001,
      startday = 1, endday = 2, sdays = 0, edays = 0, tdays = 0;
  sdays = Cmonth(startmonth, startyear, 1) - startday;
  edays = Cmonth(endmonth, endyear, 0) - (Rmonth(endmonth, endyear) - endday);
  tdays = Cyear(startyear, endyear) + (sdays + edays);
  printf("Starting month %d has %d days left in the year!\n", startmonth,
         sdays);
  printf("Ending month %d is %d days into the year!\n", endmonth, edays);
  printf(" %d total days!\n", tdays);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x7d1,-0x10(%rbp)
movl   $0xfa1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    $0x1,%edx
call   1030 <Cmonth@plt>
sub    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <Cmonth@plt>
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1060 <Rmonth@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    -0x1c(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <Cyear@plt>
mov    -0x20(%rbp),%ecx
add    -0x24(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x7d1,%esi
mov    $0x1,%edx
call   1030 <Cmonth@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%r14d
mov    $0x1,%edi
mov    $0xfa1,%esi
xor    %edx,%edx
call   1030 <Cmonth@plt>
mov    %eax,%ebp
mov    $0x1,%edi
mov    $0xfa1,%esi
call   1060 <Rmonth@plt>
sub    %eax,%ebp
lea    0x2(%rbp),%r15d
mov    $0x7d1,%edi
mov    $0xfa1,%esi
call   1050 <Cyear@plt>
add    %ebp,%ebx
add    $0x1,%ebx
add    %eax,%ebx
lea    0xe5a(%rip),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe75(%rip),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Starting month %d has %d days left in the year!\0A\00"
@.str.1 = [43 x i8] c"Ending month %d is %d days into the year!\0A\00"
@.str.2 = [17 x i8] c" %d total days!\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
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 1, i32* %3
store i32 2001, i32* %4
store i32 4001, i32* %5
store i32 1, i32* %6
store i32 2, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %2
%12 = load i32, i32* %4
%13 = call i32 @Cmonth(i32 %11, i32 %12, i32 1)
%14 = load i32, i32* %6
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %8
%16 = load i32, i32* %3
%17 = load i32, i32* %5
%18 = call i32 @Cmonth(i32 %16, i32 %17, i32 0)
%19 = load i32, i32* %3
%20 = load i32, i32* %5
%21 = call i32 @Rmonth(i32 %19, i32 %20)
%22 = load i32, i32* %7
%23 = sub nsw i32 %21, %22
%24 = sub nsw i32 %18, %23
store i32 %24, i32* %9
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 @Cyear(i32 %25, i32 %26)
%28 = load i32, i32* %8
%29 = load i32, i32* %9
%30 = add nsw i32 %28, %29
%31 = add nsw i32 %27, %30
store i32 %31, i32* %10
%32 = load i32, i32* %2
%33 = load i32, i32* %8
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %32, i32 %33)
%35 = load i32, i32* %3
%36 = load i32, i32* %9
%37 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %10
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [49 x i8] c"Starting month %d has %d days left in the year!\0A\00"
@.str.1 = [43 x i8] c"Ending month %d is %d days into the year!\0A\00"
@.str.2 = [17 x i8] c" %d total days!\0A\00"
define i32 @main() {
%1 = tail call i32 @Cmonth(i32 1, i32 2001, i32 1)
%2 = add nsw i32 %1, -1
%3 = tail call i32 @Cmonth(i32 1, i32 4001, i32 0)
%4 = tail call i32 @Rmonth(i32 1, i32 4001)
%5 = add i32 %3, 2
%6 = sub i32 %5, %4
%7 = tail call i32 @Cyear(i32 2001, i32 4001)
%8 = add nsw i32 %6, %2
%9 = add nsw i32 %8, %7
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 1, i32 %2)
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %6)
%12 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %9)
ret i32 0
}