#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 */
scalar_t__ EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getmonth(char *);
int /*<<< orphan*/ printf(char *, int, int);
scalar_t__ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  int i, t, day1, year1, day2, year2, ans;
  char month1[10], month2[10];
  fflush(stdin);
  while (scanf("%d", &t) != EOF) {
    if (t > 500)
      exit(1);
    for (i = 1; i <= t; i++) {
      scanf("%s %d, %d", month1, &day1, &year1);
      scanf("%s %d, %d", month2, &day2, &year2);
      if (getmonth(month1) < 3)
        --year1;
      if (getmonth(month2) < 2 || (getmonth(month2) == 2 && day2 < 29))
        --year2;
      ans = (year2 / 4 - year2 / 100 + year2 / 400) -
            (year1 / 4 - year1 / 100 + year1 / 400);
      printf("Case %d: %d\n", i, ans);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xe8c(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
je     12d4 <main+0x184>
cmpl   $0x1f4,-0x18(%rbp)
jle    11ad <main+0x5d>
mov    $0x1,%edi
call   1070 <exit@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12cf <main+0x17f>
lea    -0x36(%rbp),%rsi
lea    0xe35(%rip),%rdi
lea    -0x1c(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe1b(%rip),%rdi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
mov    $0x0,%al
call   1060 <scanf@plt>
lea    -0x36(%rbp),%rdi
call   1050 <getmonth@plt>
cmp    $0x3,%eax
jge    120f <main+0xbf>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <getmonth@plt>
cmp    $0x2,%eax
jl     123d <main+0xed>
lea    -0x40(%rbp),%rdi
call   1050 <getmonth@plt>
cmp    $0x2,%eax
jne    1246 <main+0xf6>
cmpl   $0x1d,-0x24(%rbp)
jge    1246 <main+0xf6>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x190,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
mov    $0x64,%esi
cltd
idiv   %esi
sub    %eax,%ecx
mov    -0x20(%rbp),%eax
mov    $0x190,%esi
cltd
idiv   %esi
mov    %eax,%edx
mov    -0x44(%rbp),%eax
add    %edx,%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xd4e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11b4 <main+0x64>
jmp    1174 <main+0x24>
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
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
call   1040 <fflush@plt>
lea    0xe94(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%rax
jne    119c <main+0x4c>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe5d(%rip),%r12
lea    0x1e(%rsp),%r13
lea    0x14(%rsp),%r14
jmp    11cf <main+0x7f>
nop
lea    0xe50(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x2e16(%rip),%rcx
cmp    (%rcx),%rax
je     118b <main+0x3b>
mov    0x4(%rsp),%eax
cmp    $0x1f4,%eax
jg     12fe <main+0x1ae>
test   %eax,%eax
jle    11b0 <main+0x60>
xor    %r15d,%r15d
jmp    128b <main+0x13b>
nopw   0x0(%rax,%rax,1)
mov    (%rsp),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rsp)
lea    0x3(%rcx),%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x2,%eax
movslq %ecx,%rcx
imul   $0xffffffffae147ae1,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x25,%rdx
add    %esi,%edx
imul   $0x51eb851f,%rcx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x27,%rcx
add    %esi,%ecx
movslq 0x8(%rsp),%rsi
lea    0x3(%rsi),%edi
test   %esi,%esi
cmovns %esi,%edi
sar    $0x2,%edi
imul   $0x51eb851f,%rsi,%rbp
mov    %rbp,%rbx
shr    $0x3f,%rbx
sar    $0x25,%rbp
add    %ebx,%ebp
imul   $0xffffffffae147ae1,%rsi,%rsi
mov    %rsi,%rbx
shr    $0x3f,%rbx
sar    $0x27,%rsi
add    %ebx,%esi
add    %eax,%edx
add    %ecx,%edx
sub    %edi,%edx
add    %ebp,%edx
add    %esi,%edx
lea    0xd92(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
cmp    0x4(%rsp),%r15d
jge    11b0 <main+0x60>
mov    %r12,%rdi
mov    %r13,%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
lea    0xc(%rsp),%rdx
mov    %rsp,%rcx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %r13,%rdi
call   1050 <getmonth@plt>
cmp    $0x2,%eax
jg     12c9 <main+0x179>
addl   $0xffffffff,0x8(%rsp)
add    $0x1,%r15d
mov    %r14,%rdi
call   1050 <getmonth@plt>
cmp    $0x2,%eax
jl     11f0 <main+0xa0>
mov    %r14,%rdi
call   1050 <getmonth@plt>
cmp    $0x2,%eax
jne    12f6 <main+0x1a6>
cmpl   $0x1d,0xc(%rsp)
jl     11f0 <main+0xa0>
mov    (%rsp),%ecx
jmp    11f9 <main+0xa9>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"%s %d, %d\00"
@.str.2 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [10 x i8]
%14 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = load i32, i32* @stdin
%16 = call i32 @fflush(i32 %15)
br label %17
17: ; preds = %80, %2
%18 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
%19 = load i64, i64* @EOF
%20 = icmp ne i64 %18, %19
br i1 %20, label %21, label %81
21: ; preds = %17
%22 = load i32, i32* %7
%23 = icmp sgt i32 %22, 500
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %21
store i32 1, i32* %6
br label %27
27: ; preds = %77, %26
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = icmp sle i32 %28, %29
br i1 %30, label %31, label %80
31: ; preds = %27
%32 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%33 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %32, i32* %8, i32* %9)
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%35 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %34, i32* %10, i32* %11)
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %13, i64 0, i64 0
%37 = call i32 @getmonth(i8* %36)
%38 = icmp slt i32 %37, 3
br i1 %38, label %39, label %42
39: ; preds = %31
%40 = load i32, i32* %9
%41 = add nsw i32 %40, -1
store i32 %41, i32* %9
br label %42
42: ; preds = %39, %31
%43 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%44 = call i32 @getmonth(i8* %43)
%45 = icmp slt i32 %44, 2
br i1 %45, label %53, label %46
46: ; preds = %42
%47 = getelementptr inbounds [10 x i8], [10 x i8]* %14, i64 0, i64 0
%48 = call i32 @getmonth(i8* %47)
%49 = icmp eq i32 %48, 2
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load i32, i32* %10
%52 = icmp slt i32 %51, 29
br i1 %52, label %53, label %56
53: ; preds = %50, %42
%54 = load i32, i32* %11
%55 = add nsw i32 %54, -1
store i32 %55, i32* %11
br label %56
56: ; preds = %53, %50, %46
%57 = load i32, i32* %11
%58 = sdiv i32 %57, 4
%59 = load i32, i32* %11
%60 = sdiv i32 %59, 100
%61 = sub nsw i32 %58, %60
%62 = load i32, i32* %11
%63 = sdiv i32 %62, 400
%64 = add nsw i32 %61, %63
%65 = load i32, i32* %9
%66 = sdiv i32 %65, 4
%67 = load i32, i32* %9
%68 = sdiv i32 %67, 100
%69 = sub nsw i32 %66, %68
%70 = load i32, i32* %9
%71 = sdiv i32 %70, 400
%72 = add nsw i32 %69, %71
%73 = sub nsw i32 %64, %72
store i32 %73, i32* %12
%74 = load i32, i32* %6
%75 = load i32, i32* %12
%76 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %75)
br label %77
77: ; preds = %56
%78 = load i32, i32* %6
%79 = add nsw i32 %78, 1
store i32 %79, i32* %6
br label %27
80: ; preds = %27
br label %17
81: ; preds = %17
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [10 x i8] c"%s %d, %d\00"
@.str.2 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [10 x i8]
%9 = alloca [10 x i8]
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = tail call i32 @fflush(i32 %17)
%19 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%20 = load i64, i64* @EOF
%21 = icmp eq i64 %19, %20
br i1 %21, label %74, label %26
22: ; preds = %56, %29
%23 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%24 = load i64, i64* @EOF
%25 = icmp eq i64 %23, %24
br i1 %25, label %74, label %26
26: ; preds = %2, %22
%27 = load i32, i32* %3
%28 = icmp sgt i32 %27, 500
br i1 %28, label %31, label %29
29: ; preds = %26
%30 = icmp slt i32 %27, 1
br i1 %30, label %22, label %33
31: ; preds = %26
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %29, %56
%34 = phi i32 [ %71, %56 ], [ 1, %29 ]
%35 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %15, i32* %4, i32* %5)
%36 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %16, i32* %6, i32* %7)
%37 = call i32 @getmonth(i8* %15)
%38 = icmp slt i32 %37, 3
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = load i32, i32* %5
%41 = add nsw i32 %40, -1
store i32 %41, i32* %5
br label %42
42: ; preds = %39, %33
%43 = call i32 @getmonth(i8* %16)
%44 = icmp slt i32 %43, 2
br i1 %44, label %53, label %45
45: ; preds = %42
%46 = call i32 @getmonth(i8* %16)
%47 = icmp eq i32 %46, 2
%48 = load i32, i32* %6
%49 = icmp slt i32 %48, 29
%50 = select i1 %47, i1 %49, i1 false
br i1 %50, label %53, label %51
51: ; preds = %45
%52 = load i32, i32* %7
br label %56
53: ; preds = %45, %42
%54 = load i32, i32* %7
%55 = add nsw i32 %54, -1
store i32 %55, i32* %7
br label %56
56: ; preds = %51, %53
%57 = phi i32 [ %52, %51 ], [ %55, %53 ]
%58 = sdiv i32 %57, 4
%59 = sdiv i32 %57, -100
%60 = sdiv i32 %57, 400
%61 = load i32, i32* %5
%62 = sdiv i32 %61, -4
%63 = sdiv i32 %61, 100
%64 = sdiv i32 %61, -400
%65 = add nsw i32 %59, %58
%66 = add nsw i32 %65, %60
%67 = add nsw i32 %66, %62
%68 = add nsw i32 %67, %63
%69 = add nsw i32 %68, %64
%70 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %69)
%71 = add nuw nsw i32 %34, 1
%72 = load i32, i32* %3
%73 = icmp slt i32 %34, %72
br i1 %73, label %33, label %22
74: ; preds = %22, %2
ret i32 0
}