#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 */
char checkISBN(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
int main() {
  char code[20];
  char *code_elems[5];
  int i, l;
  char *element;
  scanf("%s", code);
  l = strlen(code);
  if (l != 17) {
    printf("0");
    return 0;
  }
  element = strtok(code, "-");
  for (i = 0; element != NULL; i++) {
    code_elems[i] = element;
    element = strtok(NULL, "-");
  }
  if ((strcmp(code_elems[0], "978") != 0) &&
      (strcmp(code_elems[0], "979") != 0)) {
    printf("0");
    return 0;
  }
  if (checkISBN(code) == *code_elems[4] - '0') {
    printf("1");
    if (strcmp(code_elems[2], "933346") == 0) {
      printf("\nBluebridge");
    } else if (strcmp(code_elems[2], "55583") == 0) {
      printf("\nAlyson Books");
    } else if (strcmp(code_elems[2], "4210") == 0) {
      printf("\nFUNimation Productions, Ltd.");
    } else if (strcmp(code_elems[2], "01") == 0) {
      printf("\nPyramid Books");
    }
  } else {
    printf("0");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x58(%rbp)
cmpl   $0x11,-0x58(%rbp)
je     11ad <main+0x4d>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1346 <main+0x1e6>
lea    -0x20(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x60(%rbp)
movl   $0x0,-0x54(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     1202 <main+0xa2>
mov    -0x60(%rbp),%rcx
movslq -0x54(%rbp),%rax
mov    %rcx,-0x50(%rbp,%rax,8)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe18(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x60(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    11c8 <main+0x68>
mov    -0x50(%rbp),%rdi
lea    0xdf8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     124e <main+0xee>
mov    -0x50(%rbp),%rdi
lea    0xde2(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     124e <main+0xee>
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1346 <main+0x1e6>
lea    -0x20(%rbp),%rdi
call   1050 <checkISBN@plt>
movsbl %al,%eax
mov    -0x30(%rbp),%rcx
movsbl (%rcx),%ecx
sub    $0x30,%ecx
cmp    %ecx,%eax
jne    1333 <main+0x1d3>
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
lea    0xd8a(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12a3 <main+0x143>
lea    0xd7b(%rip),%rdi
call   1040 <printf@plt>
jmp    132e <main+0x1ce>
mov    -0x40(%rbp),%rdi
lea    0xd72(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12ce <main+0x16e>
lea    0xd62(%rip),%rdi
call   1040 <printf@plt>
jmp    1329 <main+0x1c9>
mov    -0x40(%rbp),%rdi
lea    0xd5b(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    12f9 <main+0x199>
lea    0xd4a(%rip),%rdi
call   1040 <printf@plt>
jmp    1324 <main+0x1c4>
mov    -0x40(%rbp),%rdi
lea    0xd53(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    131f <main+0x1bf>
lea    0xd40(%rip),%rdi
call   1040 <printf@plt>
jmp    1324 <main+0x1c4>
jmp    1329 <main+0x1c9>
jmp    132e <main+0x1ce>
jmp    133f <main+0x1df>
lea    0xcfd(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xe82(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1080 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    $0x11,%eax
jne    128e <main+0x11e>
lea    0xe62(%rip),%r14
mov    %rsp,%rdi
mov    %r14,%rsi
call   1090 <strtok@plt>
lea    0x20(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,(%rbx)
xor    %edi,%edi
mov    %r14,%rsi
call   1090 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11c0 <main+0x50>
mov    0x20(%rsp),%rbx
lea    0xe23(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     1207 <main+0x97>
lea    0xe13(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    128e <main+0x11e>
mov    %rsp,%rdi
call   1060 <checkISBN@plt>
movsbl %al,%eax
mov    0x40(%rsp),%rcx
movsbl (%rcx),%ecx
add    $0xffffffd0,%ecx
cmp    %eax,%ecx
jne    128e <main+0x11e>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    0x30(%rsp),%rbx
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12a2 <main+0x132>
lea    0xdd5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12b0 <main+0x140>
lea    0xdd5(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
je     12be <main+0x14e>
lea    0xde4(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %rax,%rax
jne    1298 <main+0x128>
lea    0xdd3(%rip),%rdi
call   1050 <printf@plt>
jmp    1298 <main+0x128>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret
lea    0xd6b(%rip),%rdi
call   1050 <printf@plt>
jmp    1298 <main+0x128>
lea    0xd6f(%rip),%rdi
call   1050 <printf@plt>
jmp    1298 <main+0x128>
lea    0xd74(%rip),%rdi
call   1050 <printf@plt>
jmp    1298 <main+0x128>

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"-\00"
@.str.3 = [4 x i8] c"978\00"
@.str.4 = [4 x i8] c"979\00"
@.str.6 = [7 x i8] c"933346\00"
@.str.7 = [12 x i8] c"\0ABluebridge\00"
@.str.8 = [6 x i8] c"55583\00"
@.str.9 = [14 x i8] c"\0AAlyson Books\00"
@.str.10 = [5 x i8] c"4210\00"
@.str.11 = [30 x i8] c"\0AFUNimation Productions, Ltd.\00"
@.str.12 = [3 x i8] c"01\00"
@.str.13 = [15 x i8] c"\0APyramid Books\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [5 x i8*]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = bitcast [5 x i8*]* %2 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%6 = call i32 @strlen(i8* %3)
%7 = icmp eq i32 %6, 17
br i1 %7, label %10, label %8
8: ; preds = %0
%9 = call i32 @putchar(i32 48)
br label %64
10: ; preds = %0
%11 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp ne i8* %11, null
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ %18, %13 ], [ 0, %10 ]
%15 = phi i8* [ %17, %13 ], [ %11, %10 ]
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 %14
store i8* %15, i8** %16
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = add nuw i64 %14, 1
%19 = icmp eq i8* %17, null
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 0
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %20
%26 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = call i32 @putchar(i32 48)
br label %64
30: ; preds = %25, %20
%31 = call signext i8 @checkISBN(i8* %3)
%32 = sext i8 %31 to i32
%33 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 4
%34 = load i8*, i8** %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = add nsw i32 %36, -48
%38 = icmp eq i32 %37, %32
br i1 %38, label %39, label %62
39: ; preds = %30
%40 = call i32 @putchar(i32 49)
%41 = getelementptr inbounds [5 x i8*], [5 x i8*]* %2, i64 0, i64 2
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %64
47: ; preds = %39
%48 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %47
%51 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %64
52: ; preds = %47
%53 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.10, i64 0, i64 0))
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %52
%56 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.11, i64 0, i64 0))
br label %64
57: ; preds = %52
%58 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %64
60: ; preds = %57
%61 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.13, i64 0, i64 0))
br label %64
62: ; preds = %30
%63 = call i32 @putchar(i32 48)
br label %64
64: ; preds = %62, %50, %57, %60, %55, %45, %28, %8
ret i32 0
}