#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, int *, int *);
int main() {
  int sum_day(int month, int day);
  int leap(int year);
  int year, month, day, days;
  printf("input date(year,month,day):");
  scanf("%d,%d,%d", &year, &month, &day);
  printf("%d/%d/%d ", year, month, day);
  days = sum_day(month, day);
  if (leap(year) && month >= 3)
    days = days + 1;
  printf("is the %dth day in this year.\n", days);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
call   1060 <scanf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <sum_day@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <leap@plt>
cmp    $0x0,%eax
je     11be <main+0x7e>
cmpl   $0x3,-0xc(%rbp)
jl     11be <main+0x7e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec2(%rip),%rdi
lea    0xc(%rsp),%rsi
lea    0x4(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1060 <scanf@plt>
mov    0xc(%rsp),%esi
mov    0x4(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%esi
call   1040 <sum_day@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   1030 <leap@plt>
test   %eax,%eax
setne  %al
cmpl   $0x3,0x4(%rsp)
setge  %cl
and    %al,%cl
movzbl %cl,%esi
add    %ebx,%esi
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [28 x i8] c"input date(year,month,day):\00"
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@.str.2 = [10 x i8] c"%d/%d/%d \00"
@.str.3 = [31 x i8] c"is the %dth day in this year.\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
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3, i32* %4)
%8 = load i32, i32* %2
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9, i32 %10)
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = call i32 @sum_day(i32 %12, i32 %13)
store i32 %14, i32* %5
%15 = load i32, i32* %2
%16 = call i32 @leap(i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %0
%19 = load i32, i32* %3
%20 = icmp sge i32 %19, 3
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %18, %0
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"input date(year,month,day):\00"
@.str.1 = [9 x i8] c"%d,%d,%d\00"
@.str.2 = [10 x i8] c"%d/%d/%d \00"
@.str.3 = [31 x i8] c"is the %dth day in this year.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10, i32 %11)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = call i32 @sum_day(i32 %13, i32 %14)
%16 = load i32, i32* %1
%17 = call i32 @leap(i32 %16)
%18 = icmp ne i32 %17, 0
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 2
%21 = select i1 %18, i1 %20, i1 false
%22 = zext i1 %21 to i32
%23 = add nsw i32 %15, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %23)
ret i32 0
}