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

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fileno(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fstat(int, struct stat *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
char *memmem(char *, int, char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *imgFileName = argv[1];
  char *archFileName = argv[2];
  char *inFileName = argv[3];
  char *inFileBuffer;
  char endChars[] = {'\xFF', '\xD9'};
  char *imgEnd;
  FILE *imgFile, *archFile, *inFile;
  struct stat inFileStats;
  int iFD, tempSize;
  if (argc != 4) {
    fprintf(stderr, "Usage: %s <jpgFileName> <archiveFileName> <inFileName>\n",
            argv[0]);
    exit(0);
  }
  imgFile = fopen(imgFileName, "w");
  if (imgFile == NULL) {
    perror("Couldn't open file");
    exit(1);
  }
  archFile = fopen(archFileName, "w");
  if (archFile == NULL) {
    perror("Couldn't open file");
    fclose(imgFile);
    exit(2);
  }
  inFile = fopen(inFileName, "r");
  if (inFile == NULL) {
    perror("Couldn't open file");
    fclose(imgFile);
    fclose(archFile);
    exit(3);
  }
  iFD = fileno(inFile);
  fstat(iFD, &inFileStats);
  printf("File size: %ld\n", inFileStats.st_size);
  inFileBuffer = (char *)malloc(inFileStats.st_size * sizeof(char));
  fread(inFileBuffer, inFileStats.st_size, 1, inFile);
  fclose(inFile);
  imgEnd = memmem(inFileBuffer, inFileStats.st_size, endChars, 2);
  if (imgEnd == NULL) {
    fprintf(stderr, "Couldn't find the guard bytes. Exiting...\n");
    free(inFileBuffer);
    fclose(imgFile);
    fclose(archFile);
    exit(4);
  }
  printf("We found the bytes. Processing...\n");
  imgEnd += 2;
  tempSize = imgEnd - inFileBuffer;
  fwrite(inFileBuffer, tempSize, 1, imgFile);
  fclose(imgFile);
  fwrite(imgEnd, inFileStats.st_size - tempSize, 1, archFile);
  fclose(archFile);
  printf("Operations successful\n");
  free(inFileBuffer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0xdef(%rip),%ax
mov    %ax,-0x32(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1244 <main+0x74>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1279 <main+0xa9>
lea    0xdd2(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x20(%rbp),%rdi
lea    0xdb6(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12b7 <main+0xe7>
lea    0xd9d(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x2,%edi
call   10d0 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x58(%rbp)
jne    12fe <main+0x12e>
lea    0xd5f(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x3,%edi
call   10d0 <exit@plt>
mov    -0x58(%rbp),%rdi
call   1090 <fileno@plt>
mov    %eax,-0x64(%rbp)
mov    -0x64(%rbp),%edi
lea    -0x60(%rbp),%rsi
call   10f0 <fstat@plt>
mov    -0x60(%rbp),%esi
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movslq -0x60(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x60(%rbp),%esi
mov    -0x58(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x58(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x30(%rbp),%rdi
mov    -0x60(%rbp),%esi
lea    -0x32(%rbp),%rdx
mov    $0x2,%ecx
call   1080 <memmem@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13b8 <main+0x1e8>
mov    0x2c5d(%rip),%rax
mov    (%rax),%edi
lea    0xcd5(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
mov    $0x4,%edi
call   10d0 <exit@plt>
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x40(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x30(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x68(%rbp),%esi
mov    -0x48(%rbp),%rcx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x40(%rbp),%rdi
mov    -0x60(%rbp),%esi
sub    -0x68(%rbp),%esi
mov    -0x50(%rbp),%rcx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    -0x50(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xc89(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x70,%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    %edi,%eax
mov    0x8(%rsi),%rdi
mov    0x10(%rsi),%rbp
mov    0x18(%rsi),%rbx
movw   $0xd9ff,0xe(%rsp)
cmp    $0x4,%eax
jne    133d <main+0x15d>
lea    0xe25(%rip),%rsi
call   10c0 <fopen@plt>
test   %rax,%rax
je     135e <main+0x17e>
mov    %rax,%r15
lea    0xe0d(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1374 <main+0x194>
mov    %rax,%r14
lea    0xe07(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     1392 <main+0x1b2>
mov    %rax,%rbx
mov    %rax,%rdi
call   10a0 <fileno@plt>
lea    0x10(%rsp),%rsi
mov    %eax,%edi
call   1100 <fstat@plt>
mov    0x10(%rsp),%r13d
lea    0xdd5(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13d,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
lea    0xe(%rsp),%rdx
mov    %r12,%rdi
mov    %r13d,%esi
mov    $0x2,%ecx
call   1090 <memmem@plt>
test   %rax,%rax
je     13b8 <main+0x1d8>
mov    %rax,%rbx
lea    0xdb8(%rip),%rdi
call   1040 <puts@plt>
add    $0x2,%rbx
mov    %ebx,%ebp
sub    %r12d,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   10f0 <fwrite@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
sub    %ebp,%r13d
mov    %rbx,%rdi
mov    %r13d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   10f0 <fwrite@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
lea    0xd8d(%rip),%rdi
call   1040 <puts@plt>
mov    %r12,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xcb0(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    0xcd5(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xcbf(%rip),%rdi
call   10d0 <perror@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    $0x2,%edi
call   10e0 <exit@plt>
lea    0xca1(%rip),%rdi
call   10d0 <perror@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    $0x3,%edi
call   10e0 <exit@plt>
mov    0x2c21(%rip),%rax
mov    (%rax),%edi
lea    0xc97(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r12,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    $0x4,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@__const.main.endChars = [2 x i8] c"\FF\D9"
@stderr = global i32 0
@.str = [56 x i8] c"Usage: %s <jpgFileName> <archiveFileName> <inFileName>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [19 x i8] c"Couldn't open file\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [16 x i8] c"File size: %ld\0A\00"
@.str.5 = [43 x i8] c"Couldn't find the guard bytes. Exiting...\0A\00"
@.str.6 = [35 x i8] c"We found the bytes. Processing...\0A\00"
@.str.7 = [23 x i8] c"Operations successful\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca [2 x i8]
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca %struct.stat
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %7
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
store i8* %26, i8** %8
%27 = bitcast [2 x i8]* %10 to i8*
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 4
br i1 %29, label %30, label %37
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %2
%38 = load i8*, i8** %6
%39 = call i32* @fopen(i8* %38, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %39, i32** %12
%40 = load i32*, i32** %12
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %37
%46 = load i8*, i8** %7
%47 = call i32* @fopen(i8* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %47, i32** %13
%48 = load i32*, i32** %13
%49 = icmp eq i32* %48, null
br i1 %49, label %50, label %55
50: ; preds = %45
%51 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%52 = load i32*, i32** %12
%53 = call i32 @fclose(i32* %52)
%54 = call i32 @exit(i32 2)
unreachable
55: ; preds = %45
%56 = load i8*, i8** %8
%57 = call i32* @fopen(i8* %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %57, i32** %14
%58 = load i32*, i32** %14
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %67
60: ; preds = %55
%61 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%62 = load i32*, i32** %12
%63 = call i32 @fclose(i32* %62)
%64 = load i32*, i32** %13
%65 = call i32 @fclose(i32* %64)
%66 = call i32 @exit(i32 3)
unreachable
67: ; preds = %55
%68 = load i32*, i32** %14
%69 = call i32 @fileno(i32* %68)
store i32 %69, i32* %16
%70 = load i32, i32* %16
%71 = call i32 @fstat(i32 %70, %struct.stat* %15)
%72 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%73 = load i32, i32* %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %73)
%75 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%76 = load i32, i32* %75
%77 = sext i32 %76 to i64
%78 = mul i64 %77, 1
%79 = trunc i64 %78 to i32
%80 = call i64 @malloc(i32 %79)
%81 = inttoptr i64 %80 to i8*
store i8* %81, i8** %9
%82 = load i8*, i8** %9
%83 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%84 = load i32, i32* %83
%85 = load i32*, i32** %14
%86 = call i32 @fread(i8* %82, i32 %84, i32 1, i32* %85)
%87 = load i32*, i32** %14
%88 = call i32 @fclose(i32* %87)
%89 = load i8*, i8** %9
%90 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%91 = load i32, i32* %90
%92 = getelementptr inbounds [2 x i8], [2 x i8]* %10, i64 0, i64 0
%93 = call i8* @memmem(i8* %89, i32 %91, i8* %92, i32 2)
store i8* %93, i8** %11
%94 = load i8*, i8** %11
%95 = icmp eq i8* %94, null
br i1 %95, label %96, label %106
96: ; preds = %67
%97 = load i32, i32* @stderr
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%99 = load i8*, i8** %9
%100 = call i32 @free(i8* %99)
%101 = load i32*, i32** %12
%102 = call i32 @fclose(i32* %101)
%103 = load i32*, i32** %13
%104 = call i32 @fclose(i32* %103)
%105 = call i32 @exit(i32 4)
unreachable
106: ; preds = %67
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0))
%108 = load i8*, i8** %11
%109 = getelementptr inbounds i8, i8* %108, i64 2
store i8* %109, i8** %11
%110 = load i8*, i8** %11
%111 = load i8*, i8** %9
%112 = ptrtoint i8* %110 to i64
%113 = ptrtoint i8* %111 to i64
%114 = sub i64 %112, %113
%115 = trunc i64 %114 to i32
store i32 %115, i32* %17
%116 = load i8*, i8** %9
%117 = load i32, i32* %17
%118 = load i32*, i32** %12
%119 = call i32 @fwrite(i8* %116, i32 %117, i32 1, i32* %118)
%120 = load i32*, i32** %12
%121 = call i32 @fclose(i32* %120)
%122 = load i8*, i8** %11
%123 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%124 = load i32, i32* %123
%125 = load i32, i32* %17
%126 = sub nsw i32 %124, %125
%127 = load i32*, i32** %13
%128 = call i32 @fwrite(i8* %122, i32 %126, i32 1, i32* %127)
%129 = load i32*, i32** %13
%130 = call i32 @fclose(i32* %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
%132 = load i8*, i8** %9
%133 = call i32 @free(i8* %132)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [56 x i8] c"Usage: %s <jpgFileName> <archiveFileName> <inFileName>\0A\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [19 x i8] c"Couldn't open file\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [16 x i8] c"File size: %ld\0A\00"
@.str.5 = [43 x i8] c"Couldn't find the guard bytes. Exiting...\0A\00"
@str = [34 x i8] c"We found the bytes. Processing...\00"
@str.8 = [22 x i8] c"Operations successful\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i16
%4 = alloca %struct.stat
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 3
%10 = load i8*, i8** %9
%11 = bitcast i16* %3 to i8*
store i16 -9729, i16* %3
%12 = bitcast %struct.stat* %4 to i8*
%13 = icmp eq i32 %0, 4
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 0)
unreachable
19: ; preds = %2
%20 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %19
%26 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %28, label %32
28: ; preds = %25
%29 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%30 = tail call i32 @fclose(i32* %20)
%31 = tail call i32 @exit(i32 2)
unreachable
32: ; preds = %25
%33 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %40
35: ; preds = %32
%36 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%37 = tail call i32 @fclose(i32* %20)
%38 = tail call i32 @fclose(i32* %26)
%39 = tail call i32 @exit(i32 3)
unreachable
40: ; preds = %32
%41 = tail call i32 @fileno(i32* %33)
%42 = call i32 @fstat(i32 %41, %struct.stat* %4)
%43 = getelementptr inbounds %struct.stat, %struct.stat* %4, i64 0, i32 0
%44 = load i32, i32* %43
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32 %44)
%46 = tail call i64 @malloc(i32 %44)
%47 = inttoptr i64 %46 to i8*
%48 = tail call i32 @fread(i8* %47, i32 %44, i32 1, i32* %33)
%49 = tail call i32 @fclose(i32* %33)
%50 = call i8* @memmem(i8* %47, i32 %44, i8* %11, i32 2)
%51 = icmp eq i8* %50, null
br i1 %51, label %52, label %59
52: ; preds = %40
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @free(i8* %47)
%56 = call i32 @fclose(i32* %20)
%57 = call i32 @fclose(i32* %26)
%58 = call i32 @exit(i32 4)
unreachable
59: ; preds = %40
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%61 = getelementptr inbounds i8, i8* %50, i64 2
%62 = ptrtoint i8* %61 to i64
%63 = sub i64 %62, %46
%64 = trunc i64 %63 to i32
%65 = call i32 @fwrite(i8* %47, i32 %64, i32 1, i32* %20)
%66 = call i32 @fclose(i32* %20)
%67 = sub nsw i32 %44, %64
%68 = call i32 @fwrite(i8* %61, i32 %67, i32 1, i32* %26)
%69 = call i32 @fclose(i32* %26)
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.8, i64 0, i64 0))
%71 = call i32 @free(i8* %47)
ret i32 0
}