#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char char2byte(char);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char *ref_line = (char *)malloc(256 * sizeof(char));
  char target_digit;
  int r, i, line = 0;
  char error = 0;
  FILE *ref = fopen("test/reference.txt", "r");
  if (ref == NULL) {
    printf("Could not find file test/reference.txt!\n");
    return 1;
  }
  FILE *target = fopen("test/all_instructions.chip8", "rb");
  if (target == NULL) {
    printf("Could not find file test/all_instructions.chip8!\n");
    printf("Have you compiled test/all_instructions.src before running this "
           "program?\n");
    fclose(ref);
    return 1;
  }
  while (fgets(ref_line, 255, ref) != NULL) {
    line = line + 1;
    for (i = 0; i < 2; i++) {
      if (0 == fread(&r, 1, 1, target)) {
        printf("Error! Compiled file ended abruptly. Stopping at line %d\n",
               line);
        fclose(ref);
        fclose(target);
        free(ref_line);
      }
      target_digit = ((char)r & 0xF0) >> 4;
      if (target_digit != (char2byte(ref_line[2 * i]))) {
        printf("Error! Byte %d at line %d does not match the reference\n", i,
               line);
        error = 1;
      }
      target_digit = ((char)r & 0x0F);
      if (target_digit != (char2byte(ref_line[2 * i + 1]))) {
        printf("Error! Byte %d at line %d does not match the reference\n", i,
               line);
        error = 1;
      }
    }
  }
  if (error) {
    printf("Compiler does NOT work correctly\n");
  } else {
    printf("Compiler works correctly!\n");
  }
  fclose(ref);
  fclose(target);
  free(ref_line);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x100,%edi
