#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 convert_digit_to_int(char);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ is_valid_isbn13(int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *, int *, int *, int *, int *);
int /*<<< orphan*/ stdin;
int main(int argc, const char *argv[]) {
  char line[21];
  fgets(line, 21, stdin);
  int ean_id;
  int group_id;
  int publisher_id;
  int title_id;
  int checksum_number;
  int digits[13], index = 0;
  for (int i = 0; i <= 20; ++i) {
    if (line[i] >= '0' && line[i] <= '9') {
      digits[index++] = convert_digit_to_int(line[i]);
    }
  }
  if (index != 13) {
    printf("0\n");
    return 0;
  }
  sscanf(line, "%d-%d-%d-%d-%d", &ean_id, &group_id, &publisher_id, &title_id,
         &checksum_number);
  if (ean_id != 978 && ean_id != 979) {
    printf("0\n");
    return 0;
  }
  if (is_valid_isbn13(digits)) {
    printf("1\n");
  } else {
    printf("0\n");
    return 0;
  }
  switch (publisher_id) {
  case 933346:
    printf("Bluebridge\n");
    break;
  case 55583:
    printf("Alyson Books\n");
    break;
  case 4210:
    printf("FUNimation Productions, Ltd.\n");
    break;
  case 1:
    printf("Pyramid Books\n");
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
mov    $0x15,%esi
call   1040 <fgets@plt>
movl   $0x0,-0x84(%rbp)
movl   $0x0,-0x88(%rbp)
cmpl   $0x14,-0x88(%rbp)
jg     120e <main+0xbe>
movslq -0x88(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jl     11f5 <main+0xa5>
movslq -0x88(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x39,%eax
jg     11f5 <main+0xa5>
movslq -0x88(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1050 <convert_digit_to_int@plt>
mov    %eax,%ecx
mov    -0x84(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x84(%rbp)
cltq
mov    %ecx,-0x80(%rbp,%rax,4)
jmp    11fa <main+0xaa>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1194 <main+0x44>
cmpl   $0xd,-0x84(%rbp)
je     1233 <main+0xe3>
lea    0xdde(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1368 <main+0x218>
lea    -0x30(%rbp),%rdi
lea    0xdc5(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x44(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <sscanf@plt>
cmpl   $0x3d2,-0x34(%rbp)
je     128d <main+0x13d>
cmpl   $0x3d3,-0x34(%rbp)
je     128d <main+0x13d>
lea    0xd84(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1368 <main+0x218>
lea    -0x80(%rbp),%rdi
call   1070 <is_valid_isbn13@plt>
cmp    $0x0,%rax
je     12b1 <main+0x161>
lea    0xd6b(%rip),%rdi
call   1030 <printf@plt>
jmp    12c9 <main+0x179>
lea    0xd48(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1368 <main+0x218>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x8c(%rbp)
sub    $0x1,%eax
je     1355 <main+0x205>
jmp    12e0 <main+0x190>
mov    -0x8c(%rbp),%eax
sub    $0x1072,%eax
je     1344 <main+0x1f4>
jmp    12f6 <main+0x1a6>
mov    -0x8c(%rbp),%eax
sub    $0xd91f,%eax
je     1333 <main+0x1e3>
jmp    130c <main+0x1bc>
mov    -0x8c(%rbp),%eax
sub    $0xe3de2,%eax
jne    1361 <main+0x211>
jmp    1322 <main+0x1d2>
lea    0xcec(%rip),%rdi
call   1030 <printf@plt>
jmp    1361 <main+0x211>
lea    0xce7(%rip),%rdi
call   1030 <printf@plt>
jmp    1361 <main+0x211>
lea    0xce4(%rip),%rdi
call   1030 <printf@plt>
jmp    1361 <main+0x211>
lea    0xcf1(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
lea    0x20(%rsp),%rdi
mov    $0x15,%esi
call   1040 <fgets@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    118a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    $0x15,%rbx
je     11ab <main+0x5b>
movzbl 0x20(%rsp,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1180 <main+0x30>
movsbl %al,%edi
call   1050 <convert_digit_to_int@plt>
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %eax,0x40(%rsp,%rcx,4)
jmp    1180 <main+0x30>
lea    0xea2(%rip),%rbx
cmp    $0xd,%ebp
jne    1259 <main+0x109>
lea    0x14(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe35(%rip),%rsi
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rdx
lea    0x1c(%rsp),%rcx
lea    0xc(%rsp),%r8
lea    0x18(%rsp),%r9
call   1060 <sscanf@plt>
mov    0x10(%rsp),%eax
and    $0xfffffffe,%eax
cmp    $0x3d2,%eax
jne    1259 <main+0x109>
lea    0x40(%rsp),%rdi
call   1070 <is_valid_isbn13@plt>
test   %rax,%rax
je     1259 <main+0x109>
lea    0xe02(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%eax
cmp    $0xd91e,%eax
jg     1232 <main+0xe2>
cmp    $0x1,%eax
je     1249 <main+0xf9>
cmp    $0x1072,%eax
jne    1261 <main+0x111>
lea    0xdef(%rip),%rbx
jmp    1259 <main+0x109>
cmp    $0xe3de2,%eax
je     1252 <main+0x102>
cmp    $0xd91f,%eax
jne    1261 <main+0x111>
lea    0xdf5(%rip),%rbx
jmp    1259 <main+0x109>
lea    0xdc1(%rip),%rbx
jmp    1259 <main+0x109>
lea    0xdf0(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"0\0A\00"
@.str.1 = [15 x i8] c"%d-%d-%d-%d-%d\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [12 x i8] c"Bluebridge\0A\00"
@.str.4 = [14 x i8] c"Alyson Books\0A\00"
@.str.5 = [30 x i8] c"FUNimation Productions, Ltd.\0A\00"
@.str.6 = [15 x i8] c"Pyramid Books\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [21 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [13 x i32]
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%16 = load i32, i32* @stdin
%17 = call i32 @fgets(i8* %15, i32 21, i32 %16)
store i32 0, i32* %13
store i32 0, i32* %14
br label %18
18: ; preds = %46, %2
%19 = load i32, i32* %14
%20 = icmp sle i32 %19, 20
br i1 %20, label %21, label %49
21: ; preds = %18
%22 = load i32, i32* %14
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp sge i32 %26, 48
br i1 %27, label %28, label %45
28: ; preds = %21
%29 = load i32, i32* %14
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sle i32 %33, 57
br i1 %34, label %35, label %45
35: ; preds = %28
%36 = load i32, i32* %14
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = call i32 @convert_digit_to_int(i8 signext %39)
%41 = load i32, i32* %13
%42 = add nsw i32 %41, 1
store i32 %42, i32* %13
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [13 x i32], [13 x i32]* %12, i64 0, i64 %43
store i32 %40, i32* %44
br label %45
45: ; preds = %35, %28, %21
br label %46
46: ; preds = %45
%47 = load i32, i32* %14
%48 = add nsw i32 %47, 1
store i32 %48, i32* %14
br label %18
49: ; preds = %18
%50 = load i32, i32* %13
%51 = icmp ne i32 %50, 13
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %83
54: ; preds = %49
%55 = getelementptr inbounds [21 x i8], [21 x i8]* %6, i64 0, i64 0
%56 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %8, i32* %9, i32* %10, i32* %11)
%57 = load i32, i32* %7
%58 = icmp ne i32 %57, 978
br i1 %58, label %59, label %64
59: ; preds = %54
%60 = load i32, i32* %7
%61 = icmp ne i32 %60, 979
br i1 %61, label %62, label %64
62: ; preds = %59
%63 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %83
64: ; preds = %59, %54
%65 = getelementptr inbounds [13 x i32], [13 x i32]* %12, i64 0, i64 0
%66 = call i64 @is_valid_isbn13(i32* %65)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %64
%69 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %72
70: ; preds = %64
%71 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %83
72: ; preds = %68
%73 = load i32, i32* %9
switch i32 %73, label %82 [
i32 933346, label %74
i32 55583, label %76
i32 4210, label %78
i32 1, label %80
]
74: ; preds = %72
%75 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
br label %82
76: ; preds = %72
%77 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
br label %82
78: ; preds = %72
%79 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
br label %82
80: ; preds = %72
%81 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
br label %82
82: ; preds = %72, %80, %78, %76, %74
store i32 0, i32* %3
br label %83
83: ; preds = %82, %70, %62, %52
%84 = load i32, i32* %3
ret i32 %84
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [15 x i8] c"%d-%d-%d-%d-%d\00"
@str.7 = [2 x i8] c"1\00"
@str.8 = [14 x i8] c"Pyramid Books\00"
@str.9 = [29 x i8] c"FUNimation Productions, Ltd.\00"
@str.10 = [13 x i8] c"Alyson Books\00"
@str.11 = [11 x i8] c"Bluebridge\00"
@str.13 = [2 x i8] c"0\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [21 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [13 x i32]
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %10, i32 21, i32 %11)
%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 = bitcast i32* %8 to i8*
%18 = bitcast [13 x i32]* %9 to i8*
br label %21
19: ; preds = %33
%20 = icmp eq i32 %34, 13
br i1 %20, label %37, label %52
21: ; preds = %2, %33
%22 = phi i64 [ 0, %2 ], [ %35, %33 ]
%23 = phi i32 [ 0, %2 ], [ %34, %33 ]
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %3, i64 0, i64 %22
%25 = load i8, i8* %24
%26 = add i8 %25, -48
%27 = icmp ult i8 %26, 10
br i1 %27, label %28, label %33
28: ; preds = %21
%29 = call i32 @convert_digit_to_int(i8 signext %25)
%30 = add nsw i32 %23, 1
%31 = sext i32 %23 to i64
%32 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 %31
store i32 %29, i32* %32
br label %33
33: ; preds = %21, %28
%34 = phi i32 [ %30, %28 ], [ %23, %21 ]
%35 = add nuw nsw i64 %22, 1
%36 = icmp eq i64 %35, 21
br i1 %36, label %19, label %21
37: ; preds = %19
%38 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%39 = load i32, i32* %4
%40 = and i32 %39, -2
%41 = icmp eq i32 %40, 978
br i1 %41, label %42, label %52
42: ; preds = %37
%43 = getelementptr inbounds [13 x i32], [13 x i32]* %9, i64 0, i64 0
%44 = call i64 @is_valid_isbn13(i32* %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %42
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.7, i64 0, i64 0))
%48 = load i32, i32* %6
switch i32 %48, label %55 [
i32 933346, label %52
i32 55583, label %49
i32 4210, label %50
i32 1, label %51
]
49: ; preds = %46
br label %52
50: ; preds = %46
br label %52
51: ; preds = %46
br label %52
52: ; preds = %46, %42, %37, %19, %51, %50, %49
%53 = phi i8* [ getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0), %49 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0), %50 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0), %51 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0), %19 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0), %37 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @str.13, i64 0, i64 0), %42 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @str.11, i64 0, i64 0), %46 ]
%54 = call i32 @puts(i8* dereferenceable(1) %53)
br label %55
55: ; preds = %52, %46
ret i32 0
}