#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int, ...);
int scanf(char *, int *, ...);
int /*<<< orphan*/ stdin;
int main() {
  freopen("input.txt", "r", stdin);
  int d1, d2, m1, m2, y1, y2, age, t, i;
  while (scanf("%d", &t) == 1) {
    for (i = 1; i <= t; i++) {
      scanf("%d/%d/%d", &d2, &m2, &y2);
      scanf("%d/%d/%d", &d1, &m1, &y1);
      if (d1 > d2) {
        d2 = d2 + 30;
        m1 = m1 + 1;
      }
      if (m1 > m2) {
        m2 = m2 + 12;
        y1 = y1 + 1;
      }
      age = y2 - y1;
      if (age < 0)
        printf("Case #%d: Invalid birth date\n", i);
      else if (age > 130)
        printf("Case #%d: Check birth date\n", i);
      else
        printf("Case #%d: %d\n", i, age);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
lea    0xeb1(%rip),%rdi
lea    0xeb4(%rip),%rsi
call   1040 <freopen@plt>
lea    0xeb0(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1276 <main+0x146>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1271 <main+0x141>
lea    0xe7c(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
lea    0xe62(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    11db <main+0xab>
mov    -0xc(%rbp),%eax
add    $0x1e,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    11f9 <main+0xc9>
mov    -0x14(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1222 <main+0xf2>
mov    -0x28(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <main+0x12e>
cmpl   $0x82,-0x20(%rbp)
jle    1245 <main+0x115>
mov    -0x28(%rbp),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <main+0x129>
mov    -0x28(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <main+0x12e>
jmp    1263 <main+0x133>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    117d <main+0x4d>
jmp    115b <main+0x2b>
xor    %eax,%eax
add    $0x30,%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    0x2ea3(%rip),%rax
mov    (%rax),%edx
lea    0xeb2(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1040 <freopen@plt>
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1296 <main+0x166>
lea    0xe8f(%rip),%rbx
lea    0x20(%rsp),%rbp
lea    0x24(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    11bc <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe6b(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1296 <main+0x166>
cmpl   $0x0,0xc(%rsp)
jle    11a0 <main+0x70>
xor    %r13d,%r13d
jmp    11e8 <main+0xb8>
nopl   0x0(%rax,%rax,1)
lea    0xe3e(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    0xc(%rsp),%r13d
jge    11a0 <main+0x70>
mov    %rbx,%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x1c(%rsp),%eax
cmp    %eax,0x24(%rsp)
jle    1230 <main+0x100>
add    $0x1e,%eax
mov    %eax,0x1c(%rsp)
mov    0x14(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x14(%rsp)
jmp    1234 <main+0x104>
mov    0x14(%rsp),%eax
mov    0x18(%rsp),%ecx
cmp    %ecx,%eax
jle    1250 <main+0x120>
add    $0xc,%ecx
mov    %ecx,0x18(%rsp)
mov    0x10(%rsp),%eax
add    $0x1,%eax
mov    %eax,0x10(%rsp)
jmp    1254 <main+0x124>
mov    0x10(%rsp),%eax
add    $0x1,%r13d
mov    0x20(%rsp),%edx
sub    %eax,%edx
js     11d0 <main+0xa0>
cmp    $0x83,%edx
jb     1280 <main+0x150>
lea    0xdc0(%rip),%rdi
jmp    11d7 <main+0xa7>
nopl   0x0(%rax,%rax,1)
lea    0xdc8(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e1 <main+0xb1>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
@.str.4 = [30 x i8] c"Case #%d: Invalid birth date\0A\00"
@.str.5 = [28 x i8] c"Case #%d: Check birth date\0A\00"
@.str.6 = [14 x i8] c"Case #%d: %d\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
%11 = load i32, i32* @stdin
%12 = call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %65, %0
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %66
16: ; preds = %13
store i32 1, i32* %10
br label %17
17: ; preds = %62, %16
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %65
21: ; preds = %17
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %3, i32* %5, i32* %7)
%23 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %4, i32* %6)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = icmp sgt i32 %24, %25
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 30
store i32 %29, i32* %3
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
br label %32
32: ; preds = %27, %21
%33 = load i32, i32* %4
%34 = load i32, i32* %5
%35 = icmp sgt i32 %33, %34
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = load i32, i32* %5
%38 = add nsw i32 %37, 12
store i32 %38, i32* %5
%39 = load i32, i32* %6
%40 = add nsw i32 %39, 1
store i32 %40, i32* %6
br label %41
41: ; preds = %36, %32
%42 = load i32, i32* %7
%43 = load i32, i32* %6
%44 = sub nsw i32 %42, %43
store i32 %44, i32* %8
%45 = load i32, i32* %8
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %50
47: ; preds = %41
%48 = load i32, i32* %10
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %48)
br label %61
50: ; preds = %41
%51 = load i32, i32* %8
%52 = icmp sgt i32 %51, 130
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %10
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %54)
br label %60
56: ; preds = %50
%57 = load i32, i32* %10
%58 = load i32, i32* %8
%59 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 %58)
br label %60
60: ; preds = %56, %53
br label %61
61: ; preds = %60, %47
br label %62
62: ; preds = %61
%63 = load i32, i32* %10
%64 = add nsw i32 %63, 1
store i32 %64, i32* %10
br label %17
65: ; preds = %17
br label %13
66: ; preds = %13
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [9 x i8] c"%d/%d/%d\00"
@.str.4 = [30 x i8] c"Case #%d: Invalid birth date\0A\00"
@.str.5 = [28 x i8] c"Case #%d: Check birth date\0A\00"
@.str.6 = [14 x i8] c"Case #%d: %d\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 = load i32, i32* @stdin
%9 = tail call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = bitcast i32* %1 to i8*
%11 = bitcast i32* %2 to i8*
%12 = bitcast i32* %3 to i8*
%13 = bitcast i32* %4 to i8*
%14 = bitcast i32* %5 to i8*
%15 = bitcast i32* %6 to i8*
%16 = bitcast i32* %7 to i8*
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%18 = icmp eq i32 %17, 1
br i1 %18, label %22, label %65
19: ; preds = %61, %22
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %65
22: ; preds = %0, %19
%23 = load i32, i32* %7
%24 = icmp slt i32 %23, 1
br i1 %24, label %19, label %25
25: ; preds = %22, %61
%26 = phi i32 [ %62, %61 ], [ 1, %22 ]
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %2, i32* %4, i32* %6)
%28 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32* %1, i32* %3, i32* %5)
%29 = load i32, i32* %1
%30 = load i32, i32* %2
%31 = icmp sgt i32 %29, %30
br i1 %31, label %34, label %32
32: ; preds = %25
%33 = load i32, i32* %3
br label %38
34: ; preds = %25
%35 = add nsw i32 %30, 30
store i32 %35, i32* %2
%36 = load i32, i32* %3
%37 = add nsw i32 %36, 1
store i32 %37, i32* %3
br label %38
38: ; preds = %32, %34
%39 = phi i32 [ %33, %32 ], [ %37, %34 ]
%40 = load i32, i32* %4
%41 = icmp sgt i32 %39, %40
br i1 %41, label %44, label %42
42: ; preds = %38
%43 = load i32, i32* %5
br label %48
44: ; preds = %38
%45 = add nsw i32 %40, 12
store i32 %45, i32* %4
%46 = load i32, i32* %5
%47 = add nsw i32 %46, 1
store i32 %47, i32* %5
br label %48
48: ; preds = %42, %44
%49 = phi i32 [ %43, %42 ], [ %47, %44 ]
%50 = load i32, i32* %6
%51 = sub nsw i32 %50, %49
%52 = icmp slt i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %48
%54 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %26)
br label %61
55: ; preds = %48
%56 = icmp ugt i32 %51, 130
br i1 %56, label %57, label %59
57: ; preds = %55
%58 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 %26)
br label %61
59: ; preds = %55
%60 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i32 %26, i32 %51)
br label %61
61: ; preds = %53, %59, %57
%62 = add nuw nsw i32 %26, 1
%63 = load i32, i32* %7
%64 = icmp slt i32 %26, %63
br i1 %64, label %25, label %19
65: ; preds = %19, %0
ret i32 0
}