#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 atoi(char *);
int /*<<< orphan*/ printf(char *);
int strlen(char *);
char *strndup(char *, int);
char *strstr(char *, char *);
int check_if_valid(char *input) {
  int i, j = 0;
  int valid = 0;
  int check;
  int remainder_from_check;
  int final;
  int even_cleaner[14] = {0};
  int first_three;
  char *first_three_ptr;
  char clean[14] = {0};
  for (i = 0; i < strlen(input); i++) {
    if ((input[i] == '0') || (input[i] == '1') || (input[i] == '2') ||
        (input[i] == '3') || (input[i] == '4') || (input[i] == '5') ||
        (input[i] == '6') || (input[i] == '7') || (input[i] == '8') ||
        (input[i] == '9')) {
      clean[j] = input[i];
      j++;
    }
  }
  if (j != 13) {
    valid = 0;
    printf("0");
    return 0;
  } else {
    valid = 1;
  }
  first_three_ptr = strndup(clean, 3);
  first_three = atoi(first_three_ptr);
  if ((first_three != 978) && (first_three != 979)) {
    valid = 0;
    printf("0");
    return 0;
  } else {
    valid = 1;
  }
  for (i = 0; i < 13; i++) {
    even_cleaner[i] = clean[i] - '0';
  }
  check = (even_cleaner[0] + even_cleaner[1] * 3 + even_cleaner[2] +
           even_cleaner[3] * 3 + even_cleaner[4] + even_cleaner[5] * 3 +
           even_cleaner[6] + even_cleaner[7] * 3 + even_cleaner[8] +
           even_cleaner[9] * 3 + even_cleaner[10] + even_cleaner[11] * 3);
  remainder_from_check = check % 10;
  if (remainder_from_check == 10) {
    final = 0;
  } else if (remainder_from_check == 0) {
    final = remainder_from_check;
  } else {
    final = 10 - remainder_from_check;
  }
  if (final != even_cleaner[12]) {
    valid = 0;
    printf("0");
    return 0;
  } else {
    valid = 1;
  }
  if (valid == 1)
    printf("1");
  char *to_be_searched = clean;
  char *alyson = "55583";
  char *result1 = strstr(to_be_searched, alyson);
  if (result1) {
    printf("\nAlyson Books");
  }
  char *bluebridge = "933346";
  char *result2 = strstr(to_be_searched, bluebridge);
  if (result2) {
    printf("\nBluebridge");
  }
  char *funimation = "4210";
  char *result3 = strstr(to_be_searched, funimation);
  if (result3) {
    printf("\nFUNimation Productions, Ltd.");
  }
  char *pyramid = "01";
  char *result4 = strstr(to_be_searched, pyramid);
  if (result4) {
    printf("\nPyramid Books");
  }
  return 1;
}