call   1090 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x20(%rbp)
movb   $0x0,-0x21(%rbp)
lea    0xe51(%rip),%rdi
lea    0xe5d(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11e4 <main+0x64>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    13cf <main+0x24f>
lea    0xe53(%rip),%rdi
lea    0xe68(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1237 <main+0xb7>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    13cf <main+0x24f>
jmp    123c <main+0xbc>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rdx
mov    $0xff,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
je     1382 <main+0x202>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    137d <main+0x1fd>
mov    -0x38(%rbp),%rcx
lea    -0x18(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <fread@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    12c0 <main+0x140>
mov    -0x20(%rbp),%esi
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%eax
movsbl %al,%eax
and    $0xf0,%eax
sar    $0x4,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <char2byte@plt>
mov    %al,%cl
mov    -0x3c(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     1316 <main+0x196>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movb   $0x1,-0x21(%rbp)
mov    -0x18(%rbp),%eax
movsbl %al,%eax
and    $0xf,%eax
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1070 <char2byte@plt>
mov    %al,%cl
mov    -0x40(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
je     136a <main+0x1ea>
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movb   $0x1,-0x21(%rbp)
jmp    136f <main+0x1ef>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1268 <main+0xe8>
jmp    123c <main+0xbc>
cmpb   $0x0,-0x21(%rbp)
je     139f <main+0x21f>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    13ad <main+0x22d>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x100,%edi
call   10a0 <malloc@plt>
mov    %rax,%r14
lea    0xe4e(%rip),%rdi
lea    0xe5a(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1391 <main+0x201>
mov    %rax,%r13
lea    0xe44(%rip),%rdi
lea    0xe59(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
je     13a4 <main+0x214>
mov    %r14,%rdi
mov    $0xff,%esi
mov    %r13,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     13d9 <main+0x249>
mov    $0x1,%r15d
xor    %r12d,%r12d
jmp    122d <main+0x9d>
nop
mov    %r14,%rdi
mov    $0xff,%esi
mov    %r13,%rdx
call   1090 <fgets@plt>
add    $0x1,%r15d
test   %rax,%rax
je     13cb <main+0x23b>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1050 <fread@plt>
test   %rax,%rax
jne    1276 <main+0xe6>
lea    0xde2(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r13,%rbp
mov    0xc(%rsp),%r13d
mov    %r13d,%ebx
shr    $0x4,%ebx
and    $0xf,%ebx
movsbl (%r14),%edi
call   1080 <char2byte@plt>
movsbl %al,%eax
cmp    %eax,%ebx
je     12ad <main+0x11d>
lea    0xdd0(%rip),%rdi
xor    %esi,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12b
and    $0xf,%r13d
movsbl 0x1(%r14),%edi
call   1080 <char2byte@plt>
movsbl %al,%eax
cmp    %eax,%r13d
je     12d9 <main+0x149>
lea    0xda4(%rip),%rdi
xor    %esi,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12b
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    0x10(%rsp),%rcx
call   1050 <fread@plt>
test   %rax,%rax
mov    %rbp,%r13
jne    1325 <main+0x195>
lea    0xd33(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%ebx
shr    $0x4,%ebx
and    $0xf,%ebx
movsbl 0x2(%r14),%edi
call   1080 <char2byte@plt>
movsbl %al,%eax
cmp    %eax,%ebx
je     135b <main+0x1cb>
lea    0xd25(%rip),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12b
and    $0xf,%ebp
movsbl 0x3(%r14),%edi
call   1080 <char2byte@plt>
movsbl %al,%eax
cmp    %eax,%ebp
je     1210 <main+0x80>
lea    0xcf4(%rip),%rdi
mov    $0x1,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12b
jmp    1210 <main+0x80>
lea    0xdc3(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1401 <main+0x271>
lea    0xd36(%rip),%rdi
call   1040 <puts@plt>
lea    0xd5b(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    $0x1,%eax
jmp    1401 <main+0x271>
test   %r12b,%r12b
je     13d9 <main+0x249>
lea    0xce9(%rip),%rdi
jmp    13e0 <main+0x250>
lea    0xcc6(%rip),%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [19 x i8] c"test/reference.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [41 x i8] c"Could not find file test/reference.txt!\0A\00"
@.str.3 = [28 x i8] c"test/all_instructions.chip8\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.5 = [50 x i8] c"Could not find file test/all_instructions.chip8!\0A\00"
@.str.6 = [74 x i8] c"Have you compiled test/all_instructions.src before running this program?\0A\00"
@.str.7 = [58 x i8] c"Error! Compiled file ended abruptly. Stopping at line %d\0A\00"
@.str.8 = [56 x i8] c"Error! Byte %d at line %d does not match the reference\0A\00"
@.str.9 = [34 x i8] c"Compiler does NOT work correctly\0A\00"
@.str.10 = [27 x i8] c"Compiler works correctly!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %1
%10 = call i64 @malloc(i32 256)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %2
store i32 0, i32* %6
store i8 0, i8* %7
%12 = call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %8
%13 = load i32*, i32** %8
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %114
17: ; preds = %0
%18 = call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.5, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.6, i64 0, i64 0))
%24 = load i32*, i32** %8
%25 = call i32 @fclose(i32* %24)
store i32 1, i32* %1
br label %114
26: ; preds = %17
br label %27
27: ; preds = %99, %26
%28 = load i8*, i8** %2
%29 = load i32*, i32** %8
%30 = call i32* @fgets(i8* %28, i32 255, i32* %29)
%31 = icmp ne i32* %30, null
br i1 %31, label %32, label %100
32: ; preds = %27
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
store i32 0, i32* %5
br label %35
35: ; preds = %96, %32
%36 = load i32, i32* %5
%37 = icmp slt i32 %36, 2
br i1 %37, label %38, label %99
38: ; preds = %35
%39 = load i32*, i32** %9
%40 = call i64 @fread(i32* %4, i32 1, i32 1, i32* %39)
%41 = icmp eq i64 0, %40
br i1 %41, label %42, label %51
42: ; preds = %38
%43 = load i32, i32* %6
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i32 %43)
%45 = load i32*, i32** %8
%46 = call i32 @fclose(i32* %45)
%47 = load i32*, i32** %9
%48 = call i32 @fclose(i32* %47)
%49 = load i8*, i8** %2
%50 = call i32 @free(i8* %49)
br label %51
51: ; preds = %42, %38
%52 = load i32, i32* %4
%53 = trunc i32 %52 to i8
%54 = sext i8 %53 to i32
%55 = and i32 %54, 240
%56 = ashr i32 %55, 4
%57 = trunc i32 %56 to i8
store i8 %57, i8* %3
%58 = load i8, i8* %3
%59 = sext i8 %58 to i32
%60 = load i8*, i8** %2
%61 = load i32, i32* %5
%62 = mul nsw i32 2, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i8, i8* %60, i64 %63
%65 = load i8, i8* %64
%66 = call signext i8 @char2byte(i8 signext %65)
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %59, %67
br i1 %68, label %69, label %73
69: ; preds = %51
%70 = load i32, i32* %5
%71 = load i32, i32* %6
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %70, i32 %71)
store i8 1, i8* %7
br label %73
73: ; preds = %69, %51
%74 = load i32, i32* %4
%75 = trunc i32 %74 to i8
%76 = sext i8 %75 to i32
%77 = and i32 %76, 15
%78 = trunc i32 %77 to i8
store i8 %78, i8* %3
%79 = load i8, i8* %3
%80 = sext i8 %79 to i32
%81 = load i8*, i8** %2
%82 = load i32, i32* %5
%83 = mul nsw i32 2, %82
%84 = add nsw i32 %83, 1
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %81, i64 %85
%87 = load i8, i8* %86
%88 = call signext i8 @char2byte(i8 signext %87)
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %80, %89
br i1 %90, label %91, label %95
91: ; preds = %73
%92 = load i32, i32* %5
%93 = load i32, i32* %6
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 %92, i32 %93)
store i8 1, i8* %7
br label %95
95: ; preds = %91, %73
br label %96
96: ; preds = %95
%97 = load i32, i32* %5
%98 = add nsw i32 %97, 1
store i32 %98, i32* %5
br label %35
99: ; preds = %35
br label %27
100: ; preds = %27
%101 = load i8, i8* %7
%102 = icmp ne i8 %101, 0
br i1 %102, label %103, label %105
103: ; preds = %100
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
br label %107
105: ; preds = %100
%106 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %107
107: ; preds = %105, %103
%108 = load i32*, i32** %8
%109 = call i32 @fclose(i32* %108)
%110 = load i32*, i32** %9
%111 = call i32 @fclose(i32* %110)
%112 = load i8*, i8** %2
%113 = call i32 @free(i8* %112)
store i32 0, i32* %1
br label %114
114: ; preds = %107, %21, %15
%115 = load i32, i32* %1
ret i32 %115
}

LLVM IR (-O2):
@.str = [19 x i8] c"test/reference.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [28 x i8] c"test/all_instructions.chip8\00"
@.str.4 = [3 x i8] c"rb\00"
@.str.7 = [58 x i8] c"Error! Compiled file ended abruptly. Stopping at line %d\0A\00"
@.str.8 = [56 x i8] c"Error! Byte %d at line %d does not match the reference\0A\00"
@str = [26 x i8] c"Compiler works correctly!\00"
@str.11 = [33 x i8] c"Compiler does NOT work correctly\00"
@str.12 = [49 x i8] c"Could not find file test/all_instructions.chip8!\00"
@str.13 = [73 x i8] c"Have you compiled test/all_instructions.src before running this program?\00"
@str.14 = [40 x i8] c"Could not find file test/reference.txt!\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i64 @malloc(i32 256)
%3 = inttoptr i64 %2 to i8*
%4 = bitcast i32* %1 to i8*
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.14, i64 0, i64 0))
br label %94
9: ; preds = %0
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %19, label %12
12: ; preds = %9
%13 = tail call i32* @fgets(i8* %3, i32 255, i32* %5)
%14 = icmp eq i32* %13, null
br i1 %14, label %87, label %15
15: ; preds = %12
%16 = getelementptr inbounds i8, i8* %3, i64 1
%17 = getelementptr inbounds i8, i8* %3, i64 2
%18 = getelementptr inbounds i8, i8* %3, i64 3
br label %23
19: ; preds = %9
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.12, i64 0, i64 0))
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @str.13, i64 0, i64 0))
%22 = tail call i32 @fclose(i32* %5)
br label %94
23: ; preds = %15, %81
%24 = phi i8 [ %82, %81 ], [ 0, %15 ]
%25 = phi i32 [ %26, %81 ], [ 0, %15 ]
%26 = add nuw nsw i32 %25, 1
%27 = call i64 @fread(i32* %1, i32 1, i32 1, i32* %10)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%31 = tail call i32 @fclose(i32* %5)
%32 = tail call i32 @fclose(i32* %10)
%33 = tail call i32 @free(i8* %3)
br label %34
34: ; preds = %29, %23
%35 = load i32, i32* %1
%36 = lshr i32 %35, 4
%37 = and i32 %36, 15
%38 = load i8, i8* %3
%39 = tail call signext i8 @char2byte(i8 signext %38)
%40 = sext i8 %39 to i32
%41 = icmp eq i32 %37, %40
br i1 %41, label %44, label %42
42: ; preds = %34
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 0, i32 %26)
br label %44
44: ; preds = %42, %34
%45 = phi i8 [ 1, %42 ], [ %24, %34 ]
%46 = and i32 %35, 15
%47 = load i8, i8* %16
%48 = tail call signext i8 @char2byte(i8 signext %47)
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %46, %49
br i1 %50, label %53, label %51
51: ; preds = %44
%52 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 0, i32 %26)
br label %53
53: ; preds = %44, %51
%54 = phi i8 [ 1, %51 ], [ %45, %44 ]
%55 = call i64 @fread(i32* %1, i32 1, i32 1, i32* %10)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %53
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%59 = tail call i32 @fclose(i32* %5)
%60 = tail call i32 @fclose(i32* %10)
%61 = tail call i32 @free(i8* %3)
br label %62
62: ; preds = %57, %53
%63 = load i32, i32* %1
%64 = lshr i32 %63, 4
%65 = and i32 %64, 15
%66 = load i8, i8* %17
%67 = tail call signext i8 @char2byte(i8 signext %66)
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %65, %68
br i1 %69, label %72, label %70
70: ; preds = %62
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 1, i32 %26)
br label %72
72: ; preds = %70, %62
%73 = phi i8 [ 1, %70 ], [ %54, %62 ]
%74 = and i32 %63, 15
%75 = load i8, i8* %18
%76 = tail call signext i8 @char2byte(i8 signext %75)
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %74, %77
br i1 %78, label %81, label %79
79: ; preds = %72
%80 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0), i32 1, i32 %26)
br label %81
81: ; preds = %79, %72
%82 = phi i8 [ 1, %79 ], [ %73, %72 ]
%83 = tail call i32* @fgets(i8* %3, i32 255, i32* %5)
%84 = icmp eq i32* %83, null
br i1 %84, label %85, label %23
85: ; preds = %81
%86 = icmp eq i8 %82, 0
br i1 %86, label %87, label %88
87: ; preds = %12, %85
br label %88
88: ; preds = %85, %87
%89 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0), %87 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.11, i64 0, i64 0), %85 ]
%90 = tail call i32 @puts(i8* dereferenceable(1) %89)
%91 = tail call i32 @fclose(i32* %5)
%92 = tail call i32 @fclose(i32* %10)
%93 = tail call i32 @free(i8* %3)
br label %94
94: ; preds = %19, %88, %7
%95 = phi i32 [ 1, %7 ], [ 1, %19 ], [ 0, %88 ]
ret i32 %95
}