#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*/ O_RDONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int process_pattern_4_hex(char *, int *, unsigned int *, unsigned int *);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int search_hex_pattern(char *pattern, int all, const char *fname, int offset) {
  int fd;
  int ilen, i, page_count;
  unsigned int pat_le, pat_be, fdata;
  char page[(4 * 1024)];
  char mesg[(128)];
  int patt_found, patlen, patt_found_history;
  int address = -1;
  if (fname == NULL)
    return -1;
  fd = open(fname, O_RDONLY);
  if (fd < 0)
    return -1;
  lseek(fd, offset, SEEK_SET);
  patlen = process_pattern_4_hex(pattern, &ilen, &pat_le, &pat_be);
  if (patlen < 0) {
    printf(" Error: check your inputs!\n");
    return -1;
  }
  if (patlen > 8) {
    printf(" Error: this version supports < 8 char patterns only\n");
    return -1;
  }
  patt_found = 0;
  patt_found_history = 0;
  page_count = offset / (4 * 1024);
  i = offset % (4 * 1024);
  lseek(fd, page_count, SEEK_SET);
  while (read(fd, page, (4 * 1024)) > 0) {
    for (; i <= (4 * 1024); i++) {
      switch (ilen) {
      case 4:
        fdata = (unsigned int)(*((int *)(page + i)));
        break;
      case 2:
        fdata = (unsigned int)(*((short *)(page + i)));
        break;
      default:
        fdata = (unsigned int)(*((char *)(page + i)));
        break;
      }
      if (fdata == pat_le) {
        patt_found = 1;
        patt_found_history = 1;
        strcpy(mesg, "Little Endian format");
      } else if (fdata == pat_be) {
        patt_found = 1;
        patt_found_history = 1;
        strcpy(mesg, "Big Endian format");
      }
      if (patt_found == 1) {
        address = ((page_count * (4 * 1024)) + i);
        printf(" Found \'%s\' in %s at offset: \"0x%X\"\n", pattern, mesg,
               address);
        if (!all)
          goto exit_search;
        else
          patt_found = 0;
      }
    }
    page_count++;
    i = 0;
  }
  if (!patt_found_history)
    printf(" Could not find the pattern \'%s\'! \n", pattern);
exit_search:
  close(fd);
  return address;
}


