#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 check_month(int, int, int);
int last_number(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char egn[12];
  int month = 0, year = 0, day = 0, result = 0;
  int p = 0;
  scanf("%s", egn);
  year = (egn[0] - 48) * 10 + (egn[1] - 48);
  month = (egn[2] - 48) * 10 + (egn[3] - 48);
  day = (egn[4] - 48) * 10 + (egn[5] - 48);
  result = check_month(month, day, year);
  if (result == 1) {
    p = last_number(egn);
  } else {
    printf("0");
    return 0;
  }
  if (p == (egn[9] - 48)) {
    printf("1");
  } else {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x10(%rbp),%rsi
lea    0xe83(%rip),%rdi
call   1050 <scanf@plt>
movsbl -0x10(%rbp),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
movsbl -0xf(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
movsbl -0xe(%rbp),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
movsbl -0xd(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
movsbl -0xc(%rbp),%eax
sub    $0x30,%eax
imul   $0xa,%eax,%eax
movsbl -0xb(%rbp),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1030 <check_month@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    11f0 <main+0xb0>
lea    -0x10(%rbp),%rdi
call   1060 <last_number@plt>
mov    %eax,-0x24(%rbp)
jmp    1208 <main+0xc8>
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <main+0xfe>
mov    -0x24(%rbp),%eax
movsbl -0x7(%rbp),%ecx
sub    $0x30,%ecx
cmp    %ecx,%eax
jne    122b <main+0xeb>
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
jmp    1237 <main+0xf7>
lea    0xdd1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xeb5(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
movsbl 0xc(%rsp),%eax
lea    (%rax,%rax,4),%eax
movsbl 0xd(%rsp),%ecx
lea    (%rcx,%rax,2),%edx
add    $0xfffffdf0,%edx
movsbl 0xe(%rsp),%eax
lea    (%rax,%rax,4),%eax
movsbl 0xf(%rsp),%ecx
lea    -0x210(%rcx,%rax,2),%edi
movsbl 0x10(%rsp),%eax
lea    (%rax,%rax,4),%eax
movsbl 0x11(%rsp),%ecx
lea    (%rcx,%rax,2),%esi
add    $0xfffffdf0,%esi
call   1040 <check_month@plt>
mov    $0x30,%edi
cmp    $0x1,%eax
jne    11c1 <main+0x81>
lea    0xc(%rsp),%rdi
call   1060 <last_number@plt>
movsbl 0x15(%rsp),%ecx
add    $0xffffffd0,%ecx
xor    %edi,%edi
cmp    %ecx,%eax
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

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
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%8 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = sub nsw i32 %12, 48
%14 = mul nsw i32 %13, 10
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 1
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = sub nsw i32 %17, 48
%19 = add nsw i32 %14, %18
store i32 %19, i32* %4
%20 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 2
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = sub nsw i32 %22, 48
%24 = mul nsw i32 %23, 10
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = sub nsw i32 %27, 48
%29 = add nsw i32 %24, %28
store i32 %29, i32* %3
%30 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 4
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = sub nsw i32 %32, 48
%34 = mul nsw i32 %33, 10
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = sub nsw i32 %37, 48
%39 = add nsw i32 %34, %38
store i32 %39, i32* %5
%40 = load i32, i32* %3
%41 = load i32, i32* %5
%42 = load i32, i32* %4
%43 = call i32 @check_month(i32 %40, i32 %41, i32 %42)
store i32 %43, i32* %6
%44 = load i32, i32* %6
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %0
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%48 = call i32 @last_number(i8* %47)
store i32 %48, i32* %7
br label %51
49: ; preds = %0
%50 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %1
br label %63
51: ; preds = %46
%52 = load i32, i32* %7
%53 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 9
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = sub nsw i32 %55, 48
%57 = icmp eq i32 %52, %56
br i1 %57, label %58, label %60
58: ; preds = %51
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %62
60: ; preds = %51
%61 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %62
62: ; preds = %60, %58
store i32 0, i32* %1
br label %63
63: ; preds = %62, %49
%64 = load i32, i32* %1
ret i32 %64
}

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 = load i8, i8* %2
%5 = sext i8 %4 to i32
%6 = mul nsw i32 %5, 10
%7 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = add nsw i32 %9, -528
%11 = add nsw i32 %10, %6
%12 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 2
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = mul nsw i32 %14, 10
%16 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 3
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = add nsw i32 %18, -528
%20 = add nsw i32 %19, %15
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = mul nsw i32 %23, 10
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, -528
%29 = add nsw i32 %28, %24
%30 = call i32 @check_month(i32 %20, i32 %29, i32 %11)
%31 = icmp eq i32 %30, 1
br i1 %31, label %32, label %40
32: ; preds = %0
%33 = call i32 @last_number(i8* %2)
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 9
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = add nsw i32 %36, -48
%38 = icmp eq i32 %33, %37
%39 = select i1 %38, i32 49, i32 48
br label %40
40: ; preds = %0, %32
%41 = phi i32 [ %39, %32 ], [ 48, %0 ]
%42 = call i32 @putchar(i32 %41)
ret i32 0
}