#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*/ CheckPublisher(char *);
scalar_t__ IsOnlyDigits(char *);
scalar_t__ checkFirstDigits(char *);
scalar_t__ checkLength(char *);
int checkSum(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char inputISBN[20];
  scanf("%[^\n]s", inputISBN);
  if (checkLength(inputISBN) && checkFirstDigits(inputISBN) &&
      IsOnlyDigits(inputISBN)) {
    if ((checkSum(inputISBN) + 48) == inputISBN[strlen(inputISBN) - 1]) {
      printf("%d", 1);
      CheckPublisher(inputISBN);
      return 0;
    }
  }
  printf("0");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe66(%rip),%rdi
call   1090 <scanf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <checkLength@plt>
cmp    $0x0,%rax
je     1235 <main+0xb5>
lea    -0x20(%rbp),%rdi
call   10a0 <checkFirstDigits@plt>
cmp    $0x0,%rax
je     1235 <main+0xb5>
lea    -0x20(%rbp),%rdi
call   1080 <IsOnlyDigits@plt>
cmp    $0x0,%rax
je     1235 <main+0xb5>
lea    -0x20(%rbp),%rdi
call   1030 <checkSum@plt>
add    $0x30,%eax
mov    %eax,-0x24(%rbp)
lea    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x20(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    1230 <main+0xb0>
lea    0xdf8(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1070 <CheckPublisher@plt>
movl   $0x0,-0x4(%rbp)
jmp    124a <main+0xca>
jmp    1235 <main+0xb5>
lea    0xdce(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
lea    0xe63(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   10a0 <scanf@plt>
mov    %rbx,%rdi
call   1070 <checkLength@plt>
test   %rax,%rax
je     120f <main+0x7f>
mov    %rsp,%rdi
call   10b0 <checkFirstDigits@plt>
test   %rax,%rax
je     120f <main+0x7f>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1090 <IsOnlyDigits@plt>
test   %rax,%rax
je     120f <main+0x7f>
mov    %rbx,%rdi
call   1040 <checkSum@plt>
mov    %eax,%ebp
add    $0x30,%ebp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
movsbl -0x1(%rax,%rbx,1),%eax
cmp    %eax,%ebp
jne    120f <main+0x7f>
lea    0xe0e(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%rdi
call   1080 <CheckPublisher@plt>
jmp    1219 <main+0x89>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"0\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i64 @checkLength(i8* %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %0
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = call i64 @checkFirstDigits(i8* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %33
12: ; preds = %8
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = call i64 @IsOnlyDigits(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %12
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%18 = call i32 @checkSum(i8* %17)
%19 = add nsw i32 %18, 48
%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, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %19, %26
br i1 %27, label %28, label %32
28: ; preds = %16
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%31 = call i32 @CheckPublisher(i8* %30)
store i32 0, i32* %1
br label %35
32: ; preds = %16
br label %33
33: ; preds = %32, %12, %8, %0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %35
35: ; preds = %33, %28
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [7 x i8] c"%[^\0A]s\00"
@.str.1 = [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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i64 @checkLength(i8* %2)
%5 = icmp eq i64 %4, 0
br i1 %5, label %25, label %6
6: ; preds = %0
%7 = call i64 @checkFirstDigits(i8* %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %25, label %9
9: ; preds = %6
%10 = call i64 @IsOnlyDigits(i8* %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %25, label %12
12: ; preds = %9
%13 = call i32 @checkSum(i8* %2)
%14 = add nsw i32 %13, 48
%15 = call i32 @strlen(i8* %2)
%16 = add nsw i32 %15, -1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %14, %20
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 1)
%24 = call i32 @CheckPublisher(i8* %2)
br label %27
25: ; preds = %12, %9, %6, %0
%26 = call i32 @putchar(i32 48)
br label %27
27: ; preds = %25, %22
ret i32 0
}