#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 if_all_digits(char *);
int if_last_digit_right(char *);
int if_lead_year(int);
int make_integers(char *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char EGN[12];
  scanf("%s", EGN);
  if (strlen(EGN) == 10) {
    if (if_all_digits(&EGN[0]) == 1) {
      int last_digit = make_integers(&EGN[9], 1);
      int year = make_integers(&EGN[0], 2);
      int month = make_integers(&EGN[2], 2);
      int day = make_integers(&EGN[4], 2);
      if (month > 12)
        month -= 40;
      switch (month) {
      case 1:
      case 3:
      case 5:
      case 7:
      case 8:
      case 10:
      case 12:
        if (day > 31 || day < 1)
          printf("0");
        else {
          if (last_digit == if_last_digit_right(&EGN[0]))
            printf("1");
          else
            printf("0");
        }
        break;
      case 4:
      case 6:
      case 9:
      case 11:
        if (day > 30 || day < 1)
          printf("0");
        else {
          if (last_digit == if_last_digit_right(&EGN[0]))
            printf("1");
          else
            printf("0");
        }
        break;
      case 2:
        if (if_lead_year(year) == 1) {
          if (day > 29 || day < 1)
            printf("0");
          else {
            if (last_digit == if_last_digit_right(&EGN[0]))
              printf("1");
            else
              printf("0");
          }
        } else {
          if (day > 28 || day < 1)
            printf("0");
          else {
            if (last_digit == if_last_digit_right(&EGN[0]))
              printf("1");
            else
              printf("0");
          }
        }
        break;
      default:
        printf("0");
        break;
      }
    } else {
      printf("0");
    }
  } else {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x10(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jne    14af <main+0x33f>
lea    -0x10(%rbp),%rdi
call   1080 <if_all_digits@plt>
cmp    $0x1,%eax
jne    149e <main+0x32e>
lea    -0x10(%rbp),%rdi
add    $0x9,%rdi
mov    $0x1,%esi
call   1060 <make_integers@plt>
mov    %eax,-0x14(%rbp)
lea    -0x10(%rbp),%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,-0x18(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x2,%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xc,-0x1c(%rbp)
jle    1216 <main+0xa6>
mov    -0x1c(%rbp),%eax
sub    $0x28,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x1,%eax
je     12d7 <main+0x167>
jmp    122a <main+0xba>
mov    -0x24(%rbp),%eax
sub    $0x2,%eax
je     13a7 <main+0x237>
jmp    123b <main+0xcb>
mov    -0x24(%rbp),%eax
sub    $0x3,%eax
je     12d7 <main+0x167>
jmp    124c <main+0xdc>
mov    -0x24(%rbp),%eax
sub    $0x4,%eax
je     133f <main+0x1cf>
jmp    125d <main+0xed>
mov    -0x24(%rbp),%eax
sub    $0x5,%eax
je     12d7 <main+0x167>
jmp    126e <main+0xfe>
mov    -0x24(%rbp),%eax
sub    $0x6,%eax
je     133f <main+0x1cf>
jmp    127f <main+0x10f>
mov    -0x24(%rbp),%eax
add    $0xfffffff9,%eax
sub    $0x2,%eax
jb     12d7 <main+0x167>
jmp    1293 <main+0x123>
mov    -0x24(%rbp),%eax
sub    $0x9,%eax
je     133f <main+0x1cf>
jmp    12a4 <main+0x134>
mov    -0x24(%rbp),%eax
sub    $0xa,%eax
je     12d7 <main+0x167>
jmp    12b5 <main+0x145>
mov    -0x24(%rbp),%eax
sub    $0xb,%eax
je     133f <main+0x1cf>
jmp    12c6 <main+0x156>
mov    -0x24(%rbp),%eax
sub    $0xc,%eax
jne    148d <main+0x31d>
jmp    12d7 <main+0x167>
cmpl   $0x1f,-0x20(%rbp)
jg     12eb <main+0x17b>
cmpl   $0x1,-0x20(%rbp)
jge    12fc <main+0x18c>
lea    0xd11(%rip),%rdi
call   1040 <printf@plt>
jmp    133a <main+0x1ca>
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x10(%rbp),%rdi
call   1090 <if_last_digit_right@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jne    1329 <main+0x1b9>
lea    0xce6(%rip),%rdi
call   1040 <printf@plt>
jmp    1335 <main+0x1c5>
lea    0xcd3(%rip),%rdi
call   1040 <printf@plt>
jmp    133a <main+0x1ca>
jmp    1499 <main+0x329>
cmpl   $0x1e,-0x20(%rbp)
jg     1353 <main+0x1e3>
cmpl   $0x1,-0x20(%rbp)
jge    1364 <main+0x1f4>
lea    0xca9(%rip),%rdi
call   1040 <printf@plt>
jmp    13a2 <main+0x232>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x10(%rbp),%rdi
call   1090 <if_last_digit_right@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jne    1391 <main+0x221>
lea    0xc7e(%rip),%rdi
call   1040 <printf@plt>
jmp    139d <main+0x22d>
lea    0xc6b(%rip),%rdi
call   1040 <printf@plt>
jmp    13a2 <main+0x232>
jmp    1499 <main+0x329>
mov    -0x18(%rbp),%edi
call   1050 <if_lead_year@plt>
cmp    $0x1,%eax
jne    1420 <main+0x2b0>
cmpl   $0x1d,-0x20(%rbp)
jg     13cc <main+0x25c>
cmpl   $0x1,-0x20(%rbp)
jge    13dd <main+0x26d>
lea    0xc30(%rip),%rdi
call   1040 <printf@plt>
jmp    141b <main+0x2ab>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x10(%rbp),%rdi
call   1090 <if_last_digit_right@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%eax
cmp    %ecx,%eax
jne    140a <main+0x29a>
lea    0xc05(%rip),%rdi
call   1040 <printf@plt>
jmp    1416 <main+0x2a6>
lea    0xbf2(%rip),%rdi
call   1040 <printf@plt>
jmp    141b <main+0x2ab>
jmp    1488 <main+0x318>
cmpl   $0x1c,-0x20(%rbp)
jg     1434 <main+0x2c4>
cmpl   $0x1,-0x20(%rbp)
jge    1445 <main+0x2d5>
lea    0xbc8(%rip),%rdi
call   1040 <printf@plt>
jmp    1483 <main+0x313>
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
lea    -0x10(%rbp),%rdi
call   1090 <if_last_digit_right@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jne    1472 <main+0x302>
lea    0xb9d(%rip),%rdi
call   1040 <printf@plt>
jmp    147e <main+0x30e>
lea    0xb8a(%rip),%rdi
call   1040 <printf@plt>
jmp    1483 <main+0x313>
jmp    1488 <main+0x318>
jmp    1499 <main+0x329>
lea    0xb6f(%rip),%rdi
call   1040 <printf@plt>
jmp    14aa <main+0x33a>
lea    0xb5e(%rip),%rdi
call   1040 <printf@plt>
jmp    14bb <main+0x34b>
lea    0xb4d(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe7d(%rip),%rdi
lea    0x4(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    $0x30,%ebx
cmp    $0xa,%eax
jne    124d <main+0xdd>
lea    0x4(%rsp),%rdi
call   1080 <if_all_digits@plt>
cmp    $0x1,%eax
jne    124d <main+0xdd>
lea    0xd(%rsp),%rdi
mov    $0x1,%esi
call   1060 <make_integers@plt>
mov    %eax,%r14d
lea    0x4(%rsp),%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,%r15d
lea    0x6(%rsp),%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,%ebp
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
call   1060 <make_integers@plt>
mov    %eax,%r12d
lea    -0x28(%rbp),%eax
cmp    $0xd,%ebp
cmovl  %ebp,%eax
cmp    $0xc,%eax
ja     124d <main+0xdd>
mov    $0x15aa,%ecx
bt     %eax,%ecx
jae    1224 <main+0xb4>
add    $0xffffffe0,%r12d
cmp    $0xffffffe1,%r12d
jae    1238 <main+0xc8>
jmp    124d <main+0xdd>
mov    $0xa50,%ecx
bt     %eax,%ecx
jae    1263 <main+0xf3>
add    $0xffffffe1,%r12d
cmp    $0xffffffe2,%r12d
jb     124d <main+0xdd>
lea    0x4(%rsp),%rdi
call   1090 <if_last_digit_right@plt>
xor    %ebx,%ebx
cmp    %eax,%r14d
sete   %bl
or     $0x30,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x2,%eax
jne    124d <main+0xdd>
mov    %r15d,%edi
call   1050 <if_lead_year@plt>
cmp    $0x1,%eax
jne    1281 <main+0x111>
add    $0xffffffe2,%r12d
cmp    $0xffffffe3,%r12d
jae    1238 <main+0xc8>
jmp    124d <main+0xdd>
add    $0xffffffe3,%r12d
cmp    $0xffffffe4,%r12d
jae    1238 <main+0xc8>
jmp    124d <main+0xdd>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = icmp eq i32 %10, 10
br i1 %11, label %12, label %119
12: ; preds = %0
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%14 = call i32 @if_all_digits(i8* %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %116
16: ; preds = %12
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 9
%18 = call i32 @make_integers(i8* %17, i32 1)
store i32 %18, i32* %3
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%20 = call i32 @make_integers(i8* %19, i32 2)
store i32 %20, i32* %4
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 2
%22 = call i32 @make_integers(i8* %21, i32 2)
store i32 %22, i32* %5
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 4
%24 = call i32 @make_integers(i8* %23, i32 2)
store i32 %24, i32* %6
%25 = load i32, i32* %5
%26 = icmp sgt i32 %25, 12
br i1 %26, label %27, label %30
27: ; preds = %16
%28 = load i32, i32* %5
%29 = sub nsw i32 %28, 40
store i32 %29, i32* %5
br label %30
30: ; preds = %27, %16
%31 = load i32, i32* %5
switch i32 %31, label %113 [
i32 1, label %32
i32 3, label %32
i32 5, label %32
i32 7, label %32
i32 8, label %32
i32 10, label %32
i32 12, label %32
i32 4, label %51
i32 6, label %51
i32 9, label %51
i32 11, label %51
i32 2, label %70
]
32: ; preds = %30, %30, %30, %30, %30, %30, %30
%33 = load i32, i32* %6
%34 = icmp sgt i32 %33, 31
br i1 %34, label %38, label %35
35: ; preds = %32
%36 = load i32, i32* %6
%37 = icmp slt i32 %36, 1
br i1 %37, label %38, label %40
38: ; preds = %35, %32
%39 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %50
40: ; preds = %35
%41 = load i32, i32* %3
%42 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%43 = call i32 @if_last_digit_right(i8* %42)
%44 = icmp eq i32 %41, %43
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %49
47: ; preds = %40
%48 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
br label %50
50: ; preds = %49, %38
br label %115
51: ; preds = %30, %30, %30, %30
%52 = load i32, i32* %6
%53 = icmp sgt i32 %52, 30
br i1 %53, label %57, label %54
54: ; preds = %51
%55 = load i32, i32* %6
%56 = icmp slt i32 %55, 1
br i1 %56, label %57, label %59
57: ; preds = %54, %51
%58 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %69
59: ; preds = %54
%60 = load i32, i32* %3
%61 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%62 = call i32 @if_last_digit_right(i8* %61)
%63 = icmp eq i32 %60, %62
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %68
66: ; preds = %59
%67 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %68
68: ; preds = %66, %64
br label %69
69: ; preds = %68, %57
br label %115
70: ; preds = %30
%71 = load i32, i32* %4
%72 = call i32 @if_lead_year(i32 %71)
%73 = icmp eq i32 %72, 1
br i1 %73, label %74, label %93
74: ; preds = %70
%75 = load i32, i32* %6
%76 = icmp sgt i32 %75, 29
br i1 %76, label %80, label %77
77: ; preds = %74
%78 = load i32, i32* %6
%79 = icmp slt i32 %78, 1
br i1 %79, label %80, label %82
80: ; preds = %77, %74
%81 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %92
82: ; preds = %77
%83 = load i32, i32* %3
%84 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%85 = call i32 @if_last_digit_right(i8* %84)
%86 = icmp eq i32 %83, %85
br i1 %86, label %87, label %89
87: ; preds = %82
%88 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %91
89: ; preds = %82
%90 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %91
91: ; preds = %89, %87
br label %92
92: ; preds = %91, %80
br label %112
93: ; preds = %70
%94 = load i32, i32* %6
%95 = icmp sgt i32 %94, 28
br i1 %95, label %99, label %96
96: ; preds = %93
%97 = load i32, i32* %6
%98 = icmp slt i32 %97, 1
br i1 %98, label %99, label %101
99: ; preds = %96, %93
%100 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %111
101: ; preds = %96
%102 = load i32, i32* %3
%103 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%104 = call i32 @if_last_digit_right(i8* %103)
%105 = icmp eq i32 %102, %104
br i1 %105, label %106, label %108
106: ; preds = %101
%107 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %110
108: ; preds = %101
%109 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %110
110: ; preds = %108, %106
br label %111
111: ; preds = %110, %99
br label %112
112: ; preds = %111, %92
br label %115
113: ; preds = %30
%114 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %115
115: ; preds = %113, %112, %69, %50
br label %118
116: ; preds = %12
%117 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %118
118: ; preds = %116, %115
br label %121
119: ; preds = %0
%120 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %121
121: ; preds = %119, %118
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
%5 = icmp eq i32 %4, 10
br i1 %5, label %6, label %39
6: ; preds = %0
%7 = call i32 @if_all_digits(i8* %2)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %39
9: ; preds = %6
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 9
%11 = call i32 @make_integers(i8* %10, i32 1)
%12 = call i32 @make_integers(i8* %2, i32 2)
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 2
%14 = call i32 @make_integers(i8* %13, i32 2)
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 4
%16 = call i32 @make_integers(i8* %15, i32 2)
%17 = icmp sgt i32 %14, 12
%18 = add nsw i32 %14, -40
%19 = select i1 %17, i32 %18, i32 %14
switch i32 %19, label %39 [
i32 1, label %20
i32 3, label %20
i32 5, label %20
i32 7, label %20
i32 8, label %20
i32 10, label %20
i32 12, label %20
i32 4, label %23
i32 6, label %23
i32 9, label %23
i32 11, label %23
i32 2, label %26
]
20: ; preds = %9, %9, %9, %9, %9, %9, %9
%21 = add i32 %16, -32
%22 = icmp ult i32 %21, -31
br i1 %22, label %39, label %35
23: ; preds = %9, %9, %9, %9
%24 = add i32 %16, -31
%25 = icmp ult i32 %24, -30
br i1 %25, label %39, label %35
26: ; preds = %9
%27 = call i32 @if_lead_year(i32 %12)
%28 = icmp eq i32 %27, 1
br i1 %28, label %29, label %32
29: ; preds = %26
%30 = add i32 %16, -30
%31 = icmp ult i32 %30, -29
br i1 %31, label %39, label %35
32: ; preds = %26
%33 = add i32 %16, -29
%34 = icmp ult i32 %33, -28
br i1 %34, label %39, label %35
35: ; preds = %32, %29, %23, %20
%36 = call i32 @if_last_digit_right(i8* %2)
%37 = icmp eq i32 %11, %36
%38 = select i1 %37, i32 49, i32 48
br label %39
39: ; preds = %35, %0, %6, %9, %32, %29, %23, %20
%40 = phi i32 [ 48, %20 ], [ 48, %23 ], [ 48, %29 ], [ 48, %32 ], [ 48, %9 ], [ 48, %6 ], [ 48, %0 ], [ %38, %35 ]
%41 = call i32 @putchar(i32 %40)
ret i32 0
}