#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*/ total_in;
  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 /*<<< orphan*/ write(int, char **, int);
main(int argc, char *argv[]) {
  int fd_in, fd_out, comp_len, uncomp_len, tag, 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 while opening: ");
    exit(1);
  }
  fd_out = open(argv[2], O_WRONLY | O_CREAT, 00644);
  if (fd_out < 0) {
    perror("Error while opening: ");
    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';
  write(fd_out, &buf_in, 8);
  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);
    ("read %d bytes\n", len);
    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);
    }
    ("a_in: %d t_in: %d a_out: %d t_out: %d -- %d out\n", zstream.avail_in,
     zstream.total_in, zstream.avail_out, zstream.total_out,
     zstream.total_out - last_out);
    write(fd_out, &buf_out, zstream.total_out - last_out);
    i += len;
    if (ret == Z_STREAM_END || ret == Z_BUF_ERROR)
      break;
  }
  if (zstream.total_out != uncomp_len - 8) {
    printf("Size mismatch (%d != %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);
    write(fd_out, &buf_in, 4);
  }
  inflateEnd(&zstream);
  close(fd_in);
  close(fd_out);
}


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    0xdaf(%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    0xd8a(%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    0xd40(%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    0xcf3(%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>
movq   $0x0,-0x10438(%rbp)
movq   $0x0,-0x10440(%rbp)
movq   $0x0,-0x10448(%rbp)
lea    -0x10470(%rbp),%rdi
call   1090 <inflateInit@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x1c(%rbp),%ecx
sub    $0x8,%ecx
cmp    %ecx,%eax
jge    14f7 <main+0x337>
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,-0x2c(%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    0x2b91(%rip),%rax
mov    (%rax),%esi
lea    -0x10470(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x1047c(%rbp)
mov    -0x1047c(%rbp),%eax
mov    0x2b78(%rip),%rcx
cmp    (%rcx),%eax
je     149f <main+0x2df>
mov    -0x1047c(%rbp),%eax
mov    0x2b7b(%rip),%rcx
cmp    (%rcx),%eax
je     149f <main+0x2df>
mov    -0x1047c(%rbp),%esi
lea    0xc1f(%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    -0x2c(%rbp),%edx
call   1040 <write@plt>
mov    -0x10480(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1047c(%rbp),%eax
mov    0x2b00(%rip),%rcx
cmp    (%rcx),%eax
je     14ed <main+0x32d>
mov    -0x1047c(%rbp),%eax
mov    0x2adb(%rip),%rcx
cmp    (%rcx),%eax
jne    14f2 <main+0x332>
jmp    14f7 <main+0x337>
jmp    13ca <main+0x20a>
mov    -0x10470(%rbp),%eax
mov    -0x20(%rbp),%ecx
sub    $0x8,%ecx
cmp    %ecx,%eax
je     15a8 <main+0x3e8>
mov    -0x10470(%rbp),%esi
mov    -0x20(%rbp),%edx
sub    $0x8,%edx
lea    0xbd3(%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    0x2a28(%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>
lea    -0x10470(%rbp),%rdi
call   10a0 <inflateEnd@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x18(%rbp),%edi
call   1070 <close@plt>
mov    -0x4(%rbp),%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    1476 <main+0x2a6>
mov    0x8(%rbx),%rdi
mov    0x2de0(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,0x8(%rsp)
test   %eax,%eax
js     1491 <main+0x2c1>
mov    0x10(%rbx),%rdi
mov    0x2d88(%rip),%rax
mov    0x2dd9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    $0x1a4,%edx
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     14a7 <main+0x2d7>
lea    0x60(%rsp),%rsi
mov    0x8(%rsp),%edi
mov    $0x8,%edx
call   1090 <read@plt>
cmp    $0x8,%eax
jne    14b9 <main+0x2e9>
cmpb   $0x43,0x60(%rsp)
jne    14e1 <main+0x311>
cmpb   $0x57,0x61(%rsp)
jne    14e1 <main+0x311>
cmpb   $0x53,0x62(%rsp)
jne    14e1 <main+0x311>
lea    0x10(%rsp),%rsi
mov    0x8(%rsp),%edi
call   10f0 <fstat@plt>
mov    0x10(%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,0x18(%rsp)
add    $0xfffffffc,%edx
lea    0xd7d(%rip),%rdi
xor    %r13d,%r13d
xor    %eax,%eax
call   1060 <printf@plt>
movb   $0x46,0x60(%rsp)
mov    0xc(%rsp),%edi
lea    0x60(%rsp),%rsi
mov    $0x8,%edx
call   1050 <write@plt>
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
nopw   0x0(%rax,%rax,1)
cmp    %ebx,%r13d
jge    13b7 <main+0x1e7>
mov    0x8(%rsp),%edi
mov    %rbp,%r15
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    %r15,%rbp
mov    %eax,0x30(%rsp)
mov    %r15,0x38(%rsp)
movl   $0x10000,0x40(%rsp)
mov    0x2c6e(%rip),%rax
mov    (%rax),%esi
lea    0x20(%rsp),%rdi
call   1030 <inflate@plt>
mov    %eax,%r15d
mov    0x2c60(%rip),%rax
cmp    (%rax),%r15d
je     1385 <main+0x1b5>
mov    0x2c6c(%rip),%rax
cmp    (%rax),%r15d
jne    1451 <main+0x281>
mov    0x20(%rsp),%edx
sub    %r12d,%edx
mov    0xc(%rsp),%edi
mov    %rbp,%rsi
call   1050 <write@plt>
mov    0x2c31(%rip),%rax
cmp    (%rax),%r15d
je     13b7 <main+0x1e7>
add    %r14d,%r13d
mov    0x2c12(%rip),%rax
cmp    (%rax),%r15d
jne    1310 <main+0x140>
mov    0x20(%rsp),%esi
mov    0x18(%rsp),%rdx
add    $0xfffffff8,%edx
cmp    %edx,%esi
je     1421 <main+0x251>
lea    0xcb8(%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    0x2bb2(%rip),%rax
mov    (%rax),%edx
mov    0xc(%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>
lea    0x20(%rsp),%rdi
call   10b0 <inflateEnd@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%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    0xc0f(%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    0xb80(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xb8e(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xb78(%rip),%rdi
call   10d0 <perror@plt>
mov    0x8(%rsp),%edi
jmp    14d2 <main+0x302>
lea    0xc10(%rip),%rdi
call   1040 <puts@plt>
mov    0x8(%rsp),%edi
call   1080 <close@plt>
mov    0xc(%rsp),%edi
call   1080 <close@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    0xbcc(%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*, 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 = [22 x i8] c"Error while opening: \00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.2 = [14 x i8] c"Header error\0A\00"
@.str.3 = [29 x i8] c"Not a compressed flash file\0A\00"
@.str.4 = [43 x i8] c"Compressed size: %d Uncompressed size: %d\0A\00"
@.str.5 = [15 x i8] c"read %d bytes\0A\00"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@Z_OK = global i32 0
@.str.6 = [31 x i8] c"Error while decompressing: %d\0A\00"
@.str.7 = [49 x i8] c"a_in: %d t_in: %d a_out: %d t_out: %d -- %d out\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.8 = [46 x i8] c"Size mismatch (%d != %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 i32
%13 = alloca [1024 x i8]
%14 = alloca [65536 x i8]
%15 = alloca %struct.TYPE_5__
%16 = alloca %struct.stat
%17 = alloca i32
%18 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%19 = load i32, i32* %4
%20 = icmp slt i32 %19, 3
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i32, i32* @O_RDONLY
%32 = call i32 (i8*, i32, ...) @open(i8* %30, i32 %31)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %27
%36 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %27
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 2
%41 = load i8*, i8** %40
%42 = load i32, i32* @O_WRONLY
%43 = load i32, i32* @O_CREAT
%44 = or i32 %42, %43
%45 = call i32 (i8*, i32, ...) @open(i8* %41, i32 %44, i32 420)
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = icmp slt i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %38
%49 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%50 = load i32, i32* %6
%51 = call i32 @close(i32 %50)
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %38
%54 = load i32, i32* %6
%55 = bitcast [1024 x i8]* %13 to i8**
%56 = call i32 @read(i32 %54, i8** %55, i32 8)
%57 = icmp ne i32 %56, 8
br i1 %57, label %58, label %65
58: ; preds = %53
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%60 = load i32, i32* %6
%61 = call i32 @close(i32 %60)
%62 = load i32, i32* %7
%63 = call i32 @close(i32 %62)
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %53
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp ne i32 %68, 67
br i1 %69, label %80, label %70
70: ; preds = %65
%71 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 1
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = icmp ne i32 %73, 87
br i1 %74, label %80, label %75
75: ; preds = %70
%76 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 2
%77 = load i8, i8* %76
%78 = sext i8 %77 to i32
%79 = icmp ne i32 %78, 83
br i1 %79, label %80, label %83
80: ; preds = %75, %70, %65
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0))
%82 = call i32 @exit(i32 1)
unreachable
83: ; preds = %75
%84 = load i32, i32* %6
%85 = call i32 @fstat(i32 %84, %struct.stat* %16)
%86 = getelementptr inbounds %struct.stat, %struct.stat* %16, i32 0, i32 0
%87 = load i32, i32* %86
store i32 %87, i32* %8
%88 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 4
%89 = load i8, i8* %88
%90 = sext i8 %89 to i32
%91 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 5
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = shl i32 %93, 8
%95 = or i32 %90, %94
%96 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 6
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = shl i32 %98, 16
%100 = or i32 %95, %99
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 7
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = shl i32 %103, 24
%105 = or i32 %100, %104
store i32 %105, i32* %9
%106 = load i32, i32* %8
%107 = sub nsw i32 %106, 4
%108 = load i32, i32* %9
%109 = sub nsw i32 %108, 4
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i32 %107, i32 %109)
%111 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
store i8 70, i8* %111
%112 = load i32, i32* %7
%113 = bitcast [1024 x i8]* %13 to i8**
%114 = call i32 @write(i32 %112, i8** %113, i32 8)
%115 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 8
store i32* null, i32** %115
%116 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 7
store i32* null, i32** %116
%117 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 6
store i32* null, i32** %117
%118 = call i32 @inflateInit(%struct.TYPE_5__* %15)
store i32 0, i32* %11
br label %119
119: ; preds = %183, %83
%120 = load i32, i32* %11
%121 = load i32, i32* %8
%122 = sub nsw i32 %121, 8
%123 = icmp slt i32 %120, %122
br i1 %123, label %124, label %184
124: ; preds = %119
%125 = load i32, i32* %6
%126 = bitcast [1024 x i8]* %13 to i8**
%127 = call i32 @read(i32 %125, i8** %126, i32 1024)
store i32 %127, i32* %18
%128 = load i32, i32* %18
%129 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 0
%130 = load i32, i32* %129
store i32 %130, i32* %12
%131 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%132 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 1
store i8* %131, i8** %132
%133 = load i32, i32* %18
%134 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 2
store i32 %133, i32* %134
%135 = getelementptr inbounds [65536 x i8], [65536 x i8]* %14, i64 0, i64 0
%136 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 3
store i8* %135, i8** %136
%137 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 4
store i32 65536, i32* %137
%138 = load i32, i32* @Z_SYNC_FLUSH
%139 = call i32 @inflate(%struct.TYPE_5__* %15, i32 %138)
store i32 %139, i32* %17
%140 = load i32, i32* %17
%141 = load i32, i32* @Z_STREAM_END
%142 = icmp ne i32 %140, %141
br i1 %142, label %143, label %152
143: ; preds = %124
%144 = load i32, i32* %17
%145 = load i32, i32* @Z_OK
%146 = icmp ne i32 %144, %145
br i1 %146, label %147, label %152
147: ; preds = %143
%148 = load i32, i32* %17
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %148)
%150 = call i32 @inflateEnd(%struct.TYPE_5__* %15)
%151 = call i32 @exit(i32 1)
unreachable
152: ; preds = %143, %124
%153 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 2
%154 = load i32, i32* %153
%155 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 5
%156 = load i32, i32* %155
%157 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 4
%158 = load i32, i32* %157
%159 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 0
%160 = load i32, i32* %159
%161 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 0
%162 = load i32, i32* %161
%163 = load i32, i32* %12
%164 = sub nsw i32 %162, %163
%165 = load i32, i32* %7
%166 = bitcast [65536 x i8]* %14 to i8**
%167 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 0
%168 = load i32, i32* %167
%169 = load i32, i32* %12
%170 = sub nsw i32 %168, %169
%171 = call i32 @write(i32 %165, i8** %166, i32 %170)
%172 = load i32, i32* %18
%173 = load i32, i32* %11
%174 = add nsw i32 %173, %172
store i32 %174, i32* %11
%175 = load i32, i32* %17
%176 = load i32, i32* @Z_STREAM_END
%177 = icmp eq i32 %175, %176
br i1 %177, label %182, label %178
178: ; preds = %152
%179 = load i32, i32* %17
%180 = load i32, i32* @Z_BUF_ERROR
%181 = icmp eq i32 %179, %180
br i1 %181, label %182, label %183
182: ; preds = %178, %152
br label %184
183: ; preds = %178
br label %119
184: ; preds = %182, %119
%185 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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 %229
190: ; preds = %184
%191 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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 ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i32 %192, i32 %194)
%196 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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]* %13, i64 0, i64 0
store i8 %200, i8* %201
%202 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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]* %13, i64 0, i64 1
store i8 %207, i8* %208
%209 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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]* %13, i64 0, i64 2
store i8 %214, i8* %215
%216 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, 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]* %13, 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]* %13 to i8**
%228 = call i32 @write(i32 %226, i8** %227, i32 4)
br label %229
229: ; preds = %190, %184
%230 = call i32 @inflateEnd(%struct.TYPE_5__* %15)
%231 = load i32, i32* %6
%232 = call i32 @close(i32 %231)
%233 = load i32, i32* %7
%234 = call i32 @close(i32 %233)
%235 = load i32, i32* %3
ret i32 %235
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i8*, i32, i8*, i32, 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 = [22 x i8] c"Error while opening: \00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.4 = [43 x i8] c"Compressed size: %d Uncompressed size: %d\0A\00"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@Z_OK = global i32 0
@.str.6 = [31 x i8] c"Error while decompressing: %d\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.8 = [46 x i8] c"Size mismatch (%d != %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 ([22 x i8], [22 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 ([22 x i8], [22 x i8]* @.str.1, 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.4, i64 0, i64 0), i32 %82, i32 %83)
store i8 70, i8* %7
%85 = call i32 @write(i32 %31, i8** %38, i32 8)
%86 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 6
%87 = bitcast i32** %86 to i8*
%88 = call i32 @inflateInit(%struct.TYPE_5__* %5)
%89 = add nsw i32 %63, -8
%90 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 0
%91 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 1
%92 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 2
%93 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 3
%94 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 4
%95 = bitcast [65536 x i8]* %4 to i8**
br label %96
96: ; preds = %113, %60
%97 = phi i32 [ 0, %60 ], [ %117, %113 ]
%98 = icmp slt i32 %97, %89
br i1 %98, label %99, label %123
99: ; preds = %96
%100 = call i32 @read(i32 %20, i8** %38, i32 1024)
%101 = load i32, i32* %90
store i8* %7, i8** %91
store i32 %100, i32* %92
store i8* %8, i8** %93
store i32 65536, i32* %94
%102 = load i32, i32* @Z_SYNC_FLUSH
%103 = call i32 @inflate(%struct.TYPE_5__* %5, i32 %102)
%104 = load i32, i32* @Z_STREAM_END
%105 = icmp eq i32 %103, %104
%106 = load i32, i32* @Z_OK
%107 = icmp eq i32 %103, %106
%108 = select i1 %105, i1 true, i1 %107
br i1 %108, label %113, label %109
109: ; preds = %99
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0), i32 %103)
%111 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %99
%114 = load i32, i32* %90
%115 = sub nsw i32 %114, %101
%116 = call i32 @write(i32 %31, i8** %95, i32 %115)
%117 = add nsw i32 %100, %97
%118 = load i32, i32* @Z_STREAM_END
%119 = icmp eq i32 %103, %118
%120 = load i32, i32* @Z_BUF_ERROR
%121 = icmp eq i32 %103, %120
%122 = select i1 %119, i1 true, i1 %121
br i1 %122, label %123, label %96
123: ; preds = %113, %96
%124 = load i32, i32* %90
%125 = add nsw i32 %81, -8
%126 = icmp eq i32 %124, %125
br i1 %126, label %143, label %127
127: ; preds = %123
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), i32 %124, i32 %125)
%129 = load i32, i32* %90
%130 = trunc i32 %129 to i8
%131 = add i8 %130, 8
store i8 %131, i8* %7
%132 = add nsw i32 %129, 8
%133 = lshr i32 %132, 8
%134 = trunc i32 %133 to i8
store i8 %134, i8* %49
%135 = lshr i32 %132, 16
%136 = trunc i32 %135 to i8
store i8 %136, i8* %53
%137 = lshr i32 %132, 24
%138 = trunc i32 %137 to i8
%139 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 3
store i8 %138, i8* %139
%140 = load i32, i32* @SEEK_SET
%141 = call i32 @lseek(i32 %31, i32 4, i32 %140)
%142 = call i32 @write(i32 %31, i8** %38, i32 4)
br label %143
143: ; preds = %127, %123
%144 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%145 = call i32 @close(i32 %20)
%146 = call i32 @close(i32 %31)
ret i32 0
}