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

/* Variables and functions */
int EOF;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc != 2) {
    fprintf(stderr, "Usage: copy infile outfile\n");
    return 1;
  }
  char *rawFile = argv[1];
  FILE *inptr = fopen(rawFile, "r");
  FILE *inptr_EOF = fopen(rawFile, "r");
  if (inptr == NULL) {
    fprintf(stderr, "Could not open %s.\n", rawFile);
    return 2;
  }
  FILE *outptr = fopen("outfile.jpeg", "w");
  if (outptr == NULL) {
    fclose(inptr);
    fprintf(stderr, "Could not create outfile.jpeg.\n");
    return 3;
  }
  uint8_t buffer[512 + 3];
  int dataByte;
  int dataIndex = 0;
  int jpgFound = 0;
  int jpgEnd = 0;
  int jpgCount = 0;
  while ((dataByte = fgetc(inptr_EOF)) != EOF) {
    for (int i = 0; i < 512; i++) {
      fread(&buffer[i], sizeof(uint8_t), 1, inptr);
    }
    for (int i = 0; i < 512; i++) {
      if ((buffer[i] == 0xFF) && (buffer[i + 1] == 0xD8) &&
          (buffer[i + 2] == 0xFF) && jpgFound == 0) {
        printf(
            "\n\n\n\n\n\n\n ------------ NEW JPEG ------------ \n\n\n\n\n\n\n");
        jpgEnd = 0;
        jpgFound = 1;
        jpgCount++;
      }
      if (jpgFound == 1) {
        printf("%X ", buffer[i]);
        fwrite(&buffer[i], sizeof(uint8_t), 1, outptr);
      }
    }
    fseek(inptr_EOF, dataIndex, SEEK_SET);
    dataIndex += 512;
  }
  printf("\n");
  printf("Jpegs Found: %i\n", jpgCount);
  fclose(inptr);
  fclose(inptr_EOF);
  fclose(outptr);
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c6 <main+0x46>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
lea    0xe4d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    14a8 <main+0x328>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe3f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    122c <main+0xac>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    14a8 <main+0x328>
lea    0xdff(%rip),%rdi
lea    0xe05(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    127a <main+0xfa>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x3,-0x4(%rbp)
jmp    14a8 <main+0x328>
movl   $0x0,-0x848(%rbp)
movl   $0x0,-0x84c(%rbp)
movl   $0x0,-0x850(%rbp)
movl   $0x0,-0x854(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x844(%rbp)
mov    0x2d30(%rip),%rcx
cmp    (%rcx),%eax
je     1456 <main+0x2d6>
movl   $0x0,-0x858(%rbp)
cmpl   $0x200,-0x858(%rbp)
jge    1316 <main+0x196>
movslq -0x858(%rbp),%rax
lea    -0x840(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   1030 <fread@plt>
mov    -0x858(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x858(%rbp)
jmp    12ca <main+0x14a>
movl   $0x0,-0x85c(%rbp)
cmpl   $0x200,-0x85c(%rbp)
jge    1428 <main+0x2a8>
movslq -0x85c(%rbp),%rax
cmpl   $0xff,-0x840(%rbp,%rax,4)
jne    13be <main+0x23e>
mov    -0x85c(%rbp),%eax
add    $0x1,%eax
cltq
cmpl   $0xd8,-0x840(%rbp,%rax,4)
jne    13be <main+0x23e>
mov    -0x85c(%rbp),%eax
add    $0x2,%eax
cltq
cmpl   $0xff,-0x840(%rbp,%rax,4)
jne    13be <main+0x23e>
cmpl   $0x0,-0x84c(%rbp)
jne    13be <main+0x23e>
lea    0xccd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x850(%rbp)
movl   $0x1,-0x84c(%rbp)
mov    -0x854(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x854(%rbp)
cmpl   $0x1,-0x84c(%rbp)
jne    140f <main+0x28f>
movslq -0x85c(%rbp),%rax
mov    -0x840(%rbp,%rax,4),%esi
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movslq -0x85c(%rbp),%rax
lea    -0x840(%rbp),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x30(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
jmp    1414 <main+0x294>
mov    -0x85c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x85c(%rbp)
jmp    1320 <main+0x1a0>
mov    -0x28(%rbp),%rdi
mov    -0x848(%rbp),%esi
mov    0x2b97(%rip),%rax
mov    (%rax),%edx
call   1080 <fseek@plt>
mov    -0x848(%rbp),%eax
add    $0x200,%eax
mov    %eax,-0x848(%rbp)
jmp    12a2 <main+0x122>
lea    0xc35(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x854(%rbp),%esi
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x30(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xbf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x838,%rsp
cmp    $0x2,%edi
jne    1274 <main+0xd4>
mov    0x8(%rsi),%rbp
lea    0xe57(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10b0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rbx,%rbx
je     1292 <main+0xf2>
lea    0xe3f(%rip),%rdi
lea    0xe45(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12b3 <main+0x113>
mov    %rax,0x18(%rsp)
mov    0x8(%rsp),%rdi
call   1080 <fgetc@plt>
mov    0x2dca(%rip),%rcx
movl   $0x0,0x4(%rsp)
cmp    (%rcx),%eax
jne    12e9 <main+0x149>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe26(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1060 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
jmp    12d7 <main+0x137>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%eax
jmp    12d7 <main+0x137>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x2,%eax
jmp    12d7 <main+0x137>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
lea    0xd76(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x3,%eax
add    $0x838,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movl   $0x0,0x4(%rsp)
xor    %r12d,%r12d
xor    %ebp,%ebp
jmp    1339 <main+0x199>
nopl   0x0(%rax,%rax,1)
mov    0x2cc9(%rip),%rax
mov    (%rax),%edx
mov    0x8(%rsp),%r14
mov    %r14,%rdi
mov    0x14(%rsp),%ebp
mov    %ebp,%esi
call   10a0 <fseek@plt>
add    $0x200,%ebp
mov    %r14,%rdi
call   1080 <fgetc@plt>
mov    0x2cb7(%rip),%rcx
cmp    (%rcx),%eax
je     122e <main+0x8e>
mov    %ebp,0x14(%rsp)
xor    %ebp,%ebp
nop
lea    (%rsp,%rbp,1),%rdi
add    $0x20,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
add    $0x4,%rbp
cmp    $0x800,%rbp
jne    1340 <main+0x1a0>
xor    %r15d,%r15d
mov    0x18(%rsp),%rbp
jmp    13c7 <main+0x227>
lea    0xcfe(%rip),%rdi
call   1040 <puts@plt>
addl   $0x1,0x4(%rsp)
lea    (%rsp,%r15,1),%r14
add    $0x20,%r14
lea    0xcd0(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0x1,%r12d
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbp,%rcx
call   10c0 <fwrite@plt>
add    $0x4,%r15
cmp    $0x800,%r15
je     1300 <main+0x160>
mov    0x20(%rsp,%r15,1),%r13d
cmp    $0xff,%r13d
jne    13f0 <main+0x250>
cmpl   $0xd8,0x24(%rsp,%r15,1)
jne    13f0 <main+0x250>
cmpl   $0xff,0x28(%rsp,%r15,1)
jne    13f0 <main+0x250>
test   %r12d,%r12d
je     1371 <main+0x1d1>
cmp    $0x1,%r12d
je     1382 <main+0x1e2>
jmp    13b6 <main+0x216>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: copy infile outfile\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Could not open %s.\0A\00"
@.str.3 = [13 x i8] c"outfile.jpeg\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [32 x i8] c"Could not create outfile.jpeg.\0A\00"
@EOF = global i32 0
@.str.6 = [51 x i8] c"\0A\0A\0A\0A\0A\0A\0A ------------ NEW JPEG ------------ \0A\0A\0A\0A\0A\0A\0A\00"
@.str.7 = [4 x i8] c"%X \00"
@SEEK_SET = global i32 0
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [17 x i8] c"Jpegs Found: %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca [515 x i32]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* %4
%19 = icmp ne i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %2
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %132
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i32* @fopen(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %7
%29 = load i8*, i8** %6
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %8
%31 = load i32*, i32** %7
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %37
33: ; preds = %23
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %6
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %35)
store i32 2, i32* %3
br label %132
37: ; preds = %23
%38 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %38, i32** %9
%39 = load i32*, i32** %9
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i32*, i32** %7
%43 = call i32 @fclose(i32* %42)
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
store i32 3, i32* %3
br label %132
46: ; preds = %37
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
br label %47
47: ; preds = %114, %46
%48 = load i32*, i32** %8
%49 = call i32 @fgetc(i32* %48)
store i32 %49, i32* %11
%50 = load i32, i32* @EOF
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %121
52: ; preds = %47
store i32 0, i32* %16
br label %53
53: ; preds = %62, %52
%54 = load i32, i32* %16
%55 = icmp slt i32 %54, 512
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = load i32, i32* %16
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %58
%60 = load i32*, i32** %7
%61 = call i32 @fread(i32* %59, i32 4, i32 1, i32* %60)
br label %62
62: ; preds = %56
%63 = load i32, i32* %16
%64 = add nsw i32 %63, 1
store i32 %64, i32* %16
br label %53
65: ; preds = %53
store i32 0, i32* %17
br label %66
66: ; preds = %111, %65
%67 = load i32, i32* %17
%68 = icmp slt i32 %67, 512
br i1 %68, label %69, label %114
69: ; preds = %66
%70 = load i32, i32* %17
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %71
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, 255
br i1 %74, label %75, label %96
75: ; preds = %69
%76 = load i32, i32* %17
%77 = add nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %78
%80 = load i32, i32* %79
%81 = icmp eq i32 %80, 216
br i1 %81, label %82, label %96
82: ; preds = %75
%83 = load i32, i32* %17
%84 = add nsw i32 %83, 2
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %85
%87 = load i32, i32* %86
%88 = icmp eq i32 %87, 255
br i1 %88, label %89, label %96
89: ; preds = %82
%90 = load i32, i32* %13
%91 = icmp eq i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %14
store i32 1, i32* %13
%94 = load i32, i32* %15
%95 = add nsw i32 %94, 1
store i32 %95, i32* %15
br label %96
96: ; preds = %92, %89, %82, %75, %69
%97 = load i32, i32* %13
%98 = icmp eq i32 %97, 1
br i1 %98, label %99, label %110
99: ; preds = %96
%100 = load i32, i32* %17
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %103)
%105 = load i32, i32* %17
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [515 x i32], [515 x i32]* %10, i64 0, i64 %106
%108 = load i32*, i32** %9
%109 = call i32 @fwrite(i32* %107, i32 4, i32 1, i32* %108)
br label %110
110: ; preds = %99, %96
br label %111
111: ; preds = %110
%112 = load i32, i32* %17
%113 = add nsw i32 %112, 1
store i32 %113, i32* %17
br label %66
114: ; preds = %66
%115 = load i32*, i32** %8
%116 = load i32, i32* %12
%117 = load i32, i32* @SEEK_SET
%118 = call i32 @fseek(i32* %115, i32 %116, i32 %117)
%119 = load i32, i32* %12
%120 = add nsw i32 %119, 512
store i32 %120, i32* %12
br label %47
121: ; preds = %47
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%123 = load i32, i32* %15
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %123)
%125 = load i32*, i32** %7
%126 = call i32 @fclose(i32* %125)
%127 = load i32*, i32** %8
%128 = call i32 @fclose(i32* %127)
%129 = load i32*, i32** %9
%130 = call i32 @fclose(i32* %129)
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %3
br label %132
132: ; preds = %121, %41, %33, %20
%133 = load i32, i32* %3
ret i32 %133
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: copy infile outfile\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [20 x i8] c"Could not open %s.\0A\00"
@.str.3 = [13 x i8] c"outfile.jpeg\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [32 x i8] c"Could not create outfile.jpeg.\0A\00"
@EOF = global i32 0
@.str.7 = [4 x i8] c"%X \00"
@SEEK_SET = global i32 0
@.str.9 = [17 x i8] c"Jpegs Found: %i\0A\00"
@str = [50 x i8] c"\0A\0A\0A\0A\0A\0A\0A ------------ NEW JPEG ------------ \0A\0A\0A\0A\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [515 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %87
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i32* %11, null
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %87
17: ; preds = %8
%18 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = tail call i32 @fclose(i32* %11)
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
br label %87
24: ; preds = %17
%25 = bitcast [515 x i32]* %3 to i8*
%26 = tail call i32 @fgetc(i32* %12)
%27 = load i32, i32* @EOF
%28 = icmp eq i32 %26, %27
br i1 %28, label %79, label %29
29: ; preds = %24, %39
%30 = phi i32 [ %75, %39 ], [ 0, %24 ]
%31 = phi i32 [ %76, %39 ], [ 0, %24 ]
%32 = phi i32 [ %42, %39 ], [ 0, %24 ]
br label %33
33: ; preds = %29, %33
%34 = phi i64 [ 0, %29 ], [ %37, %33 ]
%35 = getelementptr inbounds [515 x i32], [515 x i32]* %3, i64 0, i64 %34
%36 = call i32 @fread(i32* %35, i32 4, i32 1, i32* %11)
%37 = add nuw nsw i64 %34, 1
%38 = icmp eq i64 %37, 512
br i1 %38, label %46, label %33
39: ; preds = %74
%40 = load i32, i32* @SEEK_SET
%41 = tail call i32 @fseek(i32* %12, i32 %32, i32 %40)
%42 = add nuw nsw i32 %32, 512
%43 = tail call i32 @fgetc(i32* %12)
%44 = load i32, i32* @EOF
%45 = icmp eq i32 %43, %44
br i1 %45, label %79, label %29
46: ; preds = %33, %74
%47 = phi i64 [ %77, %74 ], [ 0, %33 ]
%48 = phi i32 [ %75, %74 ], [ %30, %33 ]
%49 = phi i32 [ %76, %74 ], [ %31, %33 ]
%50 = getelementptr inbounds [515 x i32], [515 x i32]* %3, i64 0, i64 %47
%51 = load i32, i32* %50
%52 = icmp eq i32 %51, 255
br i1 %52, label %53, label %68
53: ; preds = %46
%54 = add nuw nsw i64 %47, 1
%55 = getelementptr inbounds [515 x i32], [515 x i32]* %3, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 216
br i1 %57, label %58, label %68
58: ; preds = %53
%59 = add nuw nsw i64 %47, 2
%60 = getelementptr inbounds [515 x i32], [515 x i32]* %3, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = icmp eq i32 %61, 255
%63 = icmp eq i32 %49, 0
%64 = select i1 %62, i1 %63, i1 false
br i1 %64, label %65, label %68
65: ; preds = %58
%66 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%67 = add nsw i32 %48, 1
br label %70
68: ; preds = %58, %53, %46
%69 = icmp eq i32 %49, 1
br i1 %69, label %70, label %74
70: ; preds = %65, %68
%71 = phi i32 [ %67, %65 ], [ %48, %68 ]
%72 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %51)
%73 = call i32 @fwrite(i32* %50, i32 4, i32 1, i32* %18)
br label %74
74: ; preds = %68, %70
%75 = phi i32 [ %48, %68 ], [ %71, %70 ]
%76 = phi i32 [ %49, %68 ], [ 1, %70 ]
%77 = add nuw nsw i64 %47, 1
%78 = icmp eq i64 %77, 512
br i1 %78, label %39, label %46
79: ; preds = %39, %24
%80 = phi i32 [ 0, %24 ], [ %75, %39 ]
%81 = tail call i32 @putchar(i32 10)
%82 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0), i32 %80)
%83 = tail call i32 @fclose(i32* %11)
%84 = tail call i32 @fclose(i32* %12)
%85 = tail call i32 @fclose(i32* %18)
%86 = tail call i32 @putchar(i32 10)
br label %87
87: ; preds = %14, %79, %20, %5
%88 = phi i32 [ 1, %5 ], [ 2, %14 ], [ 3, %20 ], [ 0, %79 ]
ret i32 %88
}