#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*/ CheckBrand(char *);
char CheckISBN(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int main() {
  int i, end = 1, shit = 0;
  char a[20];
  scanf("%s", a);
  if ((a[16] - '0') != CheckISBN(a))
    end = 5;
  if (strncmp(a, "978-", 4) != 0 && strncmp(a, "979-", 4) != 0)
    end = 0;
  for (i = 0; i < strlen(a); i++)
    if (a[i] != '-')
      shit++;
  if (shit != 13)
    end = 0;
  printf("%d", end);
  if (end == 1)
    CheckBrand(a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    -0x30(%rbp),%rsi
lea    0xe78(%rip),%rdi
call   1070 <scanf@plt>
movsbl -0x20(%rbp),%eax
sub    $0x30,%eax
mov    %eax,-0x34(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <CheckISBN@plt>
mov    %al,%cl
mov    -0x34(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     11b7 <main+0x57>
movl   $0x5,-0xc(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe41(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
lea    -0x30(%rbp),%rdi
lea    0xe27(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    124d <main+0xed>
movslq -0x8(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%eax
cmp    $0x2d,%eax
je     123a <main+0xda>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    123f <main+0xdf>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1203 <main+0xa3>
cmpl   $0xd,-0x10(%rbp)
je     125e <main+0xfe>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xda5(%rip),%rdi
call   1050 <printf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    1280 <main+0x120>
lea    -0x30(%rbp),%rdi
call   1060 <CheckBrand@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xe8f(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1070 <scanf@plt>
movsbl 0x10(%rsp),%ebp
add    $0xffffffd0,%ebp
mov    %rbx,%rdi
call   1080 <CheckISBN@plt>
movsbl %al,%eax
xor    %ecx,%ecx
cmp    %eax,%ebp
setne  %cl
lea    0x1(,%rcx,4),%r14d
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11d4 <main+0x74>
lea    0xe4a(%rip),%rsi
mov    %rsp,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmovne %ecx,%r14d
mov    %rsp,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1232 <main+0xd2>
xor    %ebp,%ebp
mov    %rsp,%r15
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
cmpb   $0x2d,(%rsp,%rbp,1)
setne  %al
add    %eax,%ebx
add    $0x1,%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     11f0 <main+0x90>
cmp    $0xd,%ebx
jne    1232 <main+0xd2>
lea    0xdf3(%rip),%rdi
mov    %r14d,%esi
call   1050 <printf@plt>
cmp    $0x1,%r14d
jne    1240 <main+0xe0>
mov    %rsp,%rdi
call   1060 <CheckBrand@plt>
jmp    1240 <main+0xe0>
lea    0xdd4(%rip),%rdi
xor    %esi,%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"978-\00"
@.str.2 = [5 x i8] c"979-\00"
@.str.3 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x i8]
store i32 0, i32* %1
store i32 1, i32* %3
store i32 0, i32* %4
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 16
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = sub nsw i32 %10, 48
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%13 = call signext i8 @CheckISBN(i8* %12)
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %11, %14
br i1 %15, label %16, label %17
16: ; preds = %0
store i32 5, i32* %3
br label %17
17: ; preds = %16, %0
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%23 = call i64 @strncmp(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %21
store i32 0, i32* %3
br label %26
26: ; preds = %25, %21, %17
store i32 0, i32* %2
br label %27
27: ; preds = %43, %26
%28 = load i32, i32* %2
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = load i32, i32* %2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 45
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %42
42: ; preds = %39, %32
br label %43
43: ; preds = %42
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
br label %27
46: ; preds = %27
%47 = load i32, i32* %4
%48 = icmp ne i32 %47, 13
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %3
br label %50
50: ; preds = %49, %46
%51 = load i32, i32* %3
%52 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %3
%54 = icmp eq i32 %53, 1
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%57 = call i32 @CheckBrand(i8* %56)
br label %58
58: ; preds = %55, %50
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [5 x i8] c"978-\00"
@.str.2 = [5 x i8] c"979-\00"
@.str.3 = [3 x i8] c"%d\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 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 16
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
%7 = add nsw i32 %6, -48
%8 = call signext i8 @CheckISBN(i8* %2)
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %7, %9
%11 = select i1 %10, i32 1, i32 5
%12 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %0
%15 = call i64 @strncmp(i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%16 = icmp eq i64 %15, 0
%17 = select i1 %16, i32 %11, i32 0
br label %18
18: ; preds = %14, %0
%19 = phi i32 [ %11, %0 ], [ %17, %14 ]
%20 = call i32 @strlen(i8* %2)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %18, %22
%23 = phi i64 [ %30, %22 ], [ 0, %18 ]
%24 = phi i32 [ %29, %22 ], [ 0, %18 ]
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %23
%26 = load i8, i8* %25
%27 = icmp ne i8 %26, 45
%28 = zext i1 %27 to i32
%29 = add nuw nsw i32 %24, %28
%30 = add nuw nsw i64 %23, 1
%31 = call i32 @strlen(i8* %2)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %22, label %34
34: ; preds = %22
%35 = icmp eq i32 %29, 13
br i1 %35, label %38, label %36
36: ; preds = %18, %34
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %43
38: ; preds = %34
%39 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%40 = icmp eq i32 %19, 1
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @CheckBrand(i8* %2)
br label %43
43: ; preds = %36, %41, %38
ret i32 0
}