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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
long long getfilesize(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int sscanf(char *, char *, unsigned int *);
int strlen(char *);
void hxsearch(FILE *fptr, char *hexstring, long long filesize_bytes,
              long blocksize) {
  char pattern_buffer[16] = {0};
  char chunk[blocksize];
  unsigned int byte;
  int res;
  int z = 0;
  int current_search = 0;
  long long int master_counter = 0;
  int arraysize = 0;
  int len = 0;
  int pos = 0;
  int counter = 0;
  int bytes_read = 0;
  int runs = 0;
  int matches = 0;
  size_t offsetctr = 0;
  char *chunkptr;
  long long sz = 0;
  len = strlen(hexstring);
  arraysize = sizeof(hexstring) / sizeof(char);
  off_t fs = getfilesize(fptr);
  sz = fs;
  printf("Parsing Hex string \"%s\" now.\n\n", hexstring);
  while ((res = sscanf(&hexstring[pos], "%2x", &byte)) == 1) {
    pattern_buffer[counter] = byte;
    pos += 2;
    counter++;
  }
  printf("Results:\n\n");
  while ((bytes_read =
              fread(chunk, sizeof(unsigned char), sizeof(chunk), fptr)) > 0) {
    chunkptr = chunk;
    for (z = 0; z < bytes_read; z++) {
      if (*chunkptr == pattern_buffer[current_search]) {
        current_search++;
        if (current_search > (counter - 1)) {
          current_search = 0;
          printf("Hex string %s was found at starting byte location:  %lld\n",
                 hexstring, (long long int)(offsetctr - 1));
          matches++;
        }
      } else {
        current_search = 0;
      }
      chunkptr++;
      offsetctr++;
    }
    master_counter += bytes_read;
    runs++;
  }
  printf("\n\nQuick statistics:\n");
  printf("=====================\n");
  printf("Number of bytes that have been read:  %lld\n", master_counter);
  printf("Number of signature matches found:  %d\n", matches);
  printf("Total number of bytes in hex string:  %d\n", counter);
  printf("Block size of each buffer:  %ld\n", blocksize);
  printf("Number of buffers searched:  %d\n", runs);
  fclose(fptr);
  exit(0);
}


x86 assembly (clang, -O0):
<hxsearch>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movaps %xmm0,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movq   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
movl   $0x0,-0x6c(%rbp)
movl   $0x0,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x90(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x60(%rbp)
movl   $0x8,-0x5c(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getfilesize@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
movslq -0x64(%rbp),%rax
add    %rax,%rdi
lea    0xdad(%rip),%rsi
lea    -0x44(%rbp),%rdx
call   1080 <sscanf@plt>
mov    %eax,-0x48(%rbp)
cmp    $0x1,%eax
jne    12ab <hxsearch+0x13b>
mov    -0x44(%rbp),%eax
mov    %al,%cl
movslq -0x68(%rbp),%rax
mov    %cl,-0x30(%rbp,%rax,1)
mov    -0x64(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x64(%rbp)
mov    -0x68(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x68(%rbp)
jmp    1260 <hxsearch+0xf0>
lea    0xd71(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rax
mov    %eax,%edx
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x6c(%rbp)
cmp    $0x0,%eax
jle    13b5 <hxsearch+0x245>
mov    -0xa0(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x6c(%rbp),%eax
jge    139b <hxsearch+0x22b>
mov    -0x88(%rbp),%rax
movsbl (%rax),%eax
movslq -0x50(%rbp),%rcx
movsbl -0x30(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
jne    1368 <hxsearch+0x1f8>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x68(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jle    1363 <hxsearch+0x1f3>
movl   $0x0,-0x50(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x80(%rbp),%rdx
sub    $0x1,%rdx
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    136f <hxsearch+0x1ff>
movl   $0x0,-0x50(%rbp)
mov    -0x88(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
mov    -0x80(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x80(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    12f8 <hxsearch+0x188>
movslq -0x6c(%rbp),%rax
add    -0x58(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x70(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x70(%rbp)
jmp    12b9 <hxsearch+0x149>
lea    0xcac(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcb3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xcb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x74(%rbp),%esi
lea    0xcd3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x68(%rbp),%esi
lea    0xcea(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x70(%rbp),%esi
lea    0xd12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<hxsearch>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
xorps  %xmm0,%xmm0
movaps %xmm0,-0x80(%rbp)
mov    %rsp,%r14
mov    %rcx,-0x38(%rbp)
lea    0xf(%rcx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    %rsi,%rdi
call   1060 <strlen@plt>
mov    %r15,-0x40(%rbp)
mov    %r15,%rdi
call   1080 <getfilesize@plt>
lea    0xe32(%rip),%rdi
xor    %r15d,%r15d
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe3d(%rip),%rsi
lea    -0x30(%rbp),%rdx
mov    %rbx,-0x50(%rbp)
mov    %rbx,%rdi
call   1090 <sscanf@plt>
mov    $0x0,%r13d
cmp    $0x1,%eax
jne    1247 <hxsearch+0xc7>
mov    -0x50(%rbp),%rax
lea    0x2(%rax),%rbx
xor    %r13d,%r13d
lea    0xe10(%rip),%r15
lea    -0x30(%rbp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl -0x30(%rbp),%eax
mov    %al,-0x80(%rbp,%r13,1)
add    $0x1,%r13
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <sscanf@plt>
add    $0x2,%rbx
cmp    $0x1,%eax
je     1220 <hxsearch+0xa0>
xor    %r15d,%r15d
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
call   1040 <fread@plt>
test   %eax,%eax
mov    %r13,-0x58(%rbp)
jle    133f <hxsearch+0x1bf>
mov    %eax,%ecx
lea    -0x1(%r13),%eax
mov    %eax,-0x48(%rbp)
mov    %ecx,%eax
xor    %r12d,%r12d
xor    %r13d,%r13d
movl   $0x0,-0x2c(%rbp)
xor    %r15d,%r15d
xor    %ebx,%ebx
jmp    12cc <hxsearch+0x14c>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movslq -0x44(%rbp),%rax
mov    -0x60(%rbp),%rbx
add    %rax,%rbx
mov    -0x68(%rbp),%r15
add    $0x1,%r15d
mov    %r14,%rdi
mov    $0x1,%esi
mov    -0x38(%rbp),%rdx
mov    -0x40(%rbp),%rcx
call   1040 <fread@plt>
test   %eax,%eax
jle    1348 <hxsearch+0x1c8>
mov    %rbx,-0x60(%rbp)
mov    %r15,-0x68(%rbp)
mov    %eax,-0x44(%rbp)
mov    %eax,%r15d
neg    %r15d
mov    $0xffffffffffffffff,%rbx
jmp    1304 <hxsearch+0x184>
cs nopw 0x0(%rax,%rax,1)
xor    %r12d,%r12d
add    $0x1,%r13
add    $0x1,%rbx
lea    (%rbx,%r15,1),%eax
cmp    $0xffffffff,%eax
je     12a0 <hxsearch+0x120>
movzbl 0x1(%r14,%rbx,1),%eax
movslq %r12d,%rcx
cmp    -0x80(%rbp,%rcx,1),%al
jne    12f0 <hxsearch+0x170>
cmp    -0x48(%rbp),%r12d
jge    1320 <hxsearch+0x1a0>
add    $0x1,%r12d
jmp    12f3 <hxsearch+0x173>
nop
lea    -0x1(%r13),%rdx
xor    %r12d,%r12d
lea    0xcf5(%rip),%rdi
mov    -0x50(%rbp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
addl   $0x1,-0x2c(%rbp)
jmp    12f3 <hxsearch+0x173>
xor    %ebx,%ebx
movl   $0x0,-0x2c(%rbp)
lea    0xdd8(%rip),%rdi
call   1030 <puts@plt>
lea    0xde0(%rip),%rdi
call   1030 <puts@plt>
lea    0xcf6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd11(%rip),%rdi
mov    -0x2c(%rbp),%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd28(%rip),%rdi
mov    -0x58(%rbp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd40(%rip),%rdi
mov    -0x38(%rbp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd4f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Parsing Hex string \22%s\22 now.\0A\0A\00"
@.str.1 = [4 x i8] c"%2x\00"
@.str.2 = [11 x i8] c"Results:\0A\0A\00"
@.str.3 = [58 x i8] c"Hex string %s was found at starting byte location: %lld\0A\00"
@.str.4 = [21 x i8] c"\0A\0AQuick statistics:\0A\00"
@.str.5 = [23 x i8] c"=====================\0A\00"
@.str.6 = [44 x i8] c"Number of bytes that have been read: %lld\0A\00"
@.str.7 = [40 x i8] c"Number of signature matches found: %d\0A\00"
@.str.8 = [42 x i8] c"Total number of bytes in hex string: %d\0A\00"
@.str.9 = [33 x i8] c"Block size of each buffer: %ld\0A\00"
@.str.10 = [33 x i8] c"Number of buffers searched: %d\0A\00"
define void @hxsearch(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca [16 x i8]
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i64
%25 = alloca i8*
%26 = alloca i64
%27 = alloca i64
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%28 = bitcast [16 x i8]* %9 to i8*
%29 = load i64, i64* %8
%30 = call i8* @llvm.stacksave()
store i8* %30, i8** %10
%31 = alloca i8, i64 %29
store i64 %29, i64* %11
store i32 0, i32* %14
store i32 0, i32* %15
store i64 0, i64* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store i32 0, i32* %22
store i32 0, i32* %23
store i64 0, i64* %24
store i64 0, i64* %26
%32 = load i8*, i8** %6
%33 = call i32 @strlen(i8* %32)
store i32 %33, i32* %18
store i32 8, i32* %17
%34 = load i32*, i32** %5
%35 = call i64 @getfilesize(i32* %34)
store i64 %35, i64* %27
%36 = load i64, i64* %27
store i64 %36, i64* %26
%37 = load i8*, i8** %6
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %46, %4
%40 = load i8*, i8** %6
%41 = load i32, i32* %19
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %12)
store i32 %44, i32* %13
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %56
46: ; preds = %39
%47 = load i32, i32* %12
%48 = trunc i32 %47 to i8
%49 = load i32, i32* %20
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %50
store i8 %48, i8* %51
%52 = load i32, i32* %19
%53 = add nsw i32 %52, 2
store i32 %53, i32* %19
%54 = load i32, i32* %20
%55 = add nsw i32 %54, 1
store i32 %55, i32* %20
br label %39
56: ; preds = %39
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %102, %56
%59 = trunc i64 %29 to i32
%60 = load i32*, i32** %5
%61 = call i32 @fread(i8* %31, i32 1, i32 %59, i32* %60)
store i32 %61, i32* %21
%62 = icmp sgt i32 %61, 0
br i1 %62, label %63, label %109
63: ; preds = %58
store i8* %31, i8** %25
store i32 0, i32* %14
br label %64
64: ; preds = %99, %63
%65 = load i32, i32* %14
%66 = load i32, i32* %21
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %102
68: ; preds = %64
%69 = load i8*, i8** %25
%70 = load i8, i8* %69
%71 = sext i8 %70 to i32
%72 = load i32, i32* %15
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 %73
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp eq i32 %71, %76
br i1 %77, label %78, label %93
78: ; preds = %68
%79 = load i32, i32* %15
%80 = add nsw i32 %79, 1
store i32 %80, i32* %15
%81 = load i32, i32* %15
%82 = load i32, i32* %20
%83 = sub nsw i32 %82, 1
%84 = icmp sgt i32 %81, %83
br i1 %84, label %85, label %92
85: ; preds = %78
store i32 0, i32* %15
%86 = load i8*, i8** %6
%87 = load i64, i64* %24
%88 = sub i64 %87, 1
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %86, i64 %88)
%90 = load i32, i32* %23
%91 = add nsw i32 %90, 1
store i32 %91, i32* %23
br label %92
92: ; preds = %85, %78
br label %94
93: ; preds = %68
store i32 0, i32* %15
br label %94
94: ; preds = %93, %92
%95 = load i8*, i8** %25
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %25
%97 = load i64, i64* %24
%98 = add i64 %97, 1
store i64 %98, i64* %24
br label %99
99: ; preds = %94
%100 = load i32, i32* %14
%101 = add nsw i32 %100, 1
store i32 %101, i32* %14
br label %64
102: ; preds = %64
%103 = load i32, i32* %21
%104 = sext i32 %103 to i64
%105 = load i64, i64* %16
%106 = add nsw i64 %105, %104
store i64 %106, i64* %16
%107 = load i32, i32* %22
%108 = add nsw i32 %107, 1
store i32 %108, i32* %22
br label %58
109: ; preds = %58
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%112 = load i64, i64* %16
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i64 %112)
%114 = load i32, i32* %23
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %114)
%116 = load i32, i32* %20
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %116)
%118 = load i64, i64* %8
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i64 %118)
%120 = load i32, i32* %22
%121 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %120)
%122 = load i32*, i32** %5
%123 = call i32 @fclose(i32* %122)
%124 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [31 x i8] c"Parsing Hex string \22%s\22 now.\0A\0A\00"
@.str.1 = [4 x i8] c"%2x\00"
@.str.3 = [58 x i8] c"Hex string %s was found at starting byte location: %lld\0A\00"
@.str.6 = [44 x i8] c"Number of bytes that have been read: %lld\0A\00"
@.str.7 = [40 x i8] c"Number of signature matches found: %d\0A\00"
@.str.8 = [42 x i8] c"Total number of bytes in hex string: %d\0A\00"
@.str.9 = [33 x i8] c"Block size of each buffer: %ld\0A\00"
@.str.10 = [33 x i8] c"Number of buffers searched: %d\0A\00"
@str = [10 x i8] c"Results:\0A\00"
@str.11 = [20 x i8] c"\0A\0AQuick statistics:\00"
@str.12 = [22 x i8] c"=====================\00"
define void @hxsearch(i32* %0, i8* %1, i64 %2, i64 %3) {
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%8 = alloca i8, i64 %3
%9 = bitcast i32* %6 to i8*
%10 = tail call i32 @strlen(i8* %1)
%11 = tail call i64 @getfilesize(i32* %0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %1)
%13 = call i32 @sscanf(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %28
15: ; preds = %4, %15
%16 = phi i64 [ %21, %15 ], [ 0, %4 ]
%17 = phi i64 [ %22, %15 ], [ 0, %4 ]
%18 = load i32, i32* %6
%19 = trunc i32 %18 to i8
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %17
store i8 %19, i8* %20
%21 = add nuw nsw i64 %16, 2
%22 = add nuw i64 %17, 1
%23 = getelementptr inbounds i8, i8* %1, i64 %21
%24 = call i32 @sscanf(i8* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%25 = icmp eq i32 %24, 1
br i1 %25, label %15, label %26
26: ; preds = %15
%27 = trunc i64 %22 to i32
br label %28
28: ; preds = %26, %4
%29 = phi i32 [ 0, %4 ], [ %27, %26 ]
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%31 = trunc i64 %3 to i32
%32 = call i32 @fread(i8* %8, i32 1, i32 %31, i32* %0)
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %75
34: ; preds = %28
%35 = add nsw i32 %29, -1
br label %36
36: ; preds = %69, %34
%37 = phi i32 [ %32, %34 ], [ %73, %69 ]
%38 = phi i32 [ 0, %34 ], [ %64, %69 ]
%39 = phi i64 [ 0, %34 ], [ %66, %69 ]
%40 = phi i32 [ 0, %34 ], [ %63, %69 ]
%41 = phi i32 [ 0, %34 ], [ %72, %69 ]
%42 = phi i64 [ 0, %34 ], [ %71, %69 ]
%43 = trunc i64 %39 to i32
%44 = add i32 %37, %43
br label %45
45: ; preds = %36, %62
%46 = phi i32 [ %64, %62 ], [ %38, %36 ]
%47 = phi i8* [ %65, %62 ], [ %8, %36 ]
%48 = phi i64 [ %66, %62 ], [ %39, %36 ]
%49 = phi i32 [ %63, %62 ], [ %40, %36 ]
%50 = load i8, i8* %47
%51 = sext i32 %46 to i64
%52 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = icmp eq i8 %50, %53
br i1 %54, label %55, label %62
55: ; preds = %45
%56 = add nsw i32 %46, 1
%57 = icmp slt i32 %46, %35
br i1 %57, label %62, label %58
58: ; preds = %55
%59 = add i64 %48, -1
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.3, i64 0, i64 0), i8* %1, i64 %59)
%61 = add nsw i32 %49, 1
br label %62
62: ; preds = %45, %55, %58
%63 = phi i32 [ %61, %58 ], [ %49, %55 ], [ %49, %45 ]
%64 = phi i32 [ 0, %58 ], [ %56, %55 ], [ 0, %45 ]
%65 = getelementptr inbounds i8, i8* %47, i64 1
%66 = add i64 %48, 1
%67 = trunc i64 %66 to i32
%68 = icmp eq i32 %44, %67
br i1 %68, label %69, label %45
69: ; preds = %62
%70 = sext i32 %37 to i64
%71 = add nsw i64 %42, %70
%72 = add nuw nsw i32 %41, 1
%73 = call i32 @fread(i8* %8, i32 1, i32 %31, i32* %0)
%74 = icmp sgt i32 %73, 0
br i1 %74, label %36, label %75
75: ; preds = %69, %28
%76 = phi i64 [ 0, %28 ], [ %71, %69 ]
%77 = phi i32 [ 0, %28 ], [ %72, %69 ]
%78 = phi i32 [ 0, %28 ], [ %63, %69 ]
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%80 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.6, i64 0, i64 0), i64 %76)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0), i32 %78)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %29)
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i64 %3)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 %77)
%86 = call i32 @fclose(i32* %0)
%87 = call i32 @exit(i32 0)
unreachable
}