#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 CountDay(long);
int CountMonth(long);
int CountYear(long);
int DateOfYear(int, int, int);
scalar_t__ Leap(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long date1 = 0, date2 = 0, t = 0;
  int year1 = 0, year2 = 0, month1 = 0, month2 = 0, day1 = 0, day2 = 0,
      lastnum = 0;
  int i;
  printf("请输入第一个年月日，按照20120424的格式\n");
  scanf("%ld", &date1);
  printf("请输入第二个年月日，按照20120424的格式\n");
  scanf("%ld", &date2);
  if (date1 > date2) {
    t = date1;
    date1 = date2;
    date2 = t;
  }
  year1 = CountYear(date1);
  month1 = CountMonth(date1);
  day1 = CountDay(date1);
  year2 = CountYear(date2);
  month2 = CountMonth(date2);
  day2 = CountDay(date2);
  for (i = year1; i < year2; i++) {
    if (Leap(i)) {
      lastnum++;
    }
  }
  lastnum = lastnum + 365 * (year2 - year1) - DateOfYear(year1, month1, day1) +
            DateOfYear(year2, month2, day2);
  printf("两个日期之间相隔%d天\n", lastnum);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe3c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jle    122a <main+0xba>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <CountYear@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <CountMonth@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <CountDay@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <CountYear@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <CountMonth@plt>
mov    %eax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <CountDay@plt>
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x28(%rbp),%eax
jge    12b2 <main+0x142>
mov    -0x40(%rbp),%edi
call   1040 <Leap@plt>
cmp    $0x0,%rax
je     129f <main+0x12f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    12a4 <main+0x134>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1278 <main+0x108>
mov    -0x3c(%rbp),%eax
mov    -0x28(%rbp),%ecx
sub    -0x24(%rbp),%ecx
imul   $0x16d,%ecx,%ecx
add    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1070 <DateOfYear@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
mov    -0x38(%rbp),%edx
call   1070 <DateOfYear@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%esi
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4d(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10a0 <scanf@plt>
mov    0x10(%rsp),%rax
mov    0x8(%rsp),%rdi
cmp    %rdi,%rax
jle    11f4 <main+0x74>
mov    %rdi,0x10(%rsp)
mov    %rax,0x8(%rsp)
jmp    11f7 <main+0x77>
mov    %rax,%rdi
call   1090 <CountYear@plt>
mov    %eax,%r14d
mov    0x10(%rsp),%rdi
call   1070 <CountMonth@plt>
mov    %eax,0x24(%rsp)
mov    0x10(%rsp),%rdi
call   1060 <CountDay@plt>
mov    %eax,0x20(%rsp)
mov    0x8(%rsp),%rdi
call   1090 <CountYear@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1070 <CountMonth@plt>
mov    %eax,0x1c(%rsp)
mov    0x8(%rsp),%rdi
call   1060 <CountDay@plt>
mov    %eax,%r13d
xor    %r15d,%r15d
mov    %ebp,%r12d
sub    %r14d,%r12d
jle    1276 <main+0xf6>
xor    %r15d,%r15d
mov    %r14d,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
call   1050 <Leap@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r15d
add    $0x1,%ebx
cmp    %ebx,%ebp
jne    1260 <main+0xe0>
imul   $0x16d,%r12d,%ebx
add    %r15d,%ebx
mov    %r14d,%edi
mov    0x24(%rsp),%esi
mov    0x20(%rsp),%edx
call   1080 <DateOfYear@plt>
sub    %eax,%ebx
mov    %ebp,%edi
mov    0x1c(%rsp),%esi
mov    %r13d,%edx
call   1080 <DateOfYear@plt>
add    %eax,%ebx
lea    0xd5b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [55 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AC\AC\E4\B8\80\E4\B8\AA\E5\B9\B4\E6\9C\88\E6\97\A5\EF\BC\8C\E6\8C\89\E7\85\A720120424\E7\9A\84\E6\A0\BC\E5\BC\8F\0A\00"
@.str.1 = [4 x i8] c"%ld\00"
@.str.2 = [55 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AC\AC\E4\BA\8C\E4\B8\AA\E5\B9\B4\E6\9C\88\E6\97\A5\EF\BC\8C\E6\8C\89\E7\85\A720120424\E7\9A\84\E6\A0\BC\E5\BC\8F\0A\00"
@.str.3 = [31 x i8] c"\E4\B8\A4\E4\B8\AA\E6\97\A5\E6\9C\9F\E4\B9\8B\E9\97\B4\E7\9B\B8\E9\9A\94%d\E5\A4\A9\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %3)
%17 = load i64, i64* %2
%18 = load i64, i64* %3
%19 = icmp sgt i64 %17, %18
br i1 %19, label %20, label %24
20: ; preds = %0
%21 = load i64, i64* %2
store i64 %21, i64* %4
%22 = load i64, i64* %3
store i64 %22, i64* %2
%23 = load i64, i64* %4
store i64 %23, i64* %3
br label %24
24: ; preds = %20, %0
%25 = load i64, i64* %2
%26 = call i32 @CountYear(i64 %25)
store i32 %26, i32* %5
%27 = load i64, i64* %2
%28 = call i32 @CountMonth(i64 %27)
store i32 %28, i32* %7
%29 = load i64, i64* %2
%30 = call i32 @CountDay(i64 %29)
store i32 %30, i32* %9
%31 = load i64, i64* %3
%32 = call i32 @CountYear(i64 %31)
store i32 %32, i32* %6
%33 = load i64, i64* %3
%34 = call i32 @CountMonth(i64 %33)
store i32 %34, i32* %8
%35 = load i64, i64* %3
%36 = call i32 @CountDay(i64 %35)
store i32 %36, i32* %10
%37 = load i32, i32* %5
store i32 %37, i32* %12
br label %38
38: ; preds = %50, %24
%39 = load i32, i32* %12
%40 = load i32, i32* %6
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %53
42: ; preds = %38
%43 = load i32, i32* %12
%44 = call i64 @Leap(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %49
46: ; preds = %42
%47 = load i32, i32* %11
%48 = add nsw i32 %47, 1
store i32 %48, i32* %11
br label %49
49: ; preds = %46, %42
br label %50
50: ; preds = %49
%51 = load i32, i32* %12
%52 = add nsw i32 %51, 1
store i32 %52, i32* %12
br label %38
53: ; preds = %38
%54 = load i32, i32* %11
%55 = load i32, i32* %6
%56 = load i32, i32* %5
%57 = sub nsw i32 %55, %56
%58 = mul nsw i32 365, %57
%59 = add nsw i32 %54, %58
%60 = load i32, i32* %5
%61 = load i32, i32* %7
%62 = load i32, i32* %9
%63 = call i32 @DateOfYear(i32 %60, i32 %61, i32 %62)
%64 = sub nsw i32 %59, %63
%65 = load i32, i32* %6
%66 = load i32, i32* %8
%67 = load i32, i32* %10
%68 = call i32 @DateOfYear(i32 %65, i32 %66, i32 %67)
%69 = add nsw i32 %64, %68
store i32 %69, i32* %11
%70 = load i32, i32* %11
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %70)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%ld\00"
@.str.3 = [31 x i8] c"\E4\B8\A4\E4\B8\AA\E6\97\A5\E6\9C\9F\E4\B9\8B\E9\97\B4\E7\9B\B8\E9\9A\94%d\E5\A4\A9\0A\00"
@str = [54 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AC\AC\E4\B8\80\E4\B8\AA\E5\B9\B4\E6\9C\88\E6\97\A5\EF\BC\8C\E6\8C\89\E7\85\A720120424\E7\9A\84\E6\A0\BC\E5\BC\8F\00"
@str.4 = [54 x i8] c"\E8\AF\B7\E8\BE\93\E5\85\A5\E7\AC\AC\E4\BA\8C\E4\B8\AA\E5\B9\B4\E6\9C\88\E6\97\A5\EF\BC\8C\E6\8C\89\E7\85\A720120424\E7\9A\84\E6\A0\BC\E5\BC\8F\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%4 = bitcast i64* %2 to i8*
store i64 0, i64* %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%9 = load i64, i64* %1
%10 = load i64, i64* %2
%11 = icmp sgt i64 %9, %10
br i1 %11, label %12, label %13
12: ; preds = %0
store i64 %10, i64* %1
store i64 %9, i64* %2
br label %13
13: ; preds = %12, %0
%14 = phi i64 [ %10, %12 ], [ %9, %0 ]
%15 = call i32 @CountYear(i64 %14)
%16 = load i64, i64* %1
%17 = call i32 @CountMonth(i64 %16)
%18 = load i64, i64* %1
%19 = call i32 @CountDay(i64 %18)
%20 = load i64, i64* %2
%21 = call i32 @CountYear(i64 %20)
%22 = load i64, i64* %2
%23 = call i32 @CountMonth(i64 %22)
%24 = load i64, i64* %2
%25 = call i32 @CountDay(i64 %24)
%26 = icmp sgt i32 %21, %15
br i1 %26, label %27, label %36
27: ; preds = %13, %27
%28 = phi i32 [ %34, %27 ], [ %15, %13 ]
%29 = phi i32 [ %33, %27 ], [ 0, %13 ]
%30 = call i64 @Leap(i32 %28)
%31 = icmp ne i64 %30, 0
%32 = zext i1 %31 to i32
%33 = add nuw nsw i32 %29, %32
%34 = add i32 %28, 1
%35 = icmp eq i32 %34, %21
br i1 %35, label %36, label %27
36: ; preds = %27, %13
%37 = phi i32 [ 0, %13 ], [ %33, %27 ]
%38 = sub nsw i32 %21, %15
%39 = mul nsw i32 %38, 365
%40 = add nsw i32 %37, %39
%41 = call i32 @DateOfYear(i32 %15, i32 %17, i32 %19)
%42 = sub i32 %40, %41
%43 = call i32 @DateOfYear(i32 %21, i32 %23, i32 %25)
%44 = add nsw i32 %42, %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i32 %44)
ret i32 0
}