x86 assembly (clang, -O0):
<check_if_valid>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x38,%edx
call   1050 <memset@plt>
lea    -0x7e(%rbp),%rdi
xor    %esi,%esi
mov    $0xe,%edx
call   1050 <memset@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
cmp    %ecx,%eax
jge    12c7 <check_if_valid+0x167>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x30,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x31,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x32,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x33,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x34,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x35,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x36,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x37,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x38,%eax
je     1298 <check_if_valid+0x138>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x39,%eax
jne    12b4 <check_if_valid+0x154>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x7e(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12b9 <check_if_valid+0x159>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a4 <check_if_valid+0x44>
cmpl   $0xd,-0x18(%rbp)
je     12f0 <check_if_valid+0x190>
movl   $0x0,-0x1c(%rbp)
lea    0xd4b(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    156c <check_if_valid+0x40c>
movl   $0x1,-0x1c(%rbp)
lea    -0x7e(%rbp),%rdi
mov    $0x3,%esi
call   1060 <strndup@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x3d2,-0x64(%rbp)
je     134e <check_if_valid+0x1ee>
cmpl   $0x3d3,-0x64(%rbp)
je     134e <check_if_valid+0x1ee>
movl   $0x0,-0x1c(%rbp)
lea    0xced(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    156c <check_if_valid+0x40c>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0xd,-0x14(%rbp)
jge    1388 <check_if_valid+0x228>
movslq -0x14(%rbp),%rax
movsbl -0x7e(%rbp,%rax,1),%ecx
sub    $0x30,%ecx
movslq -0x14(%rbp),%rax
mov    %ecx,-0x60(%rbp,%rax,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    135c <check_if_valid+0x1fc>
mov    -0x60(%rbp),%eax
imul   $0x3,-0x5c(%rbp),%ecx
add    %ecx,%eax
add    -0x58(%rbp),%eax
imul   $0x3,-0x54(%rbp),%ecx
add    %ecx,%eax
add    -0x50(%rbp),%eax
imul   $0x3,-0x4c(%rbp),%ecx
add    %ecx,%eax
add    -0x48(%rbp),%eax
imul   $0x3,-0x44(%rbp),%ecx
add    %ecx,%eax
add    -0x40(%rbp),%eax
imul   $0x3,-0x3c(%rbp),%ecx
add    %ecx,%eax
add    -0x38(%rbp),%eax
imul   $0x3,-0x34(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
cmpl   $0xa,-0x24(%rbp)
jne    13e5 <check_if_valid+0x285>
movl   $0x0,-0x28(%rbp)
jmp    140a <check_if_valid+0x2aa>
cmpl   $0x0,-0x24(%rbp)
jne    13fa <check_if_valid+0x29a>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1405 <check_if_valid+0x2a5>
mov    $0xa,%eax
sub    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    140a <check_if_valid+0x2aa>
mov    -0x28(%rbp),%eax
cmp    -0x30(%rbp),%eax
je     1435 <check_if_valid+0x2d5>
movl   $0x0,-0x1c(%rbp)
lea    0xc06(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    156c <check_if_valid+0x40c>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1452 <check_if_valid+0x2f2>
lea    0xbfe(%rip),%rdi
call   1040 <printf@plt>
lea    -0x7e(%rbp),%rax
mov    %rax,-0x88(%rbp)
lea    0xb9c(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0x90(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     149f <check_if_valid+0x33f>
lea    0xb6c(%rip),%rdi
call   1040 <printf@plt>
lea    0xb6e(%rip),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     14e1 <check_if_valid+0x381>
lea    0xb3f(%rip),%rdi
call   1040 <printf@plt>
lea    0xb3f(%rip),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0xb8(%rbp)
cmpq   $0x0,-0xb8(%rbp)
je     1523 <check_if_valid+0x3c3>
lea    0xb0e(%rip),%rdi
call   1040 <printf@plt>
lea    0xb20(%rip),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x88(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
call   1080 <strstr@plt>
mov    %rax,-0xc8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
je     1565 <check_if_valid+0x405>
lea    0xaed(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_if_valid>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
movq   $0x0,0x6(%rsp)
movq   $0x0,(%rsp)
call   1040 <strlen@plt>
test   %eax,%eax
jle    1321 <check_if_valid+0x1c1>
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11b3 <check_if_valid+0x53>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11cd <check_if_valid+0x6d>
movzbl (%r14,%rbx,1),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     11a0 <check_if_valid+0x40>
movslq %r15d,%r15
mov    %al,(%rsp,%r15,1)
add    $0x1,%r15d
jmp    11a0 <check_if_valid+0x40>
cmp    $0xd,%r15d
jne    1321 <check_if_valid+0x1c1>
mov    %rsp,%rdi
mov    $0x3,%esi
call   1060 <strndup@plt>
mov    %rax,%rdi
call   1070 <atoi@plt>
and    $0xfffffffe,%eax
cmp    $0x3d2,%eax
jne    1321 <check_if_valid+0x1c1>
movsbl (%rsp),%eax
movsbl 0x1(%rsp),%ecx
movsbl 0x2(%rsp),%edx
add    %eax,%edx
movsbl 0x3(%rsp),%eax
add    %ecx,%eax
movsbl 0x4(%rsp),%ecx
add    %edx,%ecx
movsbl 0x5(%rsp),%edx
add    %eax,%edx
movsbl 0x6(%rsp),%eax
add    %ecx,%eax
movsbl 0x7(%rsp),%ecx
add    %edx,%ecx
movsbl 0x8(%rsp),%edx
add    %eax,%edx
movsbl 0x9(%rsp),%eax
add    %ecx,%eax
movsbl 0xa(%rsp),%ecx
add    %edx,%ecx
movsbl 0xb(%rsp),%edx
add    %eax,%edx
movsbl 0xc(%rsp),%eax
add    $0xffffffd0,%eax
lea    (%rdx,%rdx,2),%edx
add    %edx,%ecx
add    $0xfffffb80,%ecx
movswl %cx,%edx
imul   $0x6667,%edx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x12,%edx
add    %esi,%edx
add    %edx,%edx
lea    (%rdx,%rdx,4),%edx
sub    %edx,%ecx
mov    $0xa,%edx
sub    %ecx,%edx
xor    %ebx,%ebx
test   %cx,%cx
cmove  %ebx,%edx
movswl %dx,%ecx
cmp    %ecx,%eax
jne    1339 <check_if_valid+0x1d9>
mov    $0x31,%edi
call   1030 <putchar@plt>
lea    0xd5f(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12ba <check_if_valid+0x15a>
lea    0xd51(%rip),%rdi
call   1050 <printf@plt>
lea    0xd53(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12da <check_if_valid+0x17a>
lea    0xd46(%rip),%rdi
call   1050 <printf@plt>
lea    0xd46(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strstr@plt>
test   %rax,%rax
je     12fa <check_if_valid+0x19a>
lea    0xd37(%rip),%rdi
call   1050 <printf@plt>
lea    0xd49(%rip),%rsi
mov    %rsp,%rdi
call   1080 <strstr@plt>
mov    $0x1,%ebx
test   %rax,%rax
je     132d <check_if_valid+0x1cd>
lea    0xd33(%rip),%rdi
call   1050 <printf@plt>
jmp    132d <check_if_valid+0x1cd>
mov    $0x30,%edi
call   1030 <putchar@plt>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x30,%edi
call   1030 <putchar@plt>
jmp    132d <check_if_valid+0x1cd>

LLVM IR (-O0):
@.str = [2 x i8] c"0\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [6 x i8] c"55583\00"
@.str.3 = [14 x i8] c"\0AAlyson Books\00"
@.str.4 = [7 x i8] c"933346\00"
@.str.5 = [12 x i8] c"\0ABluebridge\00"
@.str.6 = [5 x i8] c"4210\00"
@.str.7 = [30 x i8] c"\0AFUNimation Productions, Ltd.\00"
@.str.8 = [3 x i8] c"01\00"
@.str.9 = [15 x i8] c"\0APyramid Books\00"
define i32 @check_if_valid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [14 x i32]
%11 = alloca i32
%12 = alloca i8*
%13 = alloca [14 x i8]
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %5
store i32 0, i32* %6
%23 = bitcast [14 x i32]* %10 to i8*
%24 = bitcast [14 x i8]* %13 to i8*
store i32 0, i32* %4
br label %25
25: ; preds = %122, %1
%26 = load i32, i32* %4
%27 = load i8*, i8** %3
%28 = call i32 @strlen(i8* %27)
%29 = icmp slt i32 %26, %28
br i1 %29, label %30, label %125
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i32, i32* %4
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 48
br i1 %37, label %110, label %38
38: ; preds = %30
%39 = load i8*, i8** %3
%40 = load i32, i32* %4
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 49
br i1 %45, label %110, label %46
46: ; preds = %38
%47 = load i8*, i8** %3
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 50
br i1 %53, label %110, label %54
54: ; preds = %46
%55 = load i8*, i8** %3
%56 = load i32, i32* %4
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %55, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i32
%61 = icmp eq i32 %60, 51
br i1 %61, label %110, label %62
62: ; preds = %54
%63 = load i8*, i8** %3
%64 = load i32, i32* %4
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 52
br i1 %69, label %110, label %70
70: ; preds = %62
%71 = load i8*, i8** %3
%72 = load i32, i32* %4
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds i8, i8* %71, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %76, 53
br i1 %77, label %110, label %78
78: ; preds = %70
%79 = load i8*, i8** %3
%80 = load i32, i32* %4
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 54
br i1 %85, label %110, label %86
86: ; preds = %78
%87 = load i8*, i8** %3
%88 = load i32, i32* %4
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8, i8* %87, i64 %89
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 55
br i1 %93, label %110, label %94
94: ; preds = %86
%95 = load i8*, i8** %3
%96 = load i32, i32* %4
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = load i8, i8* %98
%100 = sext i8 %99 to i32
%101 = icmp eq i32 %100, 56
br i1 %101, label %110, label %102
102: ; preds = %94
%103 = load i8*, i8** %3
%104 = load i32, i32* %4
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %103, i64 %105
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 57
br i1 %109, label %110, label %121
110: ; preds = %102, %94, %86, %78, %70, %62, %54, %46, %38, %30
%111 = load i8*, i8** %3
%112 = load i32, i32* %4
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i8, i8* %111, i64 %113
%115 = load i8, i8* %114
%116 = load i32, i32* %5
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds [14 x i8], [14 x i8]* %13, i64 0, i64 %117
store i8 %115, i8* %118
%119 = load i32, i32* %5
%120 = add nsw i32 %119, 1
store i32 %120, i32* %5
br label %121
121: ; preds = %110, %102
br label %122
122: ; preds = %121
%123 = load i32, i32* %4
%124 = add nsw i32 %123, 1
store i32 %124, i32* %4
br label %25
125: ; preds = %25
%126 = load i32, i32* %5
%127 = icmp ne i32 %126, 13
br i1 %127, label %128, label %130
128: ; preds = %125
store i32 0, i32* %6
%129 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %264
130: ; preds = %125
store i32 1, i32* %6
br label %131
131: ; preds = %130
%132 = getelementptr inbounds [14 x i8], [14 x i8]* %13, i64 0, i64 0
%133 = call i8* @strndup(i8* %132, i32 3)
store i8* %133, i8** %12
%134 = load i8*, i8** %12
%135 = call i32 @atoi(i8* %134)
store i32 %135, i32* %11
%136 = load i32, i32* %11
%137 = icmp ne i32 %136, 978
br i1 %137, label %138, label %143
138: ; preds = %131
%139 = load i32, i32* %11
%140 = icmp ne i32 %139, 979
br i1 %140, label %141, label %143
141: ; preds = %138
store i32 0, i32* %6
%142 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %264
143: ; preds = %138, %131
store i32 1, i32* %6
br label %144
144: ; preds = %143
store i32 0, i32* %4
br label %145
145: ; preds = %158, %144
%146 = load i32, i32* %4
%147 = icmp slt i32 %146, 13
br i1 %147, label %148, label %161
148: ; preds = %145
%149 = load i32, i32* %4
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [14 x i8], [14 x i8]* %13, i64 0, i64 %150
%152 = load i8, i8* %151
%153 = sext i8 %152 to i32
%154 = sub nsw i32 %153, 48
%155 = load i32, i32* %4
%156 = sext i32 %155 to i64
%157 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 %156
store i32 %154, i32* %157
br label %158
158: ; preds = %148
%159 = load i32, i32* %4
%160 = add nsw i32 %159, 1
store i32 %160, i32* %4
br label %145
161: ; preds = %145
%162 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 0
%163 = load i32, i32* %162
%164 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 1
%165 = load i32, i32* %164
%166 = mul nsw i32 %165, 3
%167 = add nsw i32 %163, %166
%168 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 2
%169 = load i32, i32* %168
%170 = add nsw i32 %167, %169
%171 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 3
%172 = load i32, i32* %171
%173 = mul nsw i32 %172, 3
%174 = add nsw i32 %170, %173
%175 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 4
%176 = load i32, i32* %175
%177 = add nsw i32 %174, %176
%178 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 5
%179 = load i32, i32* %178
%180 = mul nsw i32 %179, 3
%181 = add nsw i32 %177, %180
%182 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 6
%183 = load i32, i32* %182
%184 = add nsw i32 %181, %183
%185 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 7
%186 = load i32, i32* %185
%187 = mul nsw i32 %186, 3
%188 = add nsw i32 %184, %187
%189 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 8
%190 = load i32, i32* %189
%191 = add nsw i32 %188, %190
%192 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 9
%193 = load i32, i32* %192
%194 = mul nsw i32 %193, 3
%195 = add nsw i32 %191, %194
%196 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 10
%197 = load i32, i32* %196
%198 = add nsw i32 %195, %197
%199 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 11
%200 = load i32, i32* %199
%201 = mul nsw i32 %200, 3
%202 = add nsw i32 %198, %201
store i32 %202, i32* %7
%203 = load i32, i32* %7
%204 = srem i32 %203, 10
store i32 %204, i32* %8
%205 = load i32, i32* %8
%206 = icmp eq i32 %205, 10
br i1 %206, label %207, label %208
207: ; preds = %161
store i32 0, i32* %9
br label %217
208: ; preds = %161
%209 = load i32, i32* %8
%210 = icmp eq i32 %209, 0
br i1 %210, label %211, label %213
211: ; preds = %208
%212 = load i32, i32* %8
store i32 %212, i32* %9
br label %216
213: ; preds = %208
%214 = load i32, i32* %8
%215 = sub nsw i32 10, %214
store i32 %215, i32* %9
br label %216
216: ; preds = %213, %211
br label %217
217: ; preds = %216, %207
%218 = load i32, i32* %9
%219 = getelementptr inbounds [14 x i32], [14 x i32]* %10, i64 0, i64 12
%220 = load i32, i32* %219
%221 = icmp ne i32 %218, %220
br i1 %221, label %222, label %224
222: ; preds = %217
store i32 0, i32* %6
%223 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %264
224: ; preds = %217
store i32 1, i32* %6
br label %225
225: ; preds = %224
%226 = load i32, i32* %6
%227 = icmp eq i32 %226, 1
br i1 %227, label %228, label %230
228: ; preds = %225
%229 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %230
230: ; preds = %228, %225
%231 = getelementptr inbounds [14 x i8], [14 x i8]* %13, i64 0, i64 0
store i8* %231, i8** %14
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8** %15
%232 = load i8*, i8** %14
%233 = load i8*, i8** %15
%234 = call i8* @strstr(i8* %232, i8* %233)
store i8* %234, i8** %16
%235 = load i8*, i8** %16
%236 = icmp ne i8* %235, null
br i1 %236, label %237, label %239
237: ; preds = %230
%238 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %239
239: ; preds = %237, %230
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i8** %17
%240 = load i8*, i8** %14
%241 = load i8*, i8** %17
%242 = call i8* @strstr(i8* %240, i8* %241)
store i8* %242, i8** %18
%243 = load i8*, i8** %18
%244 = icmp ne i8* %243, null
br i1 %244, label %245, label %247
245: ; preds = %239
%246 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %247
247: ; preds = %245, %239
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %19
%248 = load i8*, i8** %14
%249 = load i8*, i8** %19
%250 = call i8* @strstr(i8* %248, i8* %249)
store i8* %250, i8** %20
%251 = load i8*, i8** %20
%252 = icmp ne i8* %251, null
br i1 %252, label %253, label %255
253: ; preds = %247
%254 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %255
255: ; preds = %253, %247
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8** %21
%256 = load i8*, i8** %14
%257 = load i8*, i8** %21
%258 = call i8* @strstr(i8* %256, i8* %257)
store i8* %258, i8** %22
%259 = load i8*, i8** %22
%260 = icmp ne i8* %259, null
br i1 %260, label %261, label %263
261: ; preds = %255
%262 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %263
263: ; preds = %261, %255
store i32 1, i32* %2
br label %264
264: ; preds = %263, %222, %141, %128
%265 = load i32, i32* %2
ret i32 %265
}

LLVM IR (-O2):
@.str.2 = [6 x i8] c"55583\00"
@.str.3 = [14 x i8] c"\0AAlyson Books\00"
@.str.4 = [7 x i8] c"933346\00"
@.str.5 = [12 x i8] c"\0ABluebridge\00"
@.str.6 = [5 x i8] c"4210\00"
@.str.7 = [30 x i8] c"\0AFUNimation Productions, Ltd.\00"
@.str.8 = [3 x i8] c"01\00"
@.str.9 = [15 x i8] c"\0APyramid Books\00"
define i32 @check_if_valid(i8* %0) {
%2 = alloca [14 x i8]
%3 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %25
6: ; preds = %1, %17
%7 = phi i64 [ %19, %17 ], [ 0, %1 ]
%8 = phi i32 [ %18, %17 ], [ 0, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %7
%10 = load i8, i8* %9
%11 = add i8 %10, -48
%12 = icmp ult i8 %11, 10
br i1 %12, label %13, label %17
13: ; preds = %6
%14 = sext i32 %8 to i64
%15 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 %14
store i8 %10, i8* %15
%16 = add nsw i32 %8, 1
br label %17
17: ; preds = %6, %13
%18 = phi i32 [ %16, %13 ], [ %8, %6 ]
%19 = add nuw nsw i64 %7, 1
%20 = tail call i32 @strlen(i8* %0)
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %6, label %23
23: ; preds = %17
%24 = icmp eq i32 %18, 13
br i1 %24, label %27, label %25
25: ; preds = %1, %23
%26 = tail call i32 @putchar(i32 48)
br label %116
27: ; preds = %23
%28 = call i8* @strndup(i8* %3, i32 3)
%29 = tail call i32 @atoi(i8* %28)
%30 = and i32 %29, -2
%31 = icmp eq i32 %30, 978
br i1 %31, label %32, label %91
32: ; preds = %27
%33 = load i8, i8* %3
%34 = sext i8 %33 to i16
%35 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i16
%38 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 2
%39 = load i8, i8* %38
%40 = sext i8 %39 to i16
%41 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 3
%42 = load i8, i8* %41
%43 = sext i8 %42 to i16
%44 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 4
%45 = load i8, i8* %44
%46 = sext i8 %45 to i16
%47 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 5
%48 = load i8, i8* %47
%49 = sext i8 %48 to i16
%50 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 6
%51 = load i8, i8* %50
%52 = sext i8 %51 to i16
%53 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 7
%54 = load i8, i8* %53
%55 = sext i8 %54 to i16
%56 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 8
%57 = load i8, i8* %56
%58 = sext i8 %57 to i16
%59 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 9
%60 = load i8, i8* %59
%61 = sext i8 %60 to i16
%62 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 10
%63 = load i8, i8* %62
%64 = sext i8 %63 to i16
%65 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 11
%66 = load i8, i8* %65
%67 = sext i8 %66 to i16
%68 = getelementptr inbounds [14 x i8], [14 x i8]* %2, i64 0, i64 12
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = add nsw i32 %70, -48
%72 = add nsw i16 %43, %37
%73 = add nsw i16 %72, %49
%74 = add nsw i16 %73, %55
%75 = add nsw i16 %74, %61
%76 = add nsw i16 %75, %67
%77 = mul nsw i16 %76, 3
%78 = add nsw i16 %40, %34
%79 = add nsw i16 %78, %46
%80 = add nsw i16 %79, %52
%81 = add nsw i16 %80, %58
%82 = add nsw i16 %81, %64
%83 = add i16 %82, %77
%84 = add i16 %83, -1152
%85 = srem i16 %84, 10
%86 = icmp eq i16 %85, 0
%87 = sub nsw i16 10, %85
%88 = select i1 %86, i16 0, i16 %87
%89 = sext i16 %88 to i32
%90 = icmp eq i32 %71, %89
br i1 %90, label %95, label %93
91: ; preds = %27
%92 = tail call i32 @putchar(i32 48)
br label %116
93: ; preds = %32
%94 = tail call i32 @putchar(i32 48)
br label %116
95: ; preds = %32
%96 = tail call i32 @putchar(i32 49)
%97 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%98 = icmp eq i8* %97, null
br i1 %98, label %101, label %99
99: ; preds = %95
%100 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %101
101: ; preds = %99, %95
%102 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%103 = icmp eq i8* %102, null
br i1 %103, label %106, label %104
104: ; preds = %101
%105 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %106
106: ; preds = %104, %101
%107 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%108 = icmp eq i8* %107, null
br i1 %108, label %111, label %109
109: ; preds = %106
%110 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %111
111: ; preds = %109, %106
%112 = call i8* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%113 = icmp eq i8* %112, null
br i1 %113, label %116, label %114
114: ; preds = %111
%115 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %116
116: ; preds = %111, %114, %93, %91, %25
%117 = phi i32 [ 0, %25 ], [ 0, %91 ], [ 0, %93 ], [ 1, %114 ], [ 1, %111 ]
ret i32 %117
}