#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main() {
  char a[20] = {0};
  scanf("%s", a);
  if (0 == strncmp(a, "978", 3) || 0 == strncmp(a, "979", 3)) {
    long chek = 0;
    for (int i = 0, k = 0; i < strlen(a) - 2; ++i) {
      if (a[i] <= '9' && '0' <= a[i]) {
        k++;
        if (a[i] != '-')
          chek = chek + (a[i] - '0') * k;
        else
          ;
      }
    }
    printf("%li\n", chek);
    char *b = a + 4;
    if (0 == strncmp(b, "933346", 6)) {
      printf("%s\n", "Bluebridge");
    }
    if (0 == strncmp(b, "55583", 5)) {
      printf("%s\n", "Alyson Books");
    }
    if (0 == strncmp(b, "4210", 4)) {
      printf("%s\n", "FUNimation Productions, Ltd.");
    }
    if (0 == strncmp(b, "1", 1)) {
      printf("%s\n", "Pyramid Books");
    }
    printf("1\n");
  } else {
    printf("0\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1060 <memset@plt>
lea    -0x20(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
lea    0xe79(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11c5 <main+0x75>
lea    -0x20(%rbp),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    138e <main+0x23e>
movq   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x3c(%rbp),%eax
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    127d <main+0x12d>
movslq -0x2c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jg     126a <main+0x11a>
movslq -0x2c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%ecx
mov    $0x30,%eax
cmp    %ecx,%eax
jg     126a <main+0x11a>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
movslq -0x2c(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x2d,%eax
je     1260 <main+0x110>
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
sub    $0x30,%ecx
imul   -0x30(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    1265 <main+0x115>
jmp    1265 <main+0x115>
jmp    126a <main+0x11a>
jmp    126f <main+0x11f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11db <main+0x8b>
mov    -0x28(%rbp),%rsi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xd6a(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12d3 <main+0x183>
lea    0xd52(%rip),%rdi
lea    0xd4f(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd48(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    130b <main+0x1bb>
lea    0xd1a(%rip),%rdi
lea    0xd28(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd23(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1343 <main+0x1f3>
lea    0xce2(%rip),%rdi
lea    0xd02(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
lea    0xd0d(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    137b <main+0x22b>
lea    0xcaa(%rip),%rdi
lea    0xce9(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xce9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    139c <main+0x24c>
lea    0xcd9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe8f(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xe80(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ba <main+0x6a>
lea    0xe6b(%rip),%rsi
mov    %rsp,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11ba <main+0x6a>
lea    0xe83(%rip),%rbx
jmp    12c4 <main+0x174>
mov    %rsp,%rdi
call   1050 <strlen@plt>
xor    %r12d,%r12d
cmp    $0x3,%eax
jl     1214 <main+0xc4>
mov    %rsp,%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11f6 <main+0xa6>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <strlen@plt>
add    $0xfffffffe,%eax
cltq
cmp    %rax,%rbx
jge    1217 <main+0xc7>
movzbl (%rsp,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     11e0 <main+0x90>
add    $0x1,%r12d
add    $0xffffffd0,%eax
imul   %r12d,%eax
cltq
add    %rax,%r15
jmp    11e0 <main+0x90>
xor    %r15d,%r15d
lea    0xded(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x4(%rsp),%r14
lea    0xddc(%rip),%rsi
mov    %r14,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1252 <main+0x102>
lea    0xdca(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc9(%rip),%rsi
mov    %r14,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1277 <main+0x127>
lea    0xdb6(%rip),%rdi
call   1040 <puts@plt>
lea    0xdb7(%rip),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    129c <main+0x14c>
lea    0xda3(%rip),%rdi
call   1040 <puts@plt>
lea    0xdc2(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    12c4 <main+0x174>
lea    0xd98(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"978\00"
@.str.2 = [4 x i8] c"979\00"
@.str.3 = [5 x i8] c"%li\0A\00"
@.str.4 = [7 x i8] c"933346\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [11 x i8] c"Bluebridge\00"
@.str.7 = [6 x i8] c"55583\00"
@.str.8 = [13 x i8] c"Alyson Books\00"
@.str.9 = [5 x i8] c"4210\00"
@.str.10 = [29 x i8] c"FUNimation Productions, Ltd.\00"
@.str.11 = [2 x i8] c"1\00"
@.str.12 = [14 x i8] c"Pyramid Books\00"
@.str.13 = [3 x i8] c"1\0A\00"
@.str.14 = [3 x i8] c"0\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 0, i32* %1
%7 = bitcast [20 x i8]* %2 to i8*
%8 = getelementptr inbounds [20 x i8], [20 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 [20 x i8], [20 x i8]* %2, i64 0, i64 0
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%12 = icmp eq i64 0, %11
br i1 %12, label %17, label %13
13: ; preds = %0
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%15 = call i64 @strncmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%16 = icmp eq i64 0, %15
br i1 %16, label %17, label %95
17: ; preds = %13, %0
store i64 0, i64* %3
store i32 0, i32* %4
store i32 0, i32* %5
br label %18
18: ; preds = %62, %17
%19 = load i32, i32* %4
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 2
%23 = icmp slt i32 %19, %22
br i1 %23, label %24, label %65
24: ; preds = %18
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp sle i32 %29, 57
br i1 %30, label %31, label %61
31: ; preds = %24
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp sle i32 48, %36
br i1 %37, label %38, label %61
38: ; preds = %31
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
%41 = load i32, i32* %4
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 45
br i1 %46, label %47, label %59
47: ; preds = %38
%48 = load i64, i64* %3
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = sext i8 %52 to i32
%54 = sub nsw i32 %53, 48
%55 = load i32, i32* %5
%56 = mul nsw i32 %54, %55
%57 = sext i32 %56 to i64
%58 = add nsw i64 %48, %57
store i64 %58, i64* %3
br label %60
59: ; preds = %38
br label %60
60: ; preds = %59, %47
br label %61
61: ; preds = %60, %31, %24
br label %62
62: ; preds = %61
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %18
65: ; preds = %18
%66 = load i64, i64* %3
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %66)
%68 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%69 = getelementptr inbounds i8, i8* %68, i64 4
store i8* %69, i8** %6
%70 = load i8*, i8** %6
%71 = call i64 @strncmp(i8* %70, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%72 = icmp eq i64 0, %71
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %75
75: ; preds = %73, %65
%76 = load i8*, i8** %6
%77 = call i64 @strncmp(i8* %76, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%78 = icmp eq i64 0, %77
br i1 %78, label %79, label %81
79: ; preds = %75
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %81
81: ; preds = %79, %75
%82 = load i8*, i8** %6
%83 = call i64 @strncmp(i8* %82, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%84 = icmp eq i64 0, %83
br i1 %84, label %85, label %87
85: ; preds = %81
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %87
87: ; preds = %85, %81
%88 = load i8*, i8** %6
%89 = call i64 @strncmp(i8* %88, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0), i32 1)
%90 = icmp eq i64 0, %89
br i1 %90, label %91, label %93
91: ; preds = %87
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
br label %93
93: ; preds = %91, %87
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.13, i64 0, i64 0))
br label %97
95: ; preds = %13
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.14, i64 0, i64 0))
br label %97
97: ; preds = %95, %93
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c"978\00"
@.str.2 = [4 x i8] c"979\00"
@.str.3 = [5 x i8] c"%li\0A\00"
@.str.4 = [7 x i8] c"933346\00"
@.str.6 = [11 x i8] c"Bluebridge\00"
@.str.7 = [6 x i8] c"55583\00"
@.str.8 = [13 x i8] c"Alyson Books\00"
@.str.9 = [5 x i8] c"4210\00"
@.str.10 = [29 x i8] c"FUNimation Productions, Ltd.\00"
@.str.12 = [14 x i8] c"Pyramid Books\00"
@str = [2 x i8] c"0\00"
@str.15 = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 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 i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %58
9: ; preds = %6, %0
%10 = call i32 @strlen(i8* %2)
%11 = icmp sgt i32 %10, 2
br i1 %11, label %18, label %12
12: ; preds = %33, %9
%13 = phi i64 [ 0, %9 ], [ %35, %33 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i64 %13)
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%16 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%17 = icmp eq i64 %16, 0
br i1 %17, label %41, label %43
18: ; preds = %9, %33
%19 = phi i64 [ %36, %33 ], [ 0, %9 ]
%20 = phi i64 [ %35, %33 ], [ 0, %9 ]
%21 = phi i32 [ %34, %33 ], [ 0, %9 ]
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %19
%23 = load i8, i8* %22
%24 = add i8 %23, -48
%25 = icmp ult i8 %24, 10
br i1 %25, label %26, label %33
26: ; preds = %18
%27 = zext i8 %23 to i32
%28 = add nsw i32 %21, 1
%29 = add nsw i32 %27, -48
%30 = mul nsw i32 %29, %28
%31 = sext i32 %30 to i64
%32 = add nsw i64 %20, %31
br label %33
33: ; preds = %18, %26
%34 = phi i32 [ %28, %26 ], [ %21, %18 ]
%35 = phi i64 [ %32, %26 ], [ %20, %18 ]
%36 = add nuw nsw i64 %19, 1
%37 = call i32 @strlen(i8* %2)
%38 = add nsw i32 %37, -2
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %36, %39
br i1 %40, label %18, label %12
41: ; preds = %12
%42 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
br label %43
43: ; preds = %41, %12
%44 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 5)
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %43
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
br label %48
48: ; preds = %46, %43
%49 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 4)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %53
51: ; preds = %48
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %53
53: ; preds = %51, %48
%54 = call i64 @strncmp(i8* %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0), i32 1)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %53
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0))
br label %58
58: ; preds = %6, %53, %56
%59 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0), %56 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.15, i64 0, i64 0), %53 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0), %6 ]
%60 = call i32 @puts(i8* dereferenceable(1) %59)
ret i32 0
}