#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;
  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    $0x450,%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,-0x444(%rbp)
movl   $0xffffffff,-0x448(%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,-0x44c(%rbp)
sub    $0x68,%eax
je     12a5 <main+0xf5>
jmp    1251 <main+0xa1>
mov    -0x44c(%rbp),%eax
sub    $0x69,%eax
je     1279 <main+0xc9>
jmp    1265 <main+0xb5>
mov    -0x44c(%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,-0x440(%rbp)
cmp    $0x0,%rax
jbe    14ef <main+0x33f>
cmpq   $0x400,-0x440(%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,-0x444(%rbp)
je     1476 <main+0x2c6>
cmpq   $0x100,-0x440(%rbp)
jb     1476 <main+0x2c6>
lea    -0x410(%rbp),%rdi
call   1070 <fix_header@plt>
movl   $0x0,-0x444(%rbp)
mov    -0x448(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0x440(%rbp),%rdx
call   1050 <crc32@plt>
mov    %eax,-0x448(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x440(%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    $0x450,%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    %r12d,%r12d
xor    %eax,%eax
mov    %rax,0x8(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10c0 <getopt@plt>
cmp    $0xffffffff,%eax
je     123c <main+0x8c>
cmp    $0x6f,%eax
je     1230 <main+0x80>
cmp    $0x69,%eax
je     1215 <main+0x65>
xor    %eax,%eax
call   10a0 <usage@plt>
jmp    11f0 <main+0x40>
mov    0x2ddc(%rip),%rax
mov    (%rax),%r12
jmp    11f0 <main+0x40>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2dc1(%rip),%rax
mov    (%rax),%rax
jmp    11e6 <main+0x36>
mov    0x2d95(%rip),%rax
mov    (%rax),%eax
cmp    %ebp,%eax
jne    124e <main+0x9e>
cmp    $0x1,%eax
jne    1272 <main+0xc2>
cltq
mov    0x2d71(%rip),%rcx
mov    (%rcx),%edi
mov    (%rbx,%rax,8),%rdx
lea    0xda2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
xor    %eax,%eax
call   10a0 <usage@plt>
test   %r12,%r12
je     12b2 <main+0x102>
lea    0xd9a(%rip),%rsi
mov    %r12,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r13
test   %rax,%rax
jne    12b2 <main+0x102>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
lea    0xd7c(%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     12f7 <main+0x147>
lea    0xd76(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    12f7 <main+0x147>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
lea    0xd58(%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    1336 <main+0x186>
nopl   0x0(%rax)
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     13af <main+0x1ff>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x400,%edx
mov    %r13,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     1383 <main+0x1d3>
mov    %rax,%rbx
cmp    $0x3ff,%rax
ja     1368 <main+0x1b8>
mov    %r13,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
jne    1390 <main+0x1e0>
test   %r12d,%r12d
je     1310 <main+0x160>
cmp    $0x100,%rbx
jb     1310 <main+0x160>
mov    %r15,%rdi
call   1070 <fix_header@plt>
xor    %r12d,%r12d
jmp    1310 <main+0x160>
mov    %r13,%rdi
call   1030 <ferror@plt>
test   %rax,%rax
je     13a2 <main+0x1f2>
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
lea    0xcba(%rip),%rsi
jmp    13bf <main+0x20f>
mov    %r14,%rdi
call   1090 <fflush@plt>
test   %rax,%rax
je     13e1 <main+0x231>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2bf3(%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    0x2bb8(%rip),%rax
jmp    13cd <main+0x21d>

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

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 = %14, %2
%8 = phi i8* [ %15, %14 ], [ null, %2 ]
%9 = phi i8* [ %11, %14 ], [ null, %2 ]
br label %10
10: ; preds = %7, %16
%11 = phi i8* [ %9, %7 ], [ %17, %16 ]
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 %7
16: ; preds = %12
%17 = load i8*, i8** @optarg
br label %10
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* %8, null
br i1 %33, label %41, label %34
34: ; preds = %32
%35 = tail call i32* @fopen(i8* %8, 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* %8)
%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* %11, null
br i1 %43, label %51, label %44
44: ; preds = %41
%45 = tail call i32* @fopen(i8* %11, 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* %11)
%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
}