#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 */
struct stat {
  int st_size;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
char *malloc(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int, char *, int);
int stat(char *, struct stat *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  int f1, f2, r, size, size2, x, y;
  char *buff, *lookfor;
  struct stat sbuff;
  int outfmt = 0;
  if (argc != 3 && argc != 4) {
    printf("Usage: %s file1 file2 [-h]\nReturns the address of the occurences "
           "of the contents of file2 in file1. -h makes it return the address "
           "in hex instead of dec.\n",
           argv[0]);
    exit(0);
  }
  if (argc == 4) {
    if (strcmp(argv[3], "-h") == 0) {
      outfmt = 1;
    } else {
      printf("Invalid switch %s\n", argv[3]);
      exit(1);
    }
  }
  r = stat(argv[1], &sbuff);
  if (r != 0) {
    perror("Couldn't stat file1.\n");
    exit(1);
  }
  size = sbuff.st_size;
  buff = malloc(size);
  if (buff == NULL) {
    perror("Couldn't malloc bytes for file1.\n");
  }
  r = stat(argv[2], &sbuff);
  if (r != 0) {
    perror("Couldn't stat file2.\n");
    exit(1);
  }
  size2 = sbuff.st_size;
  lookfor = malloc(size2);
  if (lookfor == NULL) {
    perror("Couldn't malloc bytes for file2.\n");
  }
  f1 = open(argv[1], O_RDONLY);
  if (f1 < 0) {
    perror("Couldn't open file1.\n");
    exit(1);
  }
  read(f1, buff, size);
  close(f1);
  f2 = open(argv[2], O_RDONLY);
  if (f2 < 0) {
    perror("Couldn't open file2.\n");
    exit(1);
  }
  read(f2, lookfor, size2);
  close(f2);
  for (x = 0; x < (size - size2); x++) {
    y = 0;
    while (y < size2 && buff[x + y] == lookfor[y]) {
      y++;
    }
    if (y == size2) {
      if (outfmt == 1) {
        printf("%04x\n", x);
      } else {
        printf("%i\n", x);
      }
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11dd <main+0x4d>
cmpl   $0x4,-0x8(%rbp)
je     11dd <main+0x4d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
cmpl   $0x4,-0x8(%rbp)
jne    1236 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xea5(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1211 <main+0x81>
movl   $0x1,-0x4c(%rbp)
jmp    1231 <main+0xa1>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    1236 <main+0xa6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1070 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     126a <main+0xda>
lea    0xe56(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    1293 <main+0x103>
lea    0xe39(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x48(%rbp),%rsi
call   1070 <stat@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     12c7 <main+0x137>
lea    0xe31(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x48(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1080 <malloc@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    12f0 <main+0x160>
lea    0xe14(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2ce9(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1329 <main+0x199>
lea    0xe07(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x20(%rbp),%edx
call   1050 <read@plt>
mov    -0x14(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2c99(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1379 <main+0x1e9>
lea    0xdcd(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x18(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <read@plt>
mov    -0x18(%rbp),%edi
call   1040 <close@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    -0x24(%rbp),%ecx
cmp    %ecx,%eax
jge    1458 <main+0x2c8>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x4d(%rbp)
jge    13e5 <main+0x255>
mov    -0x38(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    -0x2c(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
mov    -0x40(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x4d(%rbp)
mov    -0x4d(%rbp),%al
test   $0x1,%al
jne    13f5 <main+0x265>
jmp    1403 <main+0x273>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    13af <main+0x21f>
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jne    1445 <main+0x2b5>
cmpl   $0x1,-0x4c(%rbp)
jne    142f <main+0x29f>
mov    -0x28(%rbp),%esi
lea    0xd2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1440 <main+0x2b0>
mov    -0x28(%rbp),%esi
lea    0xd1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1445 <main+0x2b5>
jmp    144a <main+0x2ba>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1397 <main+0x207>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %edi,%r14d
lea    -0x5(%r14),%eax
cmp    $0xfffffffd,%eax
ja     11c3 <main+0x33>
mov    0x0(%r13),%rsi
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
cmp    $0x4,%r14d
jne    11e2 <main+0x52>
mov    0x18(%r13),%rdi
lea    0xec7(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    126c <main+0xdc>
mov    0x8(%r13),%rdi
mov    %rsp,%rsi
call   1070 <stat@plt>
test   %eax,%eax
jne    1263 <main+0xd3>
mov    (%rsp),%ebp
mov    %ebp,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1210 <main+0x80>
lea    0xebc(%rip),%rdi
call   10a0 <perror@plt>
mov    0x10(%r13),%rdi
mov    %rsp,%rsi
call   1070 <stat@plt>
test   %eax,%eax
jne    1288 <main+0xf8>
mov    %ebp,0x4(%rsp)
mov    (%rsp),%r15d
mov    %r15d,%edi
call   1080 <malloc@plt>
mov    %rax,%r12
test   %rax,%rax
jne    1244 <main+0xb4>
lea    0xec0(%rip),%rdi
call   10a0 <perror@plt>
mov    0x8(%r13),%rdi
mov    0x2d99(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
test   %eax,%eax
jns    129e <main+0x10e>
lea    0xec0(%rip),%rdi
jmp    128f <main+0xff>
lea    0xe47(%rip),%rdi
jmp    128f <main+0xff>
mov    0x18(%r13),%rsi
lea    0xe27(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe5a(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    0x4(%rsp),%edx
call   1050 <read@plt>
mov    %ebp,%edi
call   1040 <close@plt>
mov    0x10(%r13),%rdi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
test   %eax,%eax
jns    12d4 <main+0x144>
lea    0xe65(%rip),%rdi
jmp    128f <main+0xff>
mov    %eax,%r13d
mov    %eax,%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   1050 <read@plt>
mov    %r13d,%edi
call   1040 <close@plt>
mov    0x4(%rsp),%eax
sub    %r15d,%eax
test   %eax,%eax
jle    1377 <main+0x1e7>
cmp    $0x4,%r14d
mov    %eax,%r13d
lea    0xe44(%rip),%rax
lea    0xe43(%rip),%r14
cmove  %rax,%r14
xor    %ebp,%ebp
jmp    1339 <main+0x1a9>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
add    $0x1,%rbx
cmp    %r13,%rbp
je     1377 <main+0x1e7>
mov    $0x0,%eax
test   %r15d,%r15d
jle    1370 <main+0x1e0>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx,%rax,1),%ecx
cmp    (%r12,%rax,1),%cl
jne    1370 <main+0x1e0>
add    $0x1,%rax
cmp    %rax,%r15
jne    1350 <main+0x1c0>
jmp    1320 <main+0x190>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    %r15d,%eax
je     1320 <main+0x190>
jmp    132c <main+0x19c>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [155 x i8] c"Usage: %s file1 file2 [-h]\0AReturns the address of the occurences of the contents of file2 in file1. -h makes it return the address in hex instead of dec.\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [19 x i8] c"Invalid switch %s\0A\00"
@.str.3 = [22 x i8] c"Couldn't stat file1.\0A\00"
@.str.4 = [34 x i8] c"Couldn't malloc bytes for file1.\0A\00"
@.str.5 = [22 x i8] c"Couldn't stat file2.\0A\00"
@.str.6 = [34 x i8] c"Couldn't malloc bytes for file2.\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [22 x i8] c"Couldn't open file1.\0A\00"
@.str.8 = [22 x i8] c"Couldn't open file2.\0A\00"
@.str.9 = [6 x i8] c"%04x\0A\00"
@.str.10 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca %struct.stat
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %16
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %28
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 4
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([155 x i8], [155 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 0)
unreachable
28: ; preds = %19, %2
%29 = load i32, i32* %4
%30 = icmp eq i32 %29, 4
br i1 %30, label %31, label %45
31: ; preds = %28
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %31
store i32 1, i32* %16
br label %44
38: ; preds = %31
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %37
br label %45
45: ; preds = %44, %28
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 1
%48 = load i8*, i8** %47
%49 = call i32 @stat(i8* %48, %struct.stat* %15)
store i32 %49, i32* %8
%50 = load i32, i32* %8
%51 = icmp ne i32 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %45
%53 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @exit(i32 1)
unreachable
55: ; preds = %45
%56 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%57 = load i32, i32* %56
store i32 %57, i32* %9
%58 = load i32, i32* %9
%59 = call i8* @malloc(i32 %58)
store i8* %59, i8** %13
%60 = load i8*, i8** %13
%61 = icmp eq i8* %60, null
br i1 %61, label %62, label %64
62: ; preds = %55
%63 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %64
64: ; preds = %62, %55
%65 = load i8**, i8*** %5
%66 = getelementptr inbounds i8*, i8** %65, i64 2
%67 = load i8*, i8** %66
%68 = call i32 @stat(i8* %67, %struct.stat* %15)
store i32 %68, i32* %8
%69 = load i32, i32* %8
%70 = icmp ne i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %64
%72 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %64
%75 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%76 = load i32, i32* %75
store i32 %76, i32* %10
%77 = load i32, i32* %10
%78 = call i8* @malloc(i32 %77)
store i8* %78, i8** %14
%79 = load i8*, i8** %14
%80 = icmp eq i8* %79, null
br i1 %80, label %81, label %83
81: ; preds = %74
%82 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %83
83: ; preds = %81, %74
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 1
%86 = load i8*, i8** %85
%87 = load i32, i32* @O_RDONLY
%88 = call i32 @open(i8* %86, i32 %87)
store i32 %88, i32* %6
%89 = load i32, i32* %6
%90 = icmp slt i32 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %83
%92 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%93 = call i32 @exit(i32 1)
unreachable
94: ; preds = %83
%95 = load i32, i32* %6
%96 = load i8*, i8** %13
%97 = load i32, i32* %9
%98 = call i32 @read(i32 %95, i8* %96, i32 %97)
%99 = load i32, i32* %6
%100 = call i32 @close(i32 %99)
%101 = load i8**, i8*** %5
%102 = getelementptr inbounds i8*, i8** %101, i64 2
%103 = load i8*, i8** %102
%104 = load i32, i32* @O_RDONLY
%105 = call i32 @open(i8* %103, i32 %104)
store i32 %105, i32* %7
%106 = load i32, i32* %7
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %111
108: ; preds = %94
%109 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %94
%112 = load i32, i32* %7
%113 = load i8*, i8** %14
%114 = load i32, i32* %10
%115 = call i32 @read(i32 %112, i8* %113, i32 %114)
%116 = load i32, i32* %7
%117 = call i32 @close(i32 %116)
store i32 0, i32* %11
br label %118
118: ; preds = %165, %111
%119 = load i32, i32* %11
%120 = load i32, i32* %9
%121 = load i32, i32* %10
%122 = sub nsw i32 %120, %121
%123 = icmp slt i32 %119, %122
br i1 %123, label %124, label %168
124: ; preds = %118
store i32 0, i32* %12
br label %125
125: ; preds = %147, %124
%126 = load i32, i32* %12
%127 = load i32, i32* %10
%128 = icmp slt i32 %126, %127
br i1 %128, label %129, label %145
129: ; preds = %125
%130 = load i8*, i8** %13
%131 = load i32, i32* %11
%132 = load i32, i32* %12
%133 = add nsw i32 %131, %132
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds i8, i8* %130, i64 %134
%136 = load i8, i8* %135
%137 = sext i8 %136 to i32
%138 = load i8*, i8** %14
%139 = load i32, i32* %12
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i8, i8* %138, i64 %140
%142 = load i8, i8* %141
%143 = sext i8 %142 to i32
%144 = icmp eq i32 %137, %143
br label %145
145: ; preds = %129, %125
%146 = phi i1 [ false, %125 ], [ %144, %129 ]
br i1 %146, label %147, label %150
147: ; preds = %145
%148 = load i32, i32* %12
%149 = add nsw i32 %148, 1
store i32 %149, i32* %12
br label %125
150: ; preds = %145
%151 = load i32, i32* %12
%152 = load i32, i32* %10
%153 = icmp eq i32 %151, %152
br i1 %153, label %154, label %164
154: ; preds = %150
%155 = load i32, i32* %16
%156 = icmp eq i32 %155, 1
br i1 %156, label %157, label %160
157: ; preds = %154
%158 = load i32, i32* %11
%159 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %158)
br label %163
160: ; preds = %154
%161 = load i32, i32* %11
%162 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %161)
br label %163
163: ; preds = %160, %157
br label %164
164: ; preds = %163, %150
br label %165
165: ; preds = %164
%166 = load i32, i32* %11
%167 = add nsw i32 %166, 1
store i32 %167, i32* %11
br label %118
168: ; preds = %118
%169 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [155 x i8] c"Usage: %s file1 file2 [-h]\0AReturns the address of the occurences of the contents of file2 in file1. -h makes it return the address in hex instead of dec.\0A\00"
@.str.1 = [3 x i8] c"-h\00"
@.str.2 = [19 x i8] c"Invalid switch %s\0A\00"
@.str.3 = [22 x i8] c"Couldn't stat file1.\0A\00"
@.str.4 = [34 x i8] c"Couldn't malloc bytes for file1.\0A\00"
@.str.5 = [22 x i8] c"Couldn't stat file2.\0A\00"
@.str.6 = [34 x i8] c"Couldn't malloc bytes for file2.\0A\00"
@O_RDONLY = global i32 0
@.str.7 = [22 x i8] c"Couldn't open file1.\0A\00"
@.str.8 = [22 x i8] c"Couldn't open file2.\0A\00"
@.str.9 = [6 x i8] c"%04x\0A\00"
@.str.10 = [4 x i8] c"%i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = add i32 %0, -5
%6 = icmp ult i32 %5, -2
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([155 x i8], [155 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 0)
unreachable
11: ; preds = %2
%12 = icmp eq i32 %0, 4
br i1 %12, label %13, label %22
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %13
%19 = load i8*, i8** %14
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %13, %11
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @stat(i8* %24, %struct.stat* %3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %30, label %27
27: ; preds = %22
%28 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %22
%31 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%32 = load i32, i32* %31
%33 = tail call i8* @malloc(i32 %32)
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %30
%38 = getelementptr inbounds i8*, i8** %1, i64 2
%39 = load i8*, i8** %38
%40 = call i32 @stat(i8* %39, %struct.stat* %3)
%41 = icmp eq i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %37
%43 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %37
%46 = load i32, i32* %31
%47 = tail call i8* @malloc(i32 %46)
%48 = icmp eq i8* %47, null
br i1 %48, label %49, label %51
49: ; preds = %45
%50 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %51
51: ; preds = %49, %45
%52 = load i8*, i8** %23
%53 = load i32, i32* @O_RDONLY
%54 = tail call i32 @open(i8* %52, i32 %53)
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %51
%57 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%58 = tail call i32 @exit(i32 1)
unreachable
59: ; preds = %51
%60 = tail call i32 @read(i32 %54, i8* %33, i32 %32)
%61 = tail call i32 @close(i32 %54)
%62 = load i8*, i8** %38
%63 = load i32, i32* @O_RDONLY
%64 = tail call i32 @open(i8* %62, i32 %63)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0))
%68 = tail call i32 @exit(i32 1)
unreachable
69: ; preds = %59
%70 = tail call i32 @read(i32 %64, i8* %47, i32 %46)
%71 = tail call i32 @close(i32 %64)
%72 = sub i32 %32, %46
%73 = icmp sgt i32 %72, 0
br i1 %73, label %74, label %103
74: ; preds = %69
%75 = icmp sgt i32 %46, 0
%76 = zext i32 %72 to i64
%77 = zext i32 %46 to i64
%78 = select i1 %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0)
br label %79
79: ; preds = %74, %100
%80 = phi i64 [ 0, %74 ], [ %101, %100 ]
br i1 %75, label %81, label %94
81: ; preds = %79, %89
%82 = phi i64 [ %90, %89 ], [ 0, %79 ]
%83 = add nuw nsw i64 %82, %80
%84 = getelementptr inbounds i8, i8* %33, i64 %83
%85 = load i8, i8* %84
%86 = getelementptr inbounds i8, i8* %47, i64 %82
%87 = load i8, i8* %86
%88 = icmp eq i8 %85, %87
br i1 %88, label %89, label %92
89: ; preds = %81
%90 = add nuw nsw i64 %82, 1
%91 = icmp eq i64 %90, %77
br i1 %91, label %97, label %81
92: ; preds = %81
%93 = trunc i64 %82 to i32
br label %94
94: ; preds = %92, %79
%95 = phi i32 [ 0, %79 ], [ %93, %92 ]
%96 = icmp eq i32 %95, %46
br i1 %96, label %97, label %100
97: ; preds = %89, %94
%98 = trunc i64 %80 to i32
%99 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %78, i32 %98)
br label %100
100: ; preds = %97, %94
%101 = add nuw nsw i64 %80, 1
%102 = icmp eq i64 %101, %76
br i1 %102, label %103, label %79
103: ; preds = %100, %69
%104 = tail call i32 @exit(i32 0)
unreachable
}