x86 assembly (clang, -O0):
<search_hex_pattern>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10e0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movl   $0xffffffff,-0x10d0(%rbp)
ff ff ff
cmpq   $0x0,-0x20(%rbp)
jne    11aa <search_hex_pattern+0x3a>
movl   $0xffffffff,-0x4(%rbp)
jmp    144d <search_hex_pattern+0x2dd>
mov    -0x20(%rbp),%rdi
mov    0x2e33(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jge    11d5 <search_hex_pattern+0x65>
movl   $0xffffffff,-0x4(%rbp)
jmp    144d <search_hex_pattern+0x2dd>
mov    -0x28(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    0x2df6(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x10(%rbp),%rdi
lea    -0x2c(%rbp),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
call   1090 <process_pattern_4_hex@plt>
mov    %eax,-0x10c8(%rbp)
cmpl   $0x0,-0x10c8(%rbp)
jge    122b <search_hex_pattern+0xbb>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144d <search_hex_pattern+0x2dd>
cmpl   $0x8,-0x10c8(%rbp)
jle    1252 <search_hex_pattern+0xe2>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    144d <search_hex_pattern+0x2dd>
movl   $0x0,-0x10c4(%rbp)
movl   $0x0,-0x10cc(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x1000,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x34(%rbp),%esi
mov    0x2d49(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x28(%rbp),%edi
lea    -0x1040(%rbp),%rsi
mov    $0x1000,%edx
call   1070 <read@plt>
cmp    $0x0,%rax
jle    1418 <search_hex_pattern+0x2a8>
jmp    12b9 <search_hex_pattern+0x149>
cmpl   $0x1000,-0x30(%rbp)
jg     1403 <search_hex_pattern+0x293>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x10d4(%rbp)
sub    $0x2,%eax
je     1304 <search_hex_pattern+0x194>
jmp    12dd <search_hex_pattern+0x16d>
mov    -0x10d4(%rbp),%eax
sub    $0x4,%eax
jne    1318 <search_hex_pattern+0x1a8>
jmp    12f1 <search_hex_pattern+0x181>
movslq -0x30(%rbp),%rax
mov    -0x1040(%rbp,%rax,1),%eax
mov    %eax,-0x40(%rbp)
jmp    1327 <search_hex_pattern+0x1b7>
movslq -0x30(%rbp),%rax
movswl -0x1040(%rbp,%rax,1),%eax
ff
mov    %eax,-0x40(%rbp)
jmp    1327 <search_hex_pattern+0x1b7>
movslq -0x30(%rbp),%rax
movsbl -0x1040(%rbp,%rax,1),%eax
ff
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x38(%rbp),%eax
jne    135f <search_hex_pattern+0x1ef>
movl   $0x1,-0x10c4(%rbp)
movl   $0x1,-0x10cc(%rbp)
lea    -0x10c0(%rbp),%rdi
lea    0xcfd(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1397 <search_hex_pattern+0x227>
mov    -0x40(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jne    1392 <search_hex_pattern+0x222>
movl   $0x1,-0x10c4(%rbp)
movl   $0x1,-0x10cc(%rbp)
lea    -0x10c0(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1397 <search_hex_pattern+0x227>
cmpl   $0x1,-0x10c4(%rbp)
jne    13f0 <search_hex_pattern+0x280>
mov    -0x34(%rbp),%eax
shl    $0xc,%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x10d0(%rbp)
mov    -0x10(%rbp),%rsi
lea    -0x10c0(%rbp),%rdx
mov    -0x10d0(%rbp),%ecx
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    13e1 <search_hex_pattern+0x271>
jmp    143c <search_hex_pattern+0x2cc>
movl   $0x0,-0x10c4(%rbp)
jmp    13f0 <search_hex_pattern+0x280>
jmp    13f5 <search_hex_pattern+0x285>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12b9 <search_hex_pattern+0x149>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    1296 <search_hex_pattern+0x126>
cmpl   $0x0,-0x10cc(%rbp)
jne    1437 <search_hex_pattern+0x2c7>
mov    -0x10(%rbp),%rsi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    143c <search_hex_pattern+0x2cc>
mov    -0x28(%rbp),%edi
call   1060 <close@plt>
mov    -0x10d0(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<search_hex_pattern>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10a8,%rsp
mov    %esi,0x10(%rsp)
mov    $0xffffffff,%ebp
test   %rdx,%rdx
je     1379 <search_hex_pattern+0x1f9>
mov    %ecx,%r14d
mov    %rdi,%r12
mov    0x2e38(%rip),%rax
mov    (%rax),%esi
mov    %rdx,%rdi
call   1090 <open@plt>
test   %eax,%eax
js     1379 <search_hex_pattern+0x1f9>
mov    %eax,%r13d
mov    0x2e0c(%rip),%r15
mov    (%r15),%edx
mov    %eax,%edi
mov    %r14d,%esi
call   1060 <lseek@plt>
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %r12,%rdi
call   10a0 <process_pattern_4_hex@plt>
test   %eax,%eax
js     120a <search_hex_pattern+0x8a>
cmp    $0x9,%eax
jb     121b <search_hex_pattern+0x9b>
lea    0xe70(%rip),%rdi
call   1040 <puts@plt>
jmp    1379 <search_hex_pattern+0x1f9>
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
jmp    1379 <search_hex_pattern+0x1f9>
lea    0xfff(%r14),%ebp
test   %r14d,%r14d
cmovns %r14d,%ebp
mov    %ebp,%ebx
sar    $0xc,%ebx
mov    (%r15),%edx
mov    %r13d,%edi
mov    %ebx,%esi
call   1060 <lseek@plt>
lea    0xa0(%rsp),%rsi
mov    %r13d,%edi
mov    $0x1000,%edx
call   1080 <read@plt>
test   %rax,%rax
jle    135b <search_hex_pattern+0x1db>
mov    %r13d,0xc(%rsp)
and    $0xfffff000,%ebp
sub    %ebp,%r14d
movslq %r14d,%r14
shl    $0xc,%ebx
mov    $0xffffffff,%ebp
lea    0x20(%rsp),%r13
xor    %r15d,%r15d
jmp    1291 <search_hex_pattern+0x111>
nopl   0x0(%rax)
add    $0x1,%r14
cmp    $0x1001,%r14
je     1317 <search_hex_pattern+0x197>
mov    0x1c(%rsp),%eax
cmp    $0x2,%eax
je     12b0 <search_hex_pattern+0x130>
cmp    $0x4,%eax
jne    12c0 <search_hex_pattern+0x140>
mov    0xa0(%rsp,%r14,1),%eax
jmp    12c9 <search_hex_pattern+0x149>
nopl   0x0(%rax)
movswl 0xa0(%rsp,%r14,1),%eax
jmp    12c9 <search_hex_pattern+0x149>
nopl   0x0(%rax,%rax,1)
movsbl 0xa0(%rsp,%r14,1),%eax
lea    0xd30(%rip),%rsi
cmp    0x18(%rsp),%eax
je     12e3 <search_hex_pattern+0x163>
lea    0xd38(%rip),%rsi
cmp    0x14(%rsp),%eax
jne    1280 <search_hex_pattern+0x100>
mov    %r13,%rdi
call   1030 <strcpy@plt>
lea    (%rbx,%r14,1),%rbp
lea    0xd31(%rip),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x10(%rsp)
je     134f <search_hex_pattern+0x1cf>
mov    $0x1,%r15d
jmp    1280 <search_hex_pattern+0x100>
mov    0xc(%rsp),%edi
lea    0xa0(%rsp),%rsi
mov    $0x1000,%edx
call   1080 <read@plt>
add    $0x1000,%rbx
mov    $0x0,%r14d
test   %rax,%rax
jg     1291 <search_hex_pattern+0x111>
test   %r15d,%r15d
mov    0xc(%rsp),%r13d
jne    1371 <search_hex_pattern+0x1f1>
jmp    1360 <search_hex_pattern+0x1e0>
add    %r14d,%ebx
mov    %ebx,%ebp
mov    0xc(%rsp),%r13d
jmp    1371 <search_hex_pattern+0x1f1>
mov    $0xffffffff,%ebp
lea    0xce5(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13d,%edi
call   1070 <close@plt>
mov    %ebp,%eax
add    $0x10a8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
@.str = [28 x i8] c" Error: check your inputs!\0A\00"
@.str.1 = [54 x i8] c" Error: this version supports < 8 char patterns only\0A\00"
@.str.2 = [21 x i8] c"Little Endian format\00"
@.str.3 = [18 x i8] c"Big Endian format\00"
@.str.4 = [37 x i8] c" Found '%s' in %s at offset: \220x%X\22\0A\00"
@.str.5 = [36 x i8] c" Could not find the pattern '%s'! \0A\00"
define i32 @search_hex_pattern(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca [4096 x i8]
%18 = alloca [128 x i8]
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
store i32 -1, i32* %22
%23 = load i8*, i8** %8
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %26
25: ; preds = %4
store i32 -1, i32* %5
br label %141
26: ; preds = %4
%27 = load i8*, i8** %8
%28 = load i32, i32* @O_RDONLY
%29 = call i32 @open(i8* %27, i32 %28)
store i32 %29, i32* %10
%30 = load i32, i32* %10
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 -1, i32* %5
br label %141
33: ; preds = %26
%34 = load i32, i32* %10
%35 = load i32, i32* %9
%36 = load i32, i32* @SEEK_SET
%37 = call i32 @lseek(i32 %34, i32 %35, i32 %36)
%38 = load i8*, i8** %6
%39 = call i32 @process_pattern_4_hex(i8* %38, i32* %11, i32* %14, i32* %15)
store i32 %39, i32* %20
%40 = load i32, i32* %20
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %5
br label %141
44: ; preds = %33
%45 = load i32, i32* %20
%46 = icmp sgt i32 %45, 8
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %5
br label %141
49: ; preds = %44
store i32 0, i32* %19
store i32 0, i32* %21
%50 = load i32, i32* %9
%51 = sdiv i32 %50, 4096
store i32 %51, i32* %13
%52 = load i32, i32* %9
%53 = srem i32 %52, 4096
store i32 %53, i32* %12
%54 = load i32, i32* %10
%55 = load i32, i32* %13
%56 = load i32, i32* @SEEK_SET
%57 = call i32 @lseek(i32 %54, i32 %55, i32 %56)
br label %58
58: ; preds = %127, %49
%59 = load i32, i32* %10
%60 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%61 = call i64 @read(i32 %59, i8* %60, i32 4096)
%62 = icmp sgt i64 %61, 0
br i1 %62, label %63, label %130
63: ; preds = %58
br label %64
64: ; preds = %124, %63
%65 = load i32, i32* %12
%66 = icmp sle i32 %65, 4096
br i1 %66, label %67, label %127
67: ; preds = %64
%68 = load i32, i32* %11
switch i32 %68, label %84 [
i32 4, label %69
i32 2, label %76
]
69: ; preds = %67
%70 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%71 = load i32, i32* %12
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %70, i64 %72
%74 = bitcast i8* %73 to i32*
%75 = load i32, i32* %74
store i32 %75, i32* %16
br label %91
76: ; preds = %67
%77 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%78 = load i32, i32* %12
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %77, i64 %79
%81 = bitcast i8* %80 to i16*
%82 = load i16, i16* %81
%83 = sext i16 %82 to i32
store i32 %83, i32* %16
br label %91
84: ; preds = %67
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %17, i64 0, i64 0
%86 = load i32, i32* %12
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i8, i8* %85, i64 %87
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
store i32 %90, i32* %16
br label %91
91: ; preds = %84, %76, %69
%92 = load i32, i32* %16
%93 = load i32, i32* %14
%94 = icmp eq i32 %92, %93
br i1 %94, label %95, label %98
95: ; preds = %91
store i32 1, i32* %19
store i32 1, i32* %21
%96 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%97 = call i32 @strcpy(i8* %96, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %106
98: ; preds = %91
%99 = load i32, i32* %16
%100 = load i32, i32* %15
%101 = icmp eq i32 %99, %100
br i1 %101, label %102, label %105
102: ; preds = %98
store i32 1, i32* %19
store i32 1, i32* %21
%103 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%104 = call i32 @strcpy(i8* %103, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %105
105: ; preds = %102, %98
br label %106
106: ; preds = %105, %95
%107 = load i32, i32* %19
%108 = icmp eq i32 %107, 1
br i1 %108, label %109, label %123
109: ; preds = %106
%110 = load i32, i32* %13
%111 = mul nsw i32 %110, 4096
%112 = load i32, i32* %12
%113 = add nsw i32 %111, %112
store i32 %113, i32* %22
%114 = load i8*, i8** %6
%115 = getelementptr inbounds [128 x i8], [128 x i8]* %18, i64 0, i64 0
%116 = load i32, i32* %22
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %114, i8* %115, i32 %116)
%118 = load i32, i32* %7
%119 = icmp ne i32 %118, 0
br i1 %119, label %121, label %120
120: ; preds = %109
br label %137
121: ; preds = %109
store i32 0, i32* %19
br label %122
122: ; preds = %121
br label %123
123: ; preds = %122, %106
br label %124
124: ; preds = %123
%125 = load i32, i32* %12
%126 = add nsw i32 %125, 1
store i32 %126, i32* %12
br label %64
127: ; preds = %64
%128 = load i32, i32* %13
%129 = add nsw i32 %128, 1
store i32 %129, i32* %13
store i32 0, i32* %12
br label %58
130: ; preds = %58
%131 = load i32, i32* %21
%132 = icmp ne i32 %131, 0
br i1 %132, label %136, label %133
133: ; preds = %130
%134 = load i8*, i8** %6
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %134)
br label %136
136: ; preds = %133, %130
br label %137
137: ; preds = %136, %120
%138 = load i32, i32* %10
%139 = call i32 @close(i32 %138)
%140 = load i32, i32* %22
store i32 %140, i32* %5
br label %141
141: ; preds = %137, %47, %42, %32, %25
%142 = load i32, i32* %5
ret i32 %142
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@SEEK_SET = global i32 0
@.str.2 = [21 x i8] c"Little Endian format\00"
@.str.3 = [18 x i8] c"Big Endian format\00"
@.str.4 = [37 x i8] c" Found '%s' in %s at offset: \220x%X\22\0A\00"
@.str.5 = [36 x i8] c" Could not find the pattern '%s'! \0A\00"
@str = [53 x i8] c" Error: this version supports < 8 char patterns only\00"
@str.6 = [27 x i8] c" Error: check your inputs!\00"
define i32 @search_hex_pattern(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4096 x i8]
%9 = alloca [128 x i8]
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 0
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%15 = icmp eq i8* %2, null
br i1 %15, label %98, label %16
16: ; preds = %4
%17 = load i32, i32* @O_RDONLY
%18 = tail call i32 @open(i8* %2, i32 %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %98, label %20
20: ; preds = %16
%21 = load i32, i32* @SEEK_SET
%22 = tail call i32 @lseek(i32 %18, i32 %3, i32 %21)
%23 = call i32 @process_pattern_4_hex(i8* %0, i32* %5, i32* %6, i32* %7)
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.6, i64 0, i64 0))
br label %98
27: ; preds = %20
%28 = icmp ugt i32 %23, 8
br i1 %28, label %29, label %31
29: ; preds = %27
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
br label %98
31: ; preds = %27
%32 = sdiv i32 %3, 4096
%33 = srem i32 %3, 4096
%34 = load i32, i32* @SEEK_SET
%35 = call i32 @lseek(i32 %18, i32 %32, i32 %34)
%36 = call i64 @read(i32 %18, i8* %13, i32 4096)
%37 = icmp sgt i64 %36, 0
br i1 %37, label %38, label %90
38: ; preds = %31
%39 = icmp eq i32 %1, 0
%40 = zext i32 %32 to i64
%41 = sext i32 %33 to i64
br label %42
42: ; preds = %38, %84
%43 = phi i64 [ %40, %38 ], [ %85, %84 ]
%44 = phi i32 [ -1, %38 ], [ %81, %84 ]
%45 = phi i32 [ 0, %38 ], [ %80, %84 ]
%46 = phi i64 [ %41, %38 ], [ 0, %84 ]
%47 = shl i64 %43, 12
br label %48
48: ; preds = %42, %79
%49 = phi i64 [ %46, %42 ], [ %82, %79 ]
%50 = phi i32 [ %44, %42 ], [ %81, %79 ]
%51 = phi i32 [ %45, %42 ], [ %80, %79 ]
%52 = load i32, i32* %5
switch i32 %52, label %62 [
i32 4, label %53
i32 2, label %57
]
53: ; preds = %48
%54 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %49
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %55
br label %66
57: ; preds = %48
%58 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %49
%59 = bitcast i8* %58 to i16*
%60 = load i16, i16* %59
%61 = sext i16 %60 to i32
br label %66
62: ; preds = %48
%63 = getelementptr inbounds [4096 x i8], [4096 x i8]* %8, i64 0, i64 %49
%64 = load i8, i8* %63
%65 = sext i8 %64 to i32
br label %66
66: ; preds = %62, %57, %53
%67 = phi i32 [ %65, %62 ], [ %61, %57 ], [ %56, %53 ]
%68 = load i32, i32* %6
%69 = icmp eq i32 %67, %68
br i1 %69, label %73, label %70
70: ; preds = %66
%71 = load i32, i32* %7
%72 = icmp eq i32 %67, %71
br i1 %72, label %73, label %79
73: ; preds = %70, %66
%74 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %66 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), %70 ]
%75 = call i32 @strcpy(i8* %14, i8* %74)
%76 = add i64 %49, %47
%77 = trunc i64 %76 to i32
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %0, i8* %14, i32 %77)
br i1 %39, label %93, label %79
79: ; preds = %70, %73
%80 = phi i32 [ 1, %73 ], [ %51, %70 ]
%81 = phi i32 [ %77, %73 ], [ %50, %70 ]
%82 = add nsw i64 %49, 1
%83 = icmp eq i64 %82, 4097
br i1 %83, label %84, label %48
84: ; preds = %79
%85 = add i64 %43, 1
%86 = call i64 @read(i32 %18, i8* %13, i32 4096)
%87 = icmp sgt i64 %86, 0
br i1 %87, label %42, label %88
88: ; preds = %84
%89 = icmp eq i32 %80, 0
br i1 %89, label %90, label %95
90: ; preds = %31, %88
%91 = phi i32 [ %81, %88 ], [ -1, %31 ]
%92 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %0)
br label %95
93: ; preds = %73
%94 = trunc i64 %76 to i32
br label %95
95: ; preds = %93, %88, %90
%96 = phi i32 [ %81, %88 ], [ %91, %90 ], [ %94, %93 ]
%97 = call i32 @close(i32 %18)
br label %98
98: ; preds = %16, %4, %95, %29, %25
%99 = phi i32 [ -1, %25 ], [ -1, %29 ], [ %96, %95 ], [ -1, %4 ], [ -1, %16 ]
ret i32 %99
}