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

/* Variables and functions */
int EXIT_FAILURE;
int EXIT_SUCCESS;
int crc32(int, char *, size_t);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
scalar_t__ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fix_header(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, size_t, int, int /*<<< orphan*/ *);
int getopt(int, char **, char *);
char *optarg;
int optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  char buf[1024];
  FILE *in = stdin;
  FILE *out = stdout;
  char *ifn = NULL;
  char *ofn = NULL;
  int c;
  int v0, v1, v2;
  size_t n;
  int first_block = 1;
  uint32_t image_crc = 0xFFFFFFFF;
  while ((c = getopt(argc, argv, "i:o:h")) != -1) {
    switch (c) {
    case 'i':
      ifn = optarg;
      break;
    case 'o':
      ofn = optarg;
      break;
    case 'h':
    default:
      usage();
    }
  }
  if (optind != argc || optind == 1) {
    fprintf(stderr, "illegal arg \"%s\"\n", argv[optind]);
    usage();
  }
  if (ifn && !(in = fopen(ifn, "r"))) {
    fprintf(stderr, "can not open \"%s\" for reading\n", ifn);
    usage();
  }
  if (ofn && !(out = fopen(ofn, "w"))) {
    fprintf(stderr, "can not open \"%s\" for writing\n", ofn);
    usage();
  }
  while ((n = fread(buf, 1, sizeof(buf), in)) > 0) {
    if (n < sizeof(buf)) {
      if (ferror(in)) {
      FREAD_ERROR:
        fprintf(stderr, "fread error\n");
        return EXIT_FAILURE;
      }
    }
    if (first_block && n >= 256) {
      fix_header(buf);
      first_block = 0;
    }
    image_crc = crc32(image_crc, buf, n);
    if (!fwrite(buf, n, 1, out)) {
    FWRITE_ERROR:
      fprintf(stderr, "fwrite error\n");
      return EXIT_FAILURE;
    }
  }
  if (ferror(in)) {
    goto FREAD_ERROR;
  }
  if (fflush(out)) {
    goto FWRITE_ERROR;
  }
  fclose(in);
  fclose(out);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e10(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x418(%rbp)
mov    0x2dd7(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x420(%rbp)
movq   $0x0,-0x428(%rbp)
movq   $0x0,-0x430(%rbp)
movl   $0x1,-0x44c(%rbp)
movl   $0xffffffff,-0x450(%rbp)
ff ff ff
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xddd(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x434(%rbp)
cmp    $0xffffffff,%eax
je     12b6 <main+0x106>
mov    -0x434(%rbp),%eax
mov    %eax,-0x454(%rbp)
sub    $0x68,%eax
je     12a5 <main+0xf5>
jmp    1251 <main+0xa1>
mov    -0x454(%rbp),%eax
sub    $0x69,%eax
je     1279 <main+0xc9>
jmp    1265 <main+0xb5>
mov    -0x454(%rbp),%eax
sub    $0x6f,%eax
je     128f <main+0xdf>
jmp    12aa <main+0xfa>
mov    0x2d78(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x428(%rbp)
jmp    12b1 <main+0x101>
mov    0x2d62(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x430(%rbp)
jmp    12b1 <main+0x101>
jmp    12aa <main+0xfa>
mov    $0x0,%al
call   10a0 <usage@plt>
jmp    1215 <main+0x65>
mov    0x2d1b(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    12d8 <main+0x128>
mov    0x2d09(%rip),%rax
cmpl   $0x1,(%rax)
jne    1308 <main+0x158>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x2cec(%rip),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd0c(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
cmpq   $0x0,-0x428(%rbp)
je     135f <main+0x1af>
mov    -0x428(%rbp),%rdi
lea    0xcf4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x418(%rbp)
cmp    $0x0,%rax
jne    135f <main+0x1af>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
mov    -0x428(%rbp),%rdx
lea    0xcc9(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
cmpq   $0x0,-0x430(%rbp)
je     13b6 <main+0x206>
mov    -0x430(%rbp),%rdi
lea    0xcbe(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x420(%rbp)
cmp    $0x0,%rax
jne    13b6 <main+0x206>
mov    0x2c30(%rip),%rax
mov    (%rax),%edi
mov    -0x430(%rbp),%rdx
lea    0xc93(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x0,%al
call   10a0 <usage@plt>
jmp    13bb <main+0x20b>
lea    -0x410(%rbp),%rdi
mov    -0x418(%rbp),%rcx
mov    $0x1,%esi
mov    $0x400,%edx
call   1040 <fread@plt>
mov    %rax,-0x448(%rbp)
cmp    $0x0,%rax
jbe    14ef <main+0x33f>
cmpq   $0x400,-0x448(%rbp)
jae    1442 <main+0x292>
mov    -0x418(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     143d <main+0x28d>
jmp    1415 <main+0x265>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
lea    0xc35(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b8d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1549 <main+0x399>
jmp    1442 <main+0x292>
cmpl   $0x0,-0x44c(%rbp)
je     1476 <main+0x2c6>
cmpq   $0x100,-0x448(%rbp)
jb     1476 <main+0x2c6>
lea    -0x410(%rbp),%rdi
call   1070 <fix_header@plt>
movl   $0x0,-0x44c(%rbp)
mov    -0x450(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x448(%rbp),%rdx
call   1050 <crc32@plt>
mov    %eax,-0x450(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x448(%rbp),%rsi
mov    -0x420(%rbp),%rcx
mov    $0x1,%edx
call   10d0 <fwrite@plt>
cmp    $0x0,%eax
jne    14ea <main+0x33a>
jmp    14c2 <main+0x312>
mov    0x2aff(%rip),%rax
mov    (%rax),%edi
lea    0xb95(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2ae0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1549 <main+0x399>
jmp    13bb <main+0x20b>
mov    -0x418(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     150a <main+0x35a>
jmp    1415 <main+0x265>
mov    -0x420(%rbp),%rdi
call   1090 <fflush@plt>
cmp    $0x0,%rax
je     1525 <main+0x375>
jmp    14c2 <main+0x312>
mov    -0x418(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x420(%rbp),%rdi
call   1060 <fclose@plt>
mov    0x2a6c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x460,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e13(%rip),%rax
mov    (%rax),%r13
mov    0x2de1(%rip),%rax
mov    (%rax),%r14
lea    0xe1f(%rip),%r15
xor    %eax,%eax
mov    %rax,0x8(%rsp)
xor    %r12d,%r12d
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     1232 <main+0x82>
cmp    $0x6f,%eax
je     1215 <main+0x65>
cmp    $0x69,%eax
je     1226 <main+0x76>
xor    %eax,%eax
call   10a0 <usage@plt>
jmp    11f0 <main+0x40>
mov    0x2ddc(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
jmp    11f0 <main+0x40>
mov    0x2dcb(%rip),%rax
mov    (%rax),%r12
jmp    11f0 <main+0x40>
mov    0x2d9f(%rip),%rax
mov    (%rax),%eax
cmp    %ebp,%eax
jne    1244 <main+0x94>
cmp    $0x1,%eax
jne    1268 <main+0xb8>
cltq
mov    0x2d7b(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx,%rax,8),%rdx
lea    0xdac(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
test   %r12,%r12
je     12a8 <main+0xf8>
lea    0xda4(%rip),%rsi
mov    %r12,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    12a8 <main+0xf8>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
lea    0xd86(%rip),%rsi
xor    %r13d,%r13d
mov    %r12,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    0x8(%rsp),%rbx
test   %rbx,%rbx
je     12ed <main+0x13d>
lea    0xd80(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    12ed <main+0x13d>
mov    0x2cf8(%rip),%rax
mov    (%rax),%edi
lea    0xd62(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
mov    $0xffffffff,%ebp
mov    $0x1,%r12d
lea    0x10(%rsp),%r15
jmp    1326 <main+0x176>
nop
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <crc32@plt>
mov    %eax,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %r14,%rcx
call   10d0 <fwrite@plt>
test   %eax,%eax
je     139f <main+0x1ef>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r13,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1373 <main+0x1c3>
mov    %rax,%rbx
cmp    $0x3ff,%rax
ja     1358 <main+0x1a8>
mov    %r13,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1380 <main+0x1d0>
test   %r12d,%r12d
je     1300 <main+0x150>
cmp    $0x100,%rbx
jb     1300 <main+0x150>
mov    %r15,%rdi
call   1070 <fix_header@plt>
xor    %r12d,%r12d
jmp    1300 <main+0x150>
mov    %r13,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     1392 <main+0x1e2>
mov    0x2c41(%rip),%rax
mov    (%rax),%edi
lea    0xcca(%rip),%rsi
jmp    13af <main+0x1ff>
mov    %r14,%rdi
call   1090 <fflush@plt>
test   %rax,%rax
je     13d1 <main+0x221>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
lea    0xcb8(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2c03(%rip),%rax
mov    (%rax),%eax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r13,%rdi
call   1060 <fclose@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
mov    0x2bc8(%rip),%rax
jmp    13bd <main+0x20d>

LLVM IR (-O0):
@stdin = global i32* null
@stdout = global i32* null
@.str = [6 x i8] c"i:o:h\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [18 x i8] c"illegal arg \22%s\22\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [31 x i8] c"can not open \22%s\22 for reading\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [31 x i8] c"can not open \22%s\22 for writing\0A\00"
@.str.6 = [13 x i8] c"fread error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [14 x i8] c"fwrite error\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i64
%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** @stdin
store i32* %18, i32** %7
%19 = load i32*, i32** @stdout
store i32* %19, i32** %8
store i8* null, i8** %9
store i8* null, i8** %10
store i32 1, i32* %16
store i32 -1, i32* %17
br label %20
20: ; preds = %34, %2
%21 = load i32, i32* %4
%22 = load i8**, i8*** %5
%23 = call i32 @getopt(i32 %21, i8** %22, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i32 %23, i32* %11
%24 = icmp ne i32 %23, -1
br i1 %24, label %25, label %35
25: ; preds = %20
%26 = load i32, i32* %11
switch i32 %26, label %32 [
i32 105, label %27
i32 111, label %29
i32 104, label %31
]
27: ; preds = %25
%28 = load i8*, i8** @optarg
store i8* %28, i8** %9
br label %34
29: ; preds = %25
%30 = load i8*, i8** @optarg
store i8* %30, i8** %10
br label %34
31: ; preds = %25
br label %32
32: ; preds = %25, %31
%33 = call i32 (...) @usage()
br label %34
34: ; preds = %32, %29, %27
br label %20
35: ; preds = %20
%36 = load i32, i32* @optind
%37 = load i32, i32* %4
%38 = icmp ne i32 %36, %37
br i1 %38, label %42, label %39
39: ; preds = %35
%40 = load i32, i32* @optind
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %51
42: ; preds = %39, %35
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = load i32, i32* @optind
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %48)
%50 = call i32 (...) @usage()
br label %51
51: ; preds = %42, %39
%52 = load i8*, i8** %9
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %63
54: ; preds = %51
%55 = load i8*, i8** %9
%56 = call i32* @fopen(i8* %55, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %56, i32** %7
%57 = icmp ne i32* %56, null
br i1 %57, label %63, label %58
58: ; preds = %54
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %9
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %60)
%62 = call i32 (...) @usage()
br label %63
63: ; preds = %58, %54, %51
%64 = load i8*, i8** %10
%65 = icmp ne i8* %64, null
br i1 %65, label %66, label %75
66: ; preds = %63
%67 = load i8*, i8** %10
%68 = call i32* @fopen(i8* %67, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %68, i32** %8
%69 = icmp ne i32* %68, null
br i1 %69, label %75, label %70
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = load i8*, i8** %10
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %72)
%74 = call i32 (...) @usage()
br label %75
75: ; preds = %70, %66, %63
br label %76
76: ; preds = %118, %75
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%78 = load i32*, i32** %7
%79 = call i64 @fread(i8* %77, i32 1, i32 1024, i32* %78)
store i64 %79, i64* %15
%80 = icmp ugt i64 %79, 0
br i1 %80, label %81, label %119
81: ; preds = %76
%82 = load i64, i64* %15
%83 = icmp ult i64 %82, 1024
br i1 %83, label %84, label %94
84: ; preds = %81
%85 = load i32*, i32** %7
%86 = call i64 @ferror(i32* %85)
%87 = icmp ne i64 %86, 0
br i1 %87, label %88, label %93
88: ; preds = %84
br label %89
89: ; preds = %123, %88
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
%92 = load i32, i32* @EXIT_FAILURE
store i32 %92, i32* %3
br label %135
93: ; preds = %84
br label %94
94: ; preds = %93, %81
%95 = load i32, i32* %16
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %94
%98 = load i64, i64* %15
%99 = icmp uge i64 %98, 256
br i1 %99, label %100, label %103
100: ; preds = %97
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%102 = call i32 @fix_header(i8* %101)
store i32 0, i32* %16
br label %103
103: ; preds = %100, %97, %94
%104 = load i32, i32* %17
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%106 = load i64, i64* %15
%107 = call i32 @crc32(i32 %104, i8* %105, i64 %106)
store i32 %107, i32* %17
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%109 = load i64, i64* %15
%110 = load i32*, i32** %8
%111 = call i32 @fwrite(i8* %108, i64 %109, i32 1, i32* %110)
%112 = icmp ne i32 %111, 0
br i1 %112, label %118, label %113
113: ; preds = %103
br label %114
114: ; preds = %128, %113
%115 = load i32, i32* @stderr
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %115, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
%117 = load i32, i32* @EXIT_FAILURE
store i32 %117, i32* %3
br label %135
118: ; preds = %103
br label %76
119: ; preds = %76
%120 = load i32*, i32** %7
%121 = call i64 @ferror(i32* %120)
%122 = icmp ne i64 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %119
br label %89
124: ; preds = %119
%125 = load i32*, i32** %8
%126 = call i64 @fflush(i32* %125)
%127 = icmp ne i64 %126, 0
br i1 %127, label %128, label %129
128: ; preds = %124
br label %114
129: ; preds = %124
%130 = load i32*, i32** %7
%131 = call i32 @fclose(i32* %130)
%132 = load i32*, i32** %8
%133 = call i32 @fclose(i32* %132)
%134 = load i32, i32* @EXIT_SUCCESS
store i32 %134, i32* %3
br label %135
135: ; preds = %129, %114, %89
%136 = load i32, i32* %3
ret i32 %136
}

LLVM IR (-O2):
@stdin = global i32* null
@stdout = global i32* null
@.str = [6 x i8] c"i:o:h\00"
@optarg = global i8* null
@optind = global i32 0
@stderr = global i32 0
@.str.1 = [18 x i8] c"illegal arg \22%s\22\0A\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [31 x i8] c"can not open \22%s\22 for reading\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [31 x i8] c"can not open \22%s\22 for writing\0A\00"
@.str.6 = [13 x i8] c"fread error\0A\00"
@EXIT_FAILURE = global i32 0
@.str.7 = [14 x i8] c"fwrite error\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32*, i32** @stdin
%6 = load i32*, i32** @stdout
br label %7
7: ; preds = %16, %2
%8 = phi i8* [ %17, %16 ], [ null, %2 ]
%9 = phi i8* [ %11, %16 ], [ null, %2 ]
br label %10
10: ; preds = %7, %14
%11 = phi i8* [ %9, %7 ], [ %15, %14 ]
br label %12
12: ; preds = %10, %18
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %18 [
i32 -1, label %20
i32 105, label %14
i32 111, label %16
]
14: ; preds = %12
%15 = load i8*, i8** @optarg
br label %10
16: ; preds = %12
%17 = load i8*, i8** @optarg
br label %7
18: ; preds = %12
%19 = tail call i32 (...) @usage()
br label %12
20: ; preds = %12
%21 = load i32, i32* @optind
%22 = icmp ne i32 %21, %0
%23 = icmp eq i32 %21, 1
%24 = or i1 %22, %23
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = sext i32 %21 to i64
%28 = getelementptr inbounds i8*, i8** %1, i64 %27
%29 = load i8*, i8** %28
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = tail call i32 (...) @usage()
br label %32
32: ; preds = %20, %25
%33 = icmp eq i8* %11, null
br i1 %33, label %41, label %34
34: ; preds = %32
%35 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %41
37: ; preds = %34
%38 = load i32, i32* @stderr
%39 = tail call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%40 = tail call i32 (...) @usage()
br label %41
41: ; preds = %37, %34, %32
%42 = phi i32* [ %35, %34 ], [ null, %37 ], [ %5, %32 ]
%43 = icmp eq i8* %8, null
br i1 %43, label %51, label %44
44: ; preds = %41
%45 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = icmp eq i32* %45, null
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = load i32, i32* @stderr
%49 = tail call i32 (i32, i8*, ...) @fprintf(i32 %48, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%50 = tail call i32 (...) @usage()
br label %51
51: ; preds = %47, %44, %41
%52 = phi i32* [ %45, %44 ], [ null, %47 ], [ %6, %41 ]
br label %53
53: ; preds = %72, %51
%54 = phi i32 [ 1, %51 ], [ %73, %72 ]
%55 = phi i32 [ -1, %51 ], [ %74, %72 ]
%56 = call i64 @fread(i8* %4, i32 1, i32 1024, i32* %42)
%57 = icmp eq i64 %56, 0
br i1 %57, label %80, label %58
58: ; preds = %53
%59 = icmp ult i64 %56, 1024
br i1 %59, label %60, label %66
60: ; preds = %58
%61 = call i64 @ferror(i32* %42)
%62 = icmp eq i64 %61, 0
br i1 %62, label %66, label %63
63: ; preds = %60, %80
%64 = load i32, i32* @stderr
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0))
br label %89
66: ; preds = %60, %58
%67 = icmp ne i32 %54, 0
%68 = icmp ugt i64 %56, 255
%69 = and i1 %67, %68
br i1 %69, label %70, label %72
70: ; preds = %66
%71 = call i32 @fix_header(i8* %4)
br label %72
72: ; preds = %70, %66
%73 = phi i32 [ 0, %70 ], [ %54, %66 ]
%74 = call i32 @crc32(i32 %55, i8* %4, i64 %56)
%75 = call i32 @fwrite(i8* %4, i64 %56, i32 1, i32* %52)
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %53
77: ; preds = %72, %83
%78 = load i32, i32* @stderr
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
br label %89
80: ; preds = %53
%81 = call i64 @ferror(i32* %42)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %63
83: ; preds = %80
%84 = call i64 @fflush(i32* %52)
%85 = icmp eq i64 %84, 0
br i1 %85, label %86, label %77
86: ; preds = %83
%87 = call i32 @fclose(i32* %42)
%88 = call i32 @fclose(i32* %52)
br label %89
89: ; preds = %86, %77, %63
%90 = phi i32* [ @EXIT_FAILURE, %63 ], [ @EXIT_FAILURE, %77 ], [ @EXIT_SUCCESS, %86 ]
%91 = load i32, i32* %90
ret i32 %91
}