#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 atoi(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
char *strndup(char *, int);
int main() {
  int month_valid;
  int remainder_from_check;
  int check;
  int month_number;
  int value_pos1;
  int value_pos2;
  int value_pos3;
  int value_pos4;
  int value_pos5;
  int value_pos6;
  int value_pos7;
  int value_pos8;
  int value_pos9;
  int value_pos10;
  char upn[12];
  scanf("%s", upn);
  char *month;
  char *pos1;
  char *pos2;
  char *pos3;
  char *pos4;
  char *pos5;
  char *pos6;
  char *pos7;
  char *pos8;
  char *pos9;
  char *pos10;
  month = strndup(upn + 2, 2);
  pos1 = strndup(upn, 1);
  pos2 = strndup(upn + 1, 1);
  pos3 = strndup(upn + 2, 1);
  pos4 = strndup(upn + 3, 1);
  pos5 = strndup(upn + 4, 1);
  pos6 = strndup(upn + 5, 1);
  pos7 = strndup(upn + 6, 1);
  pos8 = strndup(upn + 7, 1);
  pos9 = strndup(upn + 8, 1);
  pos10 = strndup(upn + 9, 1);
  month_number = atoi(month);
  value_pos1 = atoi(pos1);
  value_pos2 = atoi(pos2);
  value_pos3 = atoi(pos3);
  value_pos4 = atoi(pos4);
  value_pos5 = atoi(pos5);
  value_pos6 = atoi(pos6);
  value_pos7 = atoi(pos7);
  value_pos8 = atoi(pos8);
  value_pos9 = atoi(pos9);
  value_pos10 = atoi(pos10);
  if ((month_number >= 1 && month_number <= 12) ||
      (month_number >= 21 && month_number <= 32) ||
      (month_number >= 41 && month_number <= 52)) {
    month_valid = 1;
  }
  check = (value_pos1 * 2) + (value_pos2 * 4) + (value_pos3 * 8) +
          (value_pos4 * 5) + (value_pos5 * 10) + (value_pos6 * 9) +
          (value_pos7 * 7) + (value_pos8 * 3) + (value_pos9 * 6);
  remainder_from_check = check % 11;
  if (remainder_from_check == 10) {
    remainder_from_check = 0;
  }
  if ((remainder_from_check == value_pos10) && (month_valid == 1)) {
    printf("1");
  } else {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x48(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x48(%rbp),%rdi
add    $0x2,%rdi
mov    $0x2,%esi
call   1040 <strndup@plt>
mov    %rax,-0x50(%rbp)
lea    -0x48(%rbp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x58(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x60(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x2,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x68(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x3,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x70(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x4,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x78(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x5,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x80(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x6,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x88(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x7,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x90(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x8,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0x98(%rbp)
lea    -0x48(%rbp),%rdi
add    $0x9,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,-0xa0(%rbp)
mov    -0x50(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x58(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x60(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x68(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x20(%rbp)
mov    -0x70(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x78(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x28(%rbp)
mov    -0x80(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x88(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x30(%rbp)
mov    -0x90(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x98(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0xa0(%rbp),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x1,-0x14(%rbp)
jl     1300 <main+0x1c0>
cmpl   $0xc,-0x14(%rbp)
jle    1328 <main+0x1e8>
cmpl   $0x15,-0x14(%rbp)
jl     1314 <main+0x1d4>
cmpl   $0x20,-0x14(%rbp)
jle    1328 <main+0x1e8>
cmpl   $0x29,-0x14(%rbp)
jl     132f <main+0x1ef>
cmpl   $0x34,-0x14(%rbp)
jg     132f <main+0x1ef>
movl   $0x1,-0x8(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    -0x20(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
imul   $0x5,-0x24(%rbp),%ecx
add    %ecx,%eax
imul   $0xa,-0x28(%rbp),%ecx
add    %ecx,%eax
imul   $0x9,-0x2c(%rbp),%ecx
add    %ecx,%eax
imul   $0x7,-0x30(%rbp),%ecx
add    %ecx,%eax
imul   $0x3,-0x34(%rbp),%ecx
add    %ecx,%eax
imul   $0x6,-0x38(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xb,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jne    138b <main+0x24b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    13b2 <main+0x272>
cmpl   $0x1,-0x8(%rbp)
jne    13b2 <main+0x272>
lea    0xc5b(%rip),%rdi
call   1030 <printf@plt>
jmp    13be <main+0x27e>
lea    0xc4c(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
lea    0xeab(%rip),%rdi
lea    0xc(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xe(%rsp),%rbp
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,%r14
lea    0xd(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,%r13
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,%rbx
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,%rbp
lea    0x11(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,0x50(%rsp)
lea    0x12(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,0x48(%rsp)
lea    0x13(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,0x40(%rsp)
lea    0x14(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,0x38(%rsp)
lea    0x15(%rsp),%rdi
mov    $0x1,%esi
call   1040 <strndup@plt>
mov    %rax,0x30(%rsp)
mov    %r14,%rdi
call   1060 <atoi@plt>
mov    %eax,%r12d
mov    %r15,%rdi
call   1060 <atoi@plt>
mov    %rax,0x28(%rsp)
mov    %r13,%rdi
call   1060 <atoi@plt>
mov    %rax,0x20(%rsp)
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %rax,0x18(%rsp)
mov    %rbp,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebx
mov    0x50(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    0x48(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r13d
mov    0x40(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
mov    0x38(%rsp),%rdi
call   1060 <atoi@plt>
mov    %eax,%r15d
mov    0x30(%rsp),%rdi
call   1060 <atoi@plt>
add    %r12d,%r12d
mov    0x28(%rsp),%rcx
lea    (%r12,%rcx,4),%ecx
mov    0x20(%rsp),%rdx
lea    (%rcx,%rdx,8),%ecx
mov    0x18(%rsp),%rdx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
lea    (%rbx,%rbx,4),%ecx
lea    (%rdx,%rcx,2),%ecx
lea    0x0(%rbp,%rbp,8),%edx
add    %ecx,%edx
lea    0x0(,%r13,8),%ecx
sub    %r13d,%ecx
add    %edx,%ecx
lea    (%r14,%r14,2),%edx
add    %ecx,%edx
lea    (%r15,%r15,2),%ecx
lea    (%rdx,%rcx,2),%ecx
movslq %ecx,%rcx
imul   $0x2e8ba2e9,%rcx,%rdx
mov    %rdx,%rsi
shr    $0x3f,%rsi
sar    $0x21,%rdx
add    %esi,%edx
lea    (%rdx,%rdx,4),%esi
lea    (%rdx,%rsi,2),%edx
sub    %edx,%ecx
xor    %edx,%edx
cmp    $0xa,%ecx
cmove  %edx,%ecx
xor    %edi,%edi
cmp    %eax,%ecx
sete   %dil
or     $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [2 x i8] c"0\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
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca [12 x i8]
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca i8*
%24 = alloca i8*
%25 = alloca i8*
%26 = alloca i8*
%27 = alloca i8*
store i32 0, i32* %1
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%31 = getelementptr inbounds i8, i8* %30, i64 2
%32 = call i8* @strndup(i8* %31, i32 2)
store i8* %32, i8** %17
%33 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%34 = call i8* @strndup(i8* %33, i32 1)
store i8* %34, i8** %18
%35 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = call i8* @strndup(i8* %36, i32 1)
store i8* %37, i8** %19
%38 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%39 = getelementptr inbounds i8, i8* %38, i64 2
%40 = call i8* @strndup(i8* %39, i32 1)
store i8* %40, i8** %20
%41 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%42 = getelementptr inbounds i8, i8* %41, i64 3
%43 = call i8* @strndup(i8* %42, i32 1)
store i8* %43, i8** %21
%44 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%45 = getelementptr inbounds i8, i8* %44, i64 4
%46 = call i8* @strndup(i8* %45, i32 1)
store i8* %46, i8** %22
%47 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%48 = getelementptr inbounds i8, i8* %47, i64 5
%49 = call i8* @strndup(i8* %48, i32 1)
store i8* %49, i8** %23
%50 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%51 = getelementptr inbounds i8, i8* %50, i64 6
%52 = call i8* @strndup(i8* %51, i32 1)
store i8* %52, i8** %24
%53 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%54 = getelementptr inbounds i8, i8* %53, i64 7
%55 = call i8* @strndup(i8* %54, i32 1)
store i8* %55, i8** %25
%56 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%57 = getelementptr inbounds i8, i8* %56, i64 8
%58 = call i8* @strndup(i8* %57, i32 1)
store i8* %58, i8** %26
%59 = getelementptr inbounds [12 x i8], [12 x i8]* %16, i64 0, i64 0
%60 = getelementptr inbounds i8, i8* %59, i64 9
%61 = call i8* @strndup(i8* %60, i32 1)
store i8* %61, i8** %27
%62 = load i8*, i8** %17
%63 = call i32 @atoi(i8* %62)
store i32 %63, i32* %5
%64 = load i8*, i8** %18
%65 = call i32 @atoi(i8* %64)
store i32 %65, i32* %6
%66 = load i8*, i8** %19
%67 = call i32 @atoi(i8* %66)
store i32 %67, i32* %7
%68 = load i8*, i8** %20
%69 = call i32 @atoi(i8* %68)
store i32 %69, i32* %8
%70 = load i8*, i8** %21
%71 = call i32 @atoi(i8* %70)
store i32 %71, i32* %9
%72 = load i8*, i8** %22
%73 = call i32 @atoi(i8* %72)
store i32 %73, i32* %10
%74 = load i8*, i8** %23
%75 = call i32 @atoi(i8* %74)
store i32 %75, i32* %11
%76 = load i8*, i8** %24
%77 = call i32 @atoi(i8* %76)
store i32 %77, i32* %12
%78 = load i8*, i8** %25
%79 = call i32 @atoi(i8* %78)
store i32 %79, i32* %13
%80 = load i8*, i8** %26
%81 = call i32 @atoi(i8* %80)
store i32 %81, i32* %14
%82 = load i8*, i8** %27
%83 = call i32 @atoi(i8* %82)
store i32 %83, i32* %15
%84 = load i32, i32* %5
%85 = icmp sge i32 %84, 1
br i1 %85, label %86, label %89
86: ; preds = %0
%87 = load i32, i32* %5
%88 = icmp sle i32 %87, 12
br i1 %88, label %101, label %89
89: ; preds = %86, %0
%90 = load i32, i32* %5
%91 = icmp sge i32 %90, 21
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = load i32, i32* %5
%94 = icmp sle i32 %93, 32
br i1 %94, label %101, label %95
95: ; preds = %92, %89
%96 = load i32, i32* %5
%97 = icmp sge i32 %96, 41
br i1 %97, label %98, label %102
98: ; preds = %95
%99 = load i32, i32* %5
%100 = icmp sle i32 %99, 52
br i1 %100, label %101, label %102
101: ; preds = %98, %92, %86
store i32 1, i32* %2
br label %102
102: ; preds = %101, %98, %95
%103 = load i32, i32* %6
%104 = mul nsw i32 %103, 2
%105 = load i32, i32* %7
%106 = mul nsw i32 %105, 4
%107 = add nsw i32 %104, %106
%108 = load i32, i32* %8
%109 = mul nsw i32 %108, 8
%110 = add nsw i32 %107, %109
%111 = load i32, i32* %9
%112 = mul nsw i32 %111, 5
%113 = add nsw i32 %110, %112
%114 = load i32, i32* %10
%115 = mul nsw i32 %114, 10
%116 = add nsw i32 %113, %115
%117 = load i32, i32* %11
%118 = mul nsw i32 %117, 9
%119 = add nsw i32 %116, %118
%120 = load i32, i32* %12
%121 = mul nsw i32 %120, 7
%122 = add nsw i32 %119, %121
%123 = load i32, i32* %13
%124 = mul nsw i32 %123, 3
%125 = add nsw i32 %122, %124
%126 = load i32, i32* %14
%127 = mul nsw i32 %126, 6
%128 = add nsw i32 %125, %127
store i32 %128, i32* %4
%129 = load i32, i32* %4
%130 = srem i32 %129, 11
store i32 %130, i32* %3
%131 = load i32, i32* %3
%132 = icmp eq i32 %131, 10
br i1 %132, label %133, label %134
133: ; preds = %102
store i32 0, i32* %3
br label %134
134: ; preds = %133, %102
%135 = load i32, i32* %3
%136 = load i32, i32* %15
%137 = icmp eq i32 %135, %136
br i1 %137, label %138, label %143
138: ; preds = %134
%139 = load i32, i32* %2
%140 = icmp eq i32 %139, 1
br i1 %140, label %141, label %143
141: ; preds = %138
%142 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %145
143: ; preds = %138, %134
%144 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %145
145: ; preds = %143, %141
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 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 2
%5 = call i8* @strndup(i8* %2, i32 1)
%6 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 1
%7 = call i8* @strndup(i8* %6, i32 1)
%8 = call i8* @strndup(i8* %4, i32 1)
%9 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 3
%10 = call i8* @strndup(i8* %9, i32 1)
%11 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 4
%12 = call i8* @strndup(i8* %11, i32 1)
%13 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 5
%14 = call i8* @strndup(i8* %13, i32 1)
%15 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 6
%16 = call i8* @strndup(i8* %15, i32 1)
%17 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 7
%18 = call i8* @strndup(i8* %17, i32 1)
%19 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 8
%20 = call i8* @strndup(i8* %19, i32 1)
%21 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 9
%22 = call i8* @strndup(i8* %21, i32 1)
%23 = call i32 @atoi(i8* %5)
%24 = call i32 @atoi(i8* %7)
%25 = call i32 @atoi(i8* %8)
%26 = call i32 @atoi(i8* %10)
%27 = call i32 @atoi(i8* %12)
%28 = call i32 @atoi(i8* %14)
%29 = call i32 @atoi(i8* %16)
%30 = call i32 @atoi(i8* %18)
%31 = call i32 @atoi(i8* %20)
%32 = call i32 @atoi(i8* %22)
%33 = shl nsw i32 %23, 1
%34 = shl nsw i32 %24, 2
%35 = add nsw i32 %34, %33
%36 = shl nsw i32 %25, 3
%37 = add nsw i32 %35, %36
%38 = mul nsw i32 %26, 5
%39 = add nsw i32 %37, %38
%40 = mul nsw i32 %27, 10
%41 = add nsw i32 %39, %40
%42 = mul nsw i32 %28, 9
%43 = add nsw i32 %41, %42
%44 = mul nsw i32 %29, 7
%45 = add nsw i32 %43, %44
%46 = mul nsw i32 %30, 3
%47 = add nsw i32 %45, %46
%48 = mul nsw i32 %31, 6
%49 = add nsw i32 %47, %48
%50 = srem i32 %49, 11
%51 = icmp eq i32 %50, 10
%52 = select i1 %51, i32 0, i32 %50
%53 = icmp eq i32 %52, %32
%54 = select i1 %53, i32 49, i32 48
%55 = call i32 @putchar(i32 %54)
ret i32 0
}