#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 /*<<< orphan*/);
int Cyear(int, int);
int Rmonth(int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int main(void) {
  int startmonth = 1, endmonth = 1, startyear = 2001, endyear = 2002,
      startday = 1, endday = 1, sdays = 0, edays = 0, tdays = 0;
  sdays = Rmonth(startmonth, startyear) - startday;
  edays = endday - Cmonth(endmonth, endyear, 0);
  tdays = sdays + edays + Cyear(startyear, endyear);
  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   $0x7d2,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1060 <Rmonth@plt>
sub    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
xor    %edx,%edx
call   1030 <Cmonth@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <Cyear@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x24(%rbp),%edx
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%esi
lea    0xe50(%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   %r14
push   %rbx
mov    $0x1,%r14d
mov    $0x1,%edi
mov    $0x7d1,%esi
call   1060 <Rmonth@plt>
mov    %eax,%ebx
lea    -0x1(%rbx),%ebp
mov    $0x1,%edi
mov    $0x7d2,%esi
xor    %edx,%edx
call   1030 <Cmonth@plt>
sub    %eax,%r14d
add    %r14d,%ebx
add    $0xffffffff,%ebx
mov    $0x7d1,%edi
mov    $0x7d2,%esi
call   1050 <Cyear@plt>
add    %eax,%ebx
lea    0xe70(%rip),%rdi
mov    $0x1,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea1(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
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 2002, i32* %5
store i32 1, i32* %6
store i32 1, 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 @Rmonth(i32 %11, i32 %12)
%14 = load i32, i32* %6
%15 = sub nsw i32 %13, %14
store i32 %15, i32* %8
%16 = load i32, i32* %7
%17 = load i32, i32* %3
%18 = load i32, i32* %5
%19 = call i32 @Cmonth(i32 %17, i32 %18, i32 0)
%20 = sub nsw i32 %16, %19
store i32 %20, i32* %9
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = add nsw i32 %21, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = call i32 @Cyear(i32 %24, i32 %25)
%27 = add nsw i32 %23, %26
store i32 %27, i32* %10
%28 = load i32, i32* %2
%29 = load i32, i32* %8
%30 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %3
%32 = load i32, i32* %9
%33 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32)
%34 = load i32, i32* %10
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %34)
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 @Rmonth(i32 1, i32 2001)
%2 = add nsw i32 %1, -1
%3 = tail call i32 @Cmonth(i32 1, i32 2002, i32 0)
%4 = sub nsw i32 1, %3
%5 = add nsw i32 %4, %2
%6 = tail call i32 @Cyear(i32 2001, i32 2002)
%7 = add nsw i32 %5, %6
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i32 1, i32 %2)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %4)
%10 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %7)
ret i32 0
}