#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 /*<<< orphan*/ 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 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);
    ;
    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);
    }

    ;
    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 (%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);
    write(fd_out, &buf_in, 4);
  }
  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    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,-0x24(%rbp)
mov    -0x24(%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,-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    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    0xc10(%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    -0x10480(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%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    0xb93(%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>
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    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    0xc11(%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    0xbcd(%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 = [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"
@Z_SYNC_FLUSH = global i32 0
@Z_STREAM_END = global i32 0
@Z_OK = global i32 0
@.str.5 = [31 x i8] c"Error while decompressing: %d\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.6 = [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 ([22 x i8], [22 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 ([22 x i8], [22 x i8]* @.str.1, 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.2, 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.3, 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.4, 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 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 7
store i32* null, i32** %114
%115 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 6
store i32* null, i32** %115
%116 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 5
store i32* null, i32** %116
%117 = call i32 @inflateInit(%struct.TYPE_5__* %14)
store i32 0, i32* %10
br label %118
118: ; preds = %169, %82
%119 = load i32, i32* %10
%120 = load i32, i32* %8
%121 = sub nsw i32 %120, 8
%122 = icmp slt i32 %119, %121
br i1 %122, label %123, label %170
123: ; preds = %118
%124 = load i32, i32* %6
%125 = bitcast [1024 x i8]* %12 to i8**
%126 = call i32 @read(i32 %124, i8** %125, i32 1024)
store i32 %126, i32* %17
%127 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%128 = load i32, i32* %127
store i32 %128, i32* %11
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%130 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 1
store i8* %129, i8** %130
%131 = load i32, i32* %17
%132 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 2
store i32 %131, i32* %132
%133 = getelementptr inbounds [65536 x i8], [65536 x i8]* %13, i64 0, i64 0
%134 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 3
store i8* %133, i8** %134
%135 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 4
store i32 65536, i32* %135
%136 = load i32, i32* @Z_SYNC_FLUSH
%137 = call i32 @inflate(%struct.TYPE_5__* %14, i32 %136)
store i32 %137, i32* %16
%138 = load i32, i32* %16
%139 = load i32, i32* @Z_STREAM_END
%140 = icmp ne i32 %138, %139
br i1 %140, label %141, label %150
141: ; preds = %123
%142 = load i32, i32* %16
%143 = load i32, i32* @Z_OK
%144 = icmp ne i32 %142, %143
br i1 %144, label %145, label %150
145: ; preds = %141
%146 = load i32, i32* %16
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %146)
%148 = call i32 @inflateEnd(%struct.TYPE_5__* %14)
%149 = call i32 @exit(i32 1)
unreachable
150: ; preds = %141, %123
%151 = load i32, i32* %7
%152 = bitcast [65536 x i8]* %13 to i8**
%153 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%154 = load i32, i32* %153
%155 = load i32, i32* %11
%156 = sub nsw i32 %154, %155
%157 = call i32 @write(i32 %151, i8** %152, i32 %156)
%158 = load i32, i32* %17
%159 = load i32, i32* %10
%160 = add nsw i32 %159, %158
store i32 %160, i32* %10
%161 = load i32, i32* %16
%162 = load i32, i32* @Z_STREAM_END
%163 = icmp eq i32 %161, %162
br i1 %163, label %168, label %164
164: ; preds = %150
%165 = load i32, i32* %16
%166 = load i32, i32* @Z_BUF_ERROR
%167 = icmp eq i32 %165, %166
br i1 %167, label %168, label %169
168: ; preds = %164, %150
br label %170
169: ; preds = %164
br label %118
170: ; preds = %168, %118
%171 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%172 = load i32, i32* %171
%173 = load i32, i32* %9
%174 = sub nsw i32 %173, 8
%175 = icmp ne i32 %172, %174
br i1 %175, label %176, label %215
176: ; preds = %170
%177 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%178 = load i32, i32* %177
%179 = load i32, i32* %9
%180 = sub nsw i32 %179, 8
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.6, i64 0, i64 0), i32 %178, i32 %180)
%182 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%183 = load i32, i32* %182
%184 = add nsw i32 %183, 8
%185 = and i32 %184, 255
%186 = trunc i32 %185 to i8
%187 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
store i8 %186, i8* %187
%188 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%189 = load i32, i32* %188
%190 = add nsw i32 %189, 8
%191 = ashr i32 %190, 8
%192 = and i32 %191, 255
%193 = trunc i32 %192 to i8
%194 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 1
store i8 %193, i8* %194
%195 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i32 0, i32 0
%196 = load i32, i32* %195
%197 = add nsw i32 %196, 8
%198 = ashr i32 %197, 16
%199 = and i32 %198, 255
%200 = trunc i32 %199 to i8
%201 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 2
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, 24
%206 = and i32 %205, 255
%207 = trunc i32 %206 to i8
%208 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 3
store i8 %207, i8* %208
%209 = load i32, i32* %7
%210 = load i32, i32* @SEEK_SET
%211 = call i32 @lseek(i32 %209, i32 4, i32 %210)
%212 = load i32, i32* %7
%213 = bitcast [1024 x i8]* %12 to i8**
%214 = call i32 @write(i32 %212, i8** %213, i32 4)
br label %215
215: ; preds = %176, %170
%216 = call i32 @inflateEnd(%struct.TYPE_5__* %14)
%217 = load i32, i32* %6
%218 = call i32 @close(i32 %217)
%219 = load i32, i32* %7
%220 = call i32 @close(i32 %219)
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 = [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.5 = [31 x i8] c"Error while decompressing: %d\0A\00"
@Z_BUF_ERROR = global i32 0
@.str.6 = [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.7 = [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.7, 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 5
%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.5, 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 ([47 x i8], [47 x i8]* @.str.6, 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
}