#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_ISBN(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
scalar_t__ strstr(char *, char *);
char *strtok(char *, char *);
int main() {
  char input_str[20] = {0};
  char *str_arr[20];
  char *temp;
  int i = 0;
  int valid = 0;
  int sum = 0;
  int length = 0;
  scanf("%s", input_str);
  length = strlen(input_str) - 4;
  sum = check_ISBN(input_str);
  temp = strtok(input_str, "-");
  for (i = 0; temp != NULL; i++) {
    str_arr[i] = temp;
    temp = strtok(NULL, "-");
  }
  if (strstr(str_arr[0], "978") || strstr(str_arr[0], "979"))
    if (length == 13 && *str_arr[4] - '0' == sum)
      valid = 1;
  printf("%d\n", valid);
  if (valid) {
    if (strstr(str_arr[2], "933346")) {
      printf("Bluebridge");
    }
    if (strstr(str_arr[2], "55583")) {
      printf("Alyson Books");
    }
    if (strstr(str_arr[2], "4210")) {
      printf("FUNimation Productions, Ltd.");
    }
    if (strstr(str_arr[2], "01")) {
      printf("Pyramid Books");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
movl   $0x0,-0xcc(%rbp)
movl   $0x0,-0xd0(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xd8(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe3b(%rip),%rdi
call   1070 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x4,%eax
mov    %eax,-0xd8(%rbp)
lea    -0x20(%rbp),%rdi
call   1060 <check_ISBN@plt>
mov    %eax,-0xd4(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe0d(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xc8(%rbp)
movl   $0x0,-0xcc(%rbp)
cmpq   $0x0,-0xc8(%rbp)
je     125b <main+0xeb>
mov    -0xc8(%rbp),%rcx
movslq -0xcc(%rbp),%rax
mov    %rcx,-0xc0(%rbp,%rax,8)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc8(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0xc8(%rbp)
mov    -0xcc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xcc(%rbp)
jmp    120c <main+0x9c>
mov    -0xc0(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
jne    1295 <main+0x125>
mov    -0xc0(%rbp),%rdi
lea    0xd83(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     12ca <main+0x15a>
cmpl   $0xd,-0xd8(%rbp)
jne    12c5 <main+0x155>
mov    -0xa0(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
cmp    -0xd4(%rbp),%eax
jne    12c5 <main+0x155>
movl   $0x1,-0xd0(%rbp)
jmp    12ca <main+0x15a>
mov    -0xd0(%rbp),%esi
lea    0xd36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0xd0(%rbp)
je     139c <main+0x22c>
mov    -0xb0(%rbp),%rdi
lea    0xd18(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1316 <main+0x1a6>
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb0(%rbp),%rdi
lea    0xcff(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1341 <main+0x1d1>
lea    0xcef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb0(%rbp),%rdi
lea    0xce7(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     136c <main+0x1fc>
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb0(%rbp),%rdi
lea    0xcde(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1397 <main+0x227>
lea    0xccb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    139c <main+0x22c>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
lea    0xe7d(%rip),%rdi
mov    %rsp,%rbp
mov    %rbp,%rsi
call   1060 <scanf@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
add    $0xfffffffc,%r15d
mov    %rbp,%rdi
call   1050 <check_ISBN@plt>
mov    %eax,%r14d
lea    0xe54(%rip),%rbx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <strtok@plt>
lea    0x20(%rsp),%rbp
nop
mov    %rax,0x0(%rbp)
xor    %edi,%edi
mov    %rbx,%rsi
call   1070 <strtok@plt>
add    $0x8,%rbp
test   %rax,%rax
jne    11c0 <main+0x60>
mov    0x20(%rsp),%rbx
lea    0xe22(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
jne    1208 <main+0xa8>
lea    0xe12(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12cc <main+0x16c>
cmp    $0xd,%r15d
jne    12cc <main+0x16c>
mov    0x40(%rsp),%rax
movsbl (%rax),%ebx
add    $0xffffffd0,%ebx
xor    %esi,%esi
cmp    %r14d,%ebx
sete   %sil
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    %r14d,%ebx
jne    12dc <main+0x17c>
mov    0x30(%rsp),%rbx
lea    0xdc8(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1264 <main+0x104>
lea    0xdbb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdb8(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     1286 <main+0x126>
lea    0xdaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12a8 <main+0x148>
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xda9(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12dc <main+0x17c>
lea    0xd98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    12dc <main+0x17c>
lea    0xd3a(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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