#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int total_out;
  char *next_in;
  int avail_in;
  char *next_out;
  int avail_out;
  int /*<<< orphan*/ *opaque;
  int /*<<< orphan*/ *zfree;
  int /*<<< orphan*/ *zalloc;
};
typedef TYPE_1__ z_stream;
struct stat {
  int st_size;
};

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int Z_BUF_ERROR;
int Z_OK;
int Z_STREAM_END;
int /*<<< orphan*/ Z_SYNC_FLUSH;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fstat(int, struct stat *);
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int /*<<< orphan*/ inflateInit(TYPE_1__ *);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char **, int);
int write(int, char **, int);
int main(int argc, char *argv[]) {
  int fd_in, fd_out, comp_len, uncomp_len, i, last_out;
  char buf_in[1024], buf_out[65536];
  z_stream zstream;
  struct stat statbuf;
  if (argc < 3) {
    printf("Usage: %s <infile.swf> <outfile.swf>\n", argv[0]);
    exit(1);
  }
  fd_in = open(argv[1], O_RDONLY);
  if (fd_in < 0) {
    perror("Error opening input file");
    exit(1);
  }
  fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
  if (fd_out < 0) {
    perror("Error opening output file");
    close(fd_in);
    exit(1);
  }
  if (read(fd_in, &buf_in, 8) != 8) {
    printf("Header error\n");
    close(fd_in);
    close(fd_out);
    exit(1);
  }
  if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S') {
    printf("Not a compressed flash file\n");
    exit(1);
  }
  fstat(fd_in, &statbuf);
  comp_len = statbuf.st_size;
  uncomp_len =
      buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24);
  printf("Compressed size: %d Uncompressed size: %d\n", comp_len - 4,
         uncomp_len - 4);
  buf_in[0] = 'F';
  if (write(fd_out, &buf_in, 8) < 8) {
    perror("Error writing output file");
    exit(1);
  }
  zstream.zalloc = NULL;
  zstream.zfree = NULL;
  zstream.opaque = NULL;
  inflateInit(&zstream);
  for (i = 0; i < comp_len - 8;) {
    int ret, len = read(fd_in, &buf_in, 1024);
    ;
    last_out = zstream.total_out;
    zstream.next_in = &buf_in[0];
    zstream.avail_in = len;
    zstream.next_out = &buf_out[0];
    zstream.avail_out = 65536;
    ret = inflate(&zstream, Z_SYNC_FLUSH);
    if (ret != Z_STREAM_END && ret != Z_OK) {
      printf("Error while decompressing: %d\n", ret);
      inflateEnd(&zstream);
      exit(1);
    }

    ;
    if (write(fd_out, &buf_out, zstream.total_out - last_out) <
        zstream.total_out - last_out) {
      perror("Error writing output file");
      exit(1);
    }
    i += len;
    if (ret == Z_STREAM_END || ret == Z_BUF_ERROR)
      break;
  }
  if (zstream.total_out != uncomp_len - 8) {
    printf("Size mismatch (%lu != %d), updating header...\n", zstream.total_out,
           uncomp_len - 8);
    buf_in[0] = (zstream.total_out + 8) & 0xff;
    buf_in[1] = ((zstream.total_out + 8) >> 8) & 0xff;
    buf_in[2] = ((zstream.total_out + 8) >> 16) & 0xff;
    buf_in[3] = ((zstream.total_out + 8) >> 24) & 0xff;
    lseek(fd_out, 4, SEEK_SET);
    if (write(fd_out, &buf_in, 4) < 4) {
      perror("Error writing output file");
      exit(1);
    }
  }
  inflateEnd(&zstream);
  close(fd_in);
  close(fd_out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10480,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1202 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    123d <main+0x7d>
lea    0xdf8(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
mov    0x2da3(%rip),%rax
or     (%rax),%esi
mov    $0x1a4,%edx
mov    $0x0,%al
call   10b0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    128e <main+0xce>
lea    0xdc8(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x8,%edx
call   1080 <read@plt>
cmp    $0x8,%eax
je     12d3 <main+0x113>
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movsbl -0x430(%rbp),%eax
cmp    $0x43,%eax
jne    1303 <main+0x143>
movsbl -0x42f(%rbp),%eax
cmp    $0x57,%eax
jne    1303 <main+0x143>
movsbl -0x42e(%rbp),%eax
cmp    $0x53,%eax
je     131b <main+0x15b>
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x14(%rbp),%edi
lea    -0x10478(%rbp),%rsi
call   10e0 <fstat@plt>
mov    -0x10478(%rbp),%eax
mov    %eax,-0x1c(%rbp)
movsbl -0x42c(%rbp),%eax
movsbl -0x42b(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
movsbl -0x42a(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
movsbl -0x429(%rbp),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%esi
sub    $0x4,%esi
mov    -0x20(%rbp),%edx
sub    $0x4,%edx
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movb   $0x46,-0x430(%rbp)
mov    -0x18(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x8,%edx
call   1040 <write@plt>
cmp    $0x8,%eax
jge    13b5 <main+0x1f5>
lea    0xd09(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
movq   $0x0,-0x10438(%rbp)
movq   $0x0,-0x10440(%rbp)
movq   $0x0,-0x10448(%rbp)
lea    -0x10470(%rbp),%rdi
call   1090 <inflateInit@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x8,%ecx
cmp    %ecx,%eax
jge    153d <main+0x37d>
mov    -0x14(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x400,%edx
call   1080 <read@plt>
mov    %eax,-0x10480(%rbp)
mov    -0x10470(%rbp),%eax
mov    %eax,-0x28(%rbp)
lea    -0x430(%rbp),%rax
mov    %rax,-0x10468(%rbp)
mov    -0x10480(%rbp),%eax
mov    %eax,-0x10460(%rbp)
lea    -0x10430(%rbp),%rax
mov    %rax,-0x10458(%rbp)
movl   $0x10000,-0x10450(%rbp)
mov    0x2b72(%rip),%rax
mov    (%rax),%esi
lea    -0x10470(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x1047c(%rbp)
mov    -0x1047c(%rbp),%eax
mov    0x2b59(%rip),%rcx
cmp    (%rcx),%eax
je     14be <main+0x2fe>
mov    -0x1047c(%rbp),%eax
mov    0x2b5c(%rip),%rcx
cmp    (%rcx),%eax
je     14be <main+0x2fe>
mov    -0x1047c(%rbp),%esi
lea    0xc28(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x10470(%rbp),%rdi
call   10a0 <inflateEnd@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x18(%rbp),%edi
lea    -0x10430(%rbp),%rsi
mov    -0x10470(%rbp),%edx
sub    -0x28(%rbp),%edx
call   1040 <write@plt>
mov    -0x10470(%rbp),%ecx
sub    -0x28(%rbp),%ecx
cmp    %ecx,%eax
jge    14fd <main+0x33d>
lea    0xbc1(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10480(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1047c(%rbp),%eax
mov    0x2aba(%rip),%rcx
cmp    (%rcx),%eax
je     1533 <main+0x373>
mov    -0x1047c(%rbp),%eax
mov    0x2a95(%rip),%rcx
cmp    (%rcx),%eax
jne    1538 <main+0x378>
jmp    153d <main+0x37d>
jmp    13e9 <main+0x229>
mov    -0x10470(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x8,%ecx
cmp    %ecx,%eax
je     1612 <main+0x452>
mov    -0x10470(%rbp),%esi
mov    -0x20(%rbp),%edx
sub    $0x8,%edx
lea    0xb84(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10470(%rbp),%eax
add    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x430(%rbp)
mov    -0x10470(%rbp),%eax
add    $0x8,%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %al,-0x42f(%rbp)
mov    -0x10470(%rbp),%eax
add    $0x8,%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %al,-0x42e(%rbp)
mov    -0x10470(%rbp),%eax
add    $0x8,%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %al,-0x42d(%rbp)
mov    -0x18(%rbp),%edi
mov    0x29e2(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1060 <lseek@plt>
mov    -0x18(%rbp),%edi
lea    -0x430(%rbp),%rsi
mov    $0x4,%edx
call   1040 <write@plt>
cmp    $0x4,%eax
jge    160d <main+0x44d>
lea    0xab1(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1612 <main+0x452>
lea    -0x10470(%rbp),%rdi
call   10a0 <inflateEnd@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x10480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10468,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    14af <main+0x2df>
mov    0x8(%rbx),%rdi
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,(%rsp)
test   %eax,%eax
js     14ca <main+0x2fa>
mov    0x10(%rbx),%rdi
mov    0x2d89(%rip),%rax
mov    0x2dda(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,0x4(%rsp)
test   %eax,%eax
js     14d3 <main+0x303>
lea    0x60(%rsp),%rsi
mov    (%rsp),%edi
mov    $0x8,%edx
call   1090 <read@plt>
cmp    $0x8,%eax
jne    14e4 <main+0x314>
cmpb   $0x43,0x60(%rsp)
jne    150b <main+0x33b>
cmpb   $0x57,0x61(%rsp)
jne    150b <main+0x33b>
cmpb   $0x53,0x62(%rsp)
jne    150b <main+0x33b>
lea    0x8(%rsp),%rsi
mov    (%rsp),%edi
call   10f0 <fstat@plt>
mov    0x8(%rsp),%ebx
movsbl 0x64(%rsp),%eax
movsbl 0x65(%rsp),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
movsbl 0x66(%rsp),%eax
shl    $0x10,%eax
movzbl 0x67(%rsp),%edx
shl    $0x18,%edx
or     %eax,%edx
or     %ecx,%edx
lea    -0x4(%rbx),%esi
mov    %rdx,0x10(%rsp)
add    $0xfffffffc,%edx
lea    0xd9d(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x46,0x60(%rsp)
lea    0x60(%rsp),%rsi
mov    0x4(%rsp),%edi
mov    $0x8,%edx
call   1050 <write@plt>
cmp    $0x7,%eax
jle    1474 <main+0x2a4>
xorps  %xmm0,%xmm0
movups %xmm0,0x48(%rsp)
movq   $0x0,0x58(%rsp)
lea    0x20(%rsp),%rdi
call   10a0 <inflateInit@plt>
add    $0xfffffff8,%ebx
lea    0x460(%rsp),%rbp
mov    %rbx,0x18(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %ebx,%r13d
jge    13d6 <main+0x206>
mov    (%rsp),%edi
mov    %rbp,%rbx
lea    0x60(%rsp),%rbp
mov    %rbp,%rsi
mov    $0x400,%edx
call   1090 <read@plt>
mov    %eax,%r14d
mov    0x20(%rsp),%r12d
mov    %rbp,0x28(%rsp)
mov    %rbx,%rbp
mov    %eax,0x30(%rsp)
mov    %rbx,0x38(%rsp)
movl   $0x10000,0x40(%rsp)
mov    0x2c5f(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdi
call   1030 <inflate@plt>
mov    %eax,%r15d
mov    0x2c51(%rip),%rbx
cmp    (%rbx),%eax
je     1393 <main+0x1c3>
mov    0x2c5e(%rip),%rax
cmp    (%rax),%r15d
jne    148a <main+0x2ba>
mov    0x20(%rsp),%edx
sub    %r12d,%edx
mov    0x4(%rsp),%edi
mov    %rbp,%rsi
call   1050 <write@plt>
mov    0x20(%rsp),%esi
mov    %esi,%ecx
sub    %r12d,%ecx
cmp    %ecx,%eax
jl     1474 <main+0x2a4>
cmp    (%rbx),%r15d
je     13da <main+0x20a>
add    %r14d,%r13d
mov    0x2bfa(%rip),%rax
cmp    (%rax),%r15d
mov    0x18(%rsp),%rbx
jne    1320 <main+0x150>
jmp    13da <main+0x20a>
mov    0x20(%rsp),%esi
mov    0x10(%rsp),%rdx
add    $0xfffffff8,%edx
cmp    %edx,%esi
je     1445 <main+0x275>
lea    0xcd0(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%eax
lea    0x8(%rax),%ecx
mov    %cl,0x60(%rsp)
add    $0x8,%eax
mov    %ah,0x61(%rsp)
mov    %eax,%ecx
shr    $0x10,%ecx
mov    %cl,0x62(%rsp)
shr    $0x18,%eax
mov    %al,0x63(%rsp)
mov    0x2b93(%rip),%rax
mov    (%rax),%edx
mov    0x4(%rsp),%ebx
mov    %ebx,%edi
mov    $0x4,%esi
call   1070 <lseek@plt>
lea    0x60(%rsp),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <write@plt>
cmp    $0x3,%eax
jle    1474 <main+0x2a4>
lea    0x20(%rsp),%rdi
call   10b0 <inflateEnd@plt>
mov    (%rsp),%edi
call   1080 <close@plt>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x10468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc09(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xc0d(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%rdi
call   10b0 <inflateEnd@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    (%rbx),%rsi
lea    0xb47(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xb55(%rip),%rdi
jmp    147b <main+0x2ab>
lea    0xb65(%rip),%rdi
call   10d0 <perror@plt>
mov    (%rsp),%edi
jmp    14fc <main+0x32c>
lea    0xc1d(%rip),%rdi
call   1040 <puts@plt>
mov    (%rsp),%edi
call   1080 <close@plt>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xbda(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i8*, i32, i8*, i32, i32*, i32*, i32* }
%struct.stat = type { i32 }
@.str = [38 x i8] c"Usage: %s <infile.swf> <outfile.swf>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [25 x i8] c"Error opening input file\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [26 x i8] c"Error opening output file\00"
@.str.3 = [14 x i8] c"Header error\0A\00"
@.str.4 = [29 x i8] c"Not a compressed flash file\0A\00"
@.str.5 = [43 x i8] c"Compressed size: %d Uncompressed size: %d\0A\00"
@.str.6 = [26 x i8] c"Error writing output file\00"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@Z_OK = global i32 0
@.str.7 = [31 x i8] c"Error while decompressing: %d\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.8 = [47 x i8] c"Size mismatch (%lu != %d), updating header...\0A\00"
@SEEK_SET = global i32 0
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 [1024 x i8]
%13 = alloca [65536 x i8]
%14 = alloca %struct.TYPE_5__
%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 i32, i32* %4
%19 = icmp slt i32 %18, 3
br i1 %19, label %20, label %26
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i32, i32* @O_RDONLY
%31 = call i32 (i8*, i32, ...) @open(i8* %29, i32 %30)
store i32 %31, i32* %6
%32 = load i32, i32* %6
%33 = icmp slt i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %26
%35 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%36 = call i32 @exit(i32 1)
unreachable
37: ; preds = %26
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = load i32, i32* @O_WRONLY
%42 = load i32, i32* @O_CREAT
%43 = or i32 %41, %42
%44 = call i32 (i8*, i32, ...) @open(i8* %40, i32 %43, i32 420)
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = icmp slt i32 %45, 0
br i1 %46, label %47, label %52
47: ; preds = %37
%48 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%49 = load i32, i32* %6
%50 = call i32 @close(i32 %49)
%51 = call i32 @exit(i32 1)
unreachable
52: ; preds = %37
%53 = load i32, i32* %6
%54 = bitcast [1024 x i8]* %12 to i8**
%55 = call i32 @read(i32 %53, i8** %54, i32 8)
%56 = icmp ne i32 %55, 8
br i1 %56, label %57, label %64
57: ; preds = %52
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%59 = load i32, i32* %6
%60 = call i32 @close(i32 %59)
%61 = load i32, i32* %7
%62 = call i32 @close(i32 %61)
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %52
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%66 = load i8, i8* %65
%67 = sext i8 %66 to i32
%68 = icmp ne i32 %67, 67
br i1 %68, label %79, label %69
69: ; preds = %64
%70 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 1
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = icmp ne i32 %72, 87
br i1 %73, label %79, label %74
74: ; preds = %69
%75 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 2
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp ne i32 %77, 83
br i1 %78, label %79, label %82
79: ; preds = %74, %69, %64
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %74
%83 = load i32, i32* %6
%84 = call i32 @fstat(i32 %83, %struct.stat* %15)
%85 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%86 = load i32, i32* %85
store i32 %86, i32* %8
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 4
%88 = load i8, i8* %87
%89 = sext i8 %88 to i32
%90 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 5
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = shl i32 %92, 8
%94 = or i32 %89, %93
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 6
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = shl i32 %97, 16
%99 = or i32 %94, %98
%100 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 7
%101 = load i8, i8* %100
%102 = sext i8 %101 to i32
%103 = shl i32 %102, 24
%104 = or i32 %99, %103
store i32 %104, i32* %9
%105 = load i32, i32* %8
%106 = sub nsw i32 %105, 4
%107 = load i32, i32* %9
%108 = sub nsw i32 %107, 4
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %106, i32 %108)
%110 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
store i8 70, i8* %110
%111 = load i32, i32* %7
%112 = bitcast [1024 x i8]* %12 to i8**
%113 = call i32 @write(i32 %111, i8** %112, i32 8)
%114 = icmp slt i32 %113, 8
br i1 %114, label %115, label %118
115: ; preds = %82
%116 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%117 = call i32 @exit(i32 1)
unreachable
118: ; preds = %82
%119 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 7
store i32* null, i32** %119
%120 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 6
store i32* null, i32** %120
%121 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 5
store i32* null, i32** %121
%122 = call i32 @inflateInit(%struct.TYPE_5__* %14)
store i32 0, i32* %10
br label %123
123: ; preds = %183, %118
%124 = load i32, i32* %10
%125 = load i32, i32* %8
%126 = sub nsw i32 %125, 8
%127 = icmp slt i32 %124, %126
br i1 %127, label %128, label %184
128: ; preds = %123
%129 = load i32, i32* %6
%130 = bitcast [1024 x i8]* %12 to i8**
%131 = call i32 @read(i32 %129, i8** %130, i32 1024)
store i32 %131, i32* %17
%132 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%133 = load i32, i32* %132
store i32 %133, i32* %11
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%135 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 1
store i8* %134, i8** %135
%136 = load i32, i32* %17
%137 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 2
store i32 %136, i32* %137
%138 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
%139 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 3
store i8* %138, i8** %139
%140 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 4
store i32 65536, i32* %140
%141 = load i32, i32* @Z_SYNC_FLUSH
%142 = call i32 @inflate(%struct.TYPE_5__* %14, i32 %141)
store i32 %142, i32* %16
%143 = load i32, i32* %16
%144 = load i32, i32* @Z_STREAM_END
%145 = icmp ne i32 %143, %144
br i1 %145, label %146, label %155
146: ; preds = %128
%147 = load i32, i32* %16
%148 = load i32, i32* @Z_OK
%149 = icmp ne i32 %147, %148
br i1 %149, label %150, label %155
150: ; preds = %146
%151 = load i32, i32* %16
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %151)
%153 = call i32 @inflateEnd(%struct.TYPE_5__* %14)
%154 = call i32 @exit(i32 1)
unreachable
155: ; preds = %146, %128
%156 = load i32, i32* %7
%157 = bitcast [65536 x i8]* %13 to i8**
%158 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%159 = load i32, i32* %158
%160 = load i32, i32* %11
%161 = sub nsw i32 %159, %160
%162 = call i32 @write(i32 %156, i8** %157, i32 %161)
%163 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%164 = load i32, i32* %163
%165 = load i32, i32* %11
%166 = sub nsw i32 %164, %165
%167 = icmp slt i32 %162, %166
br i1 %167, label %168, label %171
168: ; preds = %155
%169 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%170 = call i32 @exit(i32 1)
unreachable
171: ; preds = %155
%172 = load i32, i32* %17
%173 = load i32, i32* %10
%174 = add nsw i32 %173, %172
store i32 %174, i32* %10
%175 = load i32, i32* %16
%176 = load i32, i32* @Z_STREAM_END
%177 = icmp eq i32 %175, %176
br i1 %177, label %182, label %178
178: ; preds = %171
%179 = load i32, i32* %16
%180 = load i32, i32* @Z_BUF_ERROR
%181 = icmp eq i32 %179, %180
br i1 %181, label %182, label %183
182: ; preds = %178, %171
br label %184
183: ; preds = %178
br label %123
184: ; preds = %182, %123
%185 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%186 = load i32, i32* %185
%187 = load i32, i32* %9
%188 = sub nsw i32 %187, 8
%189 = icmp ne i32 %186, %188
br i1 %189, label %190, label %234
190: ; preds = %184
%191 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%192 = load i32, i32* %191
%193 = load i32, i32* %9
%194 = sub nsw i32 %193, 8
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 %192, i32 %194)
%196 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%197 = load i32, i32* %196
%198 = add nsw i32 %197, 8
%199 = and i32 %198, 255
%200 = trunc i32 %199 to i8
%201 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
store i8 %200, i8* %201
%202 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%203 = load i32, i32* %202
%204 = add nsw i32 %203, 8
%205 = ashr i32 %204, 8
%206 = and i32 %205, 255
%207 = trunc i32 %206 to i8
%208 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 1
store i8 %207, i8* %208
%209 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%210 = load i32, i32* %209
%211 = add nsw i32 %210, 8
%212 = ashr i32 %211, 16
%213 = and i32 %212, 255
%214 = trunc i32 %213 to i8
%215 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 2
store i8 %214, i8* %215
%216 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%217 = load i32, i32* %216
%218 = add nsw i32 %217, 8
%219 = ashr i32 %218, 24
%220 = and i32 %219, 255
%221 = trunc i32 %220 to i8
%222 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 3
store i8 %221, i8* %222
%223 = load i32, i32* %7
%224 = load i32, i32* @SEEK_SET
%225 = call i32 @lseek(i32 %223, i32 4, i32 %224)
%226 = load i32, i32* %7
%227 = bitcast [1024 x i8]* %12 to i8**
%228 = call i32 @write(i32 %226, i8** %227, i32 4)
%229 = icmp slt i32 %228, 4
br i1 %229, label %230, label %233
230: ; preds = %190
%231 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%232 = call i32 @exit(i32 1)
unreachable
233: ; preds = %190
br label %234
234: ; preds = %233, %184
%235 = call i32 @inflateEnd(%struct.TYPE_5__* %14)
%236 = load i32, i32* %6
%237 = call i32 @close(i32 %236)
%238 = load i32, i32* %7
%239 = call i32 @close(i32 %238)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i8*, i32, i8*, i32, i32*, i32*, i32* }
%struct.stat = type { i32 }
@.str = [38 x i8] c"Usage: %s <infile.swf> <outfile.swf>\0A\00"
@O_RDONLY = global i32 0
@.str.1 = [25 x i8] c"Error opening input file\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [26 x i8] c"Error opening output file\00"
@.str.5 = [43 x i8] c"Compressed size: %d Uncompressed size: %d\0A\00"
@.str.6 = [26 x i8] c"Error writing output file\00"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@Z_OK = global i32 0
@.str.7 = [31 x i8] c"Error while decompressing: %d\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.8 = [47 x i8] c"Size mismatch (%lu != %d), updating header...\0A\00"
@SEEK_SET = global i32 0
@str = [28 x i8] c"Not a compressed flash file\00"
@str.9 = [13 x i8] c"Header error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [65536 x i8]
%5 = alloca %struct.TYPE_5__
%6 = alloca %struct.stat
%7 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [65536 x i8], [65536 x i8]* %4, i64 0, i64 0
%9 = bitcast %struct.TYPE_5__* %5 to i8*
%10 = bitcast %struct.stat* %6 to i8*
%11 = icmp slt i32 %0, 3
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8*, i8** %1
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = load i32, i32* @O_RDONLY
%20 = tail call i32 (i8*, i32, ...) @open(i8* %18, i32 %19)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16
%23 = tail call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %16
%26 = getelementptr inbounds i8*, i8** %1, i64 2
%27 = load i8*, i8** %26
%28 = load i32, i32* @O_WRONLY
%29 = load i32, i32* @O_CREAT
%30 = or i32 %29, %28
%31 = tail call i32 (i8*, i32, ...) @open(i8* %27, i32 %30, i32 420)
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %25
%34 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call i32 @close(i32 %20)
%36 = tail call i32 @exit(i32 1)
unreachable
37: ; preds = %25
%38 = bitcast [1024 x i8]* %3 to i8**
%39 = call i32 @read(i32 %20, i8** %38, i32 8)
%40 = icmp eq i32 %39, 8
br i1 %40, label %46, label %41
41: ; preds = %37
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
%43 = tail call i32 @close(i32 %20)
%44 = tail call i32 @close(i32 %31)
%45 = tail call i32 @exit(i32 1)
unreachable
46: ; preds = %37
%47 = load i8, i8* %7
%48 = icmp ne i8 %47, 67
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 1
%50 = load i8, i8* %49
%51 = icmp ne i8 %50, 87
%52 = select i1 %48, i1 true, i1 %51
%53 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 2
%54 = load i8, i8* %53
%55 = icmp ne i8 %54, 83
%56 = select i1 %52, i1 true, i1 %55
br i1 %56, label %57, label %60
57: ; preds = %46
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %46
%61 = call i32 @fstat(i32 %20, %struct.stat* %6)
%62 = getelementptr inbounds %struct.stat, %struct.stat* %6, i64 0, i32 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 4
%65 = load i8, i8* %64
%66 = sext i8 %65 to i32
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 5
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = shl nsw i32 %69, 8
%71 = or i32 %70, %66
%72 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 6
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = shl nsw i32 %74, 16
%76 = or i32 %71, %75
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 7
%78 = load i8, i8* %77
%79 = zext i8 %78 to i32
%80 = shl nuw i32 %79, 24
%81 = or i32 %76, %80
%82 = add nsw i32 %63, -4
%83 = add nsw i32 %81, -4
%84 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i32 %82, i32 %83)
store i8 70, i8* %7
%85 = call i32 @write(i32 %31, i8** %38, i32 8)
%86 = icmp slt i32 %85, 8
br i1 %86, label %87, label %90
87: ; preds = %60
%88 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%89 = tail call i32 @exit(i32 1)
unreachable
90: ; preds = %60
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 5
%92 = bitcast i32** %91 to i8*
%93 = call i32 @inflateInit(%struct.TYPE_5__* %5)
%94 = add nsw i32 %63, -8
%95 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 0
%96 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 1
%97 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 2
%98 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 3
%99 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 4
%100 = bitcast [65536 x i8]* %4 to i8**
br label %101
101: ; preds = %130, %90
%102 = phi i32 [ 0, %90 ], [ %131, %130 ]
%103 = icmp slt i32 %102, %94
br i1 %103, label %106, label %104
104: ; preds = %101
%105 = load i32, i32* %95
br label %137
106: ; preds = %101
%107 = call i32 @read(i32 %20, i8** %38, i32 1024)
%108 = load i32, i32* %95
store i8* %7, i8** %96
store i32 %107, i32* %97
store i8* %8, i8** %98
store i32 65536, i32* %99
%109 = load i32, i32* @Z_SYNC_FLUSH
%110 = call i32 @inflate(%struct.TYPE_5__* %5, i32 %109)
%111 = load i32, i32* @Z_STREAM_END
%112 = icmp eq i32 %110, %111
%113 = load i32, i32* @Z_OK
%114 = icmp eq i32 %110, %113
%115 = select i1 %112, i1 true, i1 %114
br i1 %115, label %120, label %116
116: ; preds = %106
%117 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), i32 %110)
%118 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%119 = call i32 @exit(i32 1)
unreachable
120: ; preds = %106
%121 = load i32, i32* %95
%122 = sub nsw i32 %121, %108
%123 = call i32 @write(i32 %31, i8** %100, i32 %122)
%124 = load i32, i32* %95
%125 = sub nsw i32 %124, %108
%126 = icmp slt i32 %123, %125
br i1 %126, label %127, label %130
127: ; preds = %120
%128 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %120
%131 = add nsw i32 %107, %102
%132 = load i32, i32* @Z_STREAM_END
%133 = icmp eq i32 %110, %132
%134 = load i32, i32* @Z_BUF_ERROR
%135 = icmp eq i32 %110, %134
%136 = select i1 %133, i1 true, i1 %135
br i1 %136, label %137, label %101
137: ; preds = %130, %104
%138 = phi i32 [ %105, %104 ], [ %124, %130 ]
%139 = add nsw i32 %81, -8
%140 = icmp eq i32 %138, %139
br i1 %140, label %161, label %141
141: ; preds = %137
%142 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.8, i64 0, i64 0), i32 %138, i32 %139)
%143 = load i32, i32* %95
%144 = trunc i32 %143 to i8
%145 = add i8 %144, 8
store i8 %145, i8* %7
%146 = add nsw i32 %143, 8
%147 = lshr i32 %146, 8
%148 = trunc i32 %147 to i8
store i8 %148, i8* %49
%149 = lshr i32 %146, 16
%150 = trunc i32 %149 to i8
store i8 %150, i8* %53
%151 = lshr i32 %146, 24
%152 = trunc i32 %151 to i8
%153 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 3
store i8 %152, i8* %153
%154 = load i32, i32* @SEEK_SET
%155 = call i32 @lseek(i32 %31, i32 4, i32 %154)
%156 = call i32 @write(i32 %31, i8** %38, i32 4)
%157 = icmp slt i32 %156, 4
br i1 %157, label %158, label %161
158: ; preds = %141
%159 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%160 = call i32 @exit(i32 1)
unreachable
161: ; preds = %141, %137
%162 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%163 = call i32 @close(i32 %20)
%164 = call i32 @close(i32 %31)
ret i32 0
}