#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
typedef int uint32_t;
struct stat {
  int /*<<< orphan*/ st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EfiCompress(int /*<<< orphan*/ *, int, int /*<<< orphan*/ *, int *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *malloc(int);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ stat(char *, struct stat *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
char *strrchr(char *, char);
int main(int argc, char *argv[]) {
  char *progname;
  int retval = 1;
  progname = strrchr(argv[0], '/');
  if (progname)
    progname++;
  else
    progname = argv[0];
  if (argc != 3) {
    fprintf(stderr, "\nUsage:  %s INFILE OUTFILE\n\n", progname);
    exit(1);
  }
  char *infile = argv[1];
  char *outfile = argv[2];
  struct stat istat;
  if (0 != stat(infile, &istat)) {
    fprintf(stderr, "%s: can't stat %s: %s\n", progname, infile,
            strerror(errno));
    exit(1);
  }
  uint32_t isize = (uint32_t)istat.st_size;
  printf("%s is %d bytes\n", infile, isize);
  FILE *ifp = fopen(infile, "rb");
  if (!ifp) {
    fprintf(stderr, "%s: can't read %s: %s\n", progname, infile,
            strerror(errno));
    exit(1);
  }
  uint8_t *ibuf = malloc(isize);
  if (!ibuf) {
    fprintf(stderr, "%s: can't malloc %d bytes: %s\n", progname, isize,
            strerror(errno));
    goto done1;
  }
  if (1 != fread(ibuf, isize, 1, ifp)) {
    fprintf(stderr, "%s: can't read %d bytes: %s\n", progname, isize,
            strerror(errno));
    goto done2;
  }
  uint32_t osize = isize;
  uint8_t *obuf = malloc(osize);
  if (!obuf) {
    fprintf(stderr, "%s: can't allocate %d bytes: %s\n", progname, osize,
            strerror(errno));
    goto done2;
  }
  int r = EfiCompress(ibuf, isize, obuf, &osize);
  if (r != 0) {
    fprintf(stderr, "%s: compression failed with code %d\n", progname, r);
    goto done3;
  }
  printf("Compressed %d bytes to %d bytes\n", isize, osize);
  FILE *ofp = fopen(outfile, "wb");
  if (!ofp) {
    fprintf(stderr, "%s: can't open %s for writing: %s\n", progname, outfile,
            strerror(errno));
    goto done3;
  }
  if (1 != fwrite(obuf, osize, 1, ofp)) {
    fprintf(stderr, "%s: can't write %d bytes: %s\n", progname, osize,
            strerror(errno));
    goto done4;
  }
  printf("wrote %d bytes to %s\n", osize, outfile);
  retval = 0;
done4:
  fclose(ofp);
done3:
  free(obuf);
done2:
  free(ibuf);
done1:
  fclose(ifp);
  return retval;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1221 <main+0x51>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    122c <main+0x5c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     125b <main+0x8b>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdb6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1090 <stat@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     12e4 <main+0x114>
mov    0x2d4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    -0x78(%rbp),%rcx
mov    %rax,%r8
lea    0xd4a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x3c(%rbp),%edx
lea    0xd3c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
lea    0xd3a(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    1380 <main+0x1b0>
mov    0x2cbb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x2c8e(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0x9c(%rbp),%edi
mov    -0x98(%rbp),%rdx
mov    -0x90(%rbp),%rcx
mov    %rax,%r8
lea    0xcd8(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x3c(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    13f1 <main+0x221>
mov    0x2c42(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0xa0(%rbp)
mov    0x2c17(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%ecx
mov    %rax,%r8
lea    0xc79(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    166f <main+0x49f>
mov    -0x50(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x48(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     146f <main+0x29f>
mov    0x2bc4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0xb0(%rbp)
mov    0x2b99(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xbc(%rbp),%edi
mov    -0xb8(%rbp),%rdx
mov    -0xb0(%rbp),%ecx
mov    %rax,%r8
lea    0xc1a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1666 <main+0x496>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x54(%rbp),%edi
call   10a0 <malloc@plt>
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
jne    14e6 <main+0x316>
mov    0x2b4d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0xc0(%rbp)
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rdx
mov    -0xc0(%rbp),%ecx
mov    %rax,%r8
lea    0xbc0(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1666 <main+0x496>
mov    -0x50(%rbp),%rdi
mov    -0x3c(%rbp),%esi
mov    -0x60(%rbp),%rdx
lea    -0x54(%rbp),%rcx
call   10b0 <EfiCompress@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
je     152a <main+0x35a>
mov    0x2ad2(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x64(%rbp),%ecx
lea    0xb9d(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    165d <main+0x48d>
mov    -0x3c(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    0xba9(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%rdi
lea    0xbb8(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x70(%rbp)
jne    15ba <main+0x3ea>
mov    0x2a7c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xe4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0xd8(%rbp)
mov    0x2a4f(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xe4(%rbp),%edi
mov    -0xe0(%rbp),%rdx
mov    -0xd8(%rbp),%rcx
mov    %rax,%r8
lea    0xb56(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    165d <main+0x48d>
mov    -0x60(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    -0x70(%rbp),%rcx
mov    $0x1,%edx
call   10e0 <fwrite@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
je     1638 <main+0x468>
mov    0x29fb(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xf4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0xe8(%rbp)
mov    0x29d0(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
mov    -0xf4(%rbp),%edi
mov    -0xf0(%rbp),%rdx
mov    -0xe8(%rbp),%ecx
mov    %rax,%r8
lea    0xafb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1654 <main+0x484>
mov    -0x54(%rbp),%esi
mov    -0x30(%rbp),%rdx
lea    0xaff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x70(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x60(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x1c(%rbp),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%r14d
mov    (%rsi),%rbp
mov    %rbp,%rdi
mov    $0x2f,%esi
call   1070 <strrchr@plt>
lea    0x1(%rax),%r13
test   %rax,%rax
cmove  %rbp,%r13
cmp    $0x3,%r14d
jne    1483 <main+0x2b3>
mov    0x8(%rbx),%rbp
mov    0x10(%rbx),%rbx
lea    0x8(%rsp),%rsi
mov    %rbp,%rdi
call   1090 <stat@plt>
test   %rax,%rax
jne    14a7 <main+0x2d7>
mov    0x8(%rsp),%r12d
lea    0xe01(%rip),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdfd(%rip),%rsi
mov    %rbp,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     14c7 <main+0x2f7>
mov    %rax,%r14
mov    %r12d,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     12ec <main+0x11c>
mov    %rax,%r15
mov    $0x1,%ebp
mov    %rax,%rdi
mov    %r12d,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
cmp    $0x1,%eax
jne    1326 <main+0x156>
mov    %r12d,0x4(%rsp)
mov    %r12d,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1346 <main+0x176>
lea    0x4(%rsp),%rcx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %rax,0x10(%rsp)
mov    %rax,%rdx
call   10b0 <EfiCompress@plt>
test   %eax,%eax
je     137b <main+0x1ab>
mov    0x2d13(%rip),%rcx
mov    (%rcx),%edi
lea    0xde5(%rip),%rsi
mov    %r13,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebp
jmp    1458 <main+0x288>
mov    0x2ced(%rip),%rax
mov    (%rax),%ebx
mov    0x2cdc(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd54(%rip),%rsi
mov    %ebx,%edi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebp
jmp    146a <main+0x29a>
mov    0x2cb3(%rip),%rax
mov    (%rax),%ebx
mov    0x2ca2(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd39(%rip),%rsi
jmp    1364 <main+0x194>
mov    0x2c93(%rip),%rax
mov    (%rax),%ebx
mov    0x2c82(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd36(%rip),%rsi
mov    %ebx,%edi
mov    %r13,%rdx
mov    %r12d,%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1462 <main+0x292>
mov    0x4(%rsp),%edx
lea    0xd5a(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd6a(%rip),%rsi
mov    %rbx,%rdi
call   10c0 <fopen@plt>
test   %rax,%rax
je     13e0 <main+0x210>
mov    %rax,%r12
mov    0x4(%rsp),%esi
mov    $0x1,%ebp
mov    0x10(%rsp),%rdi
mov    $0x1,%edx
mov    %rax,%rcx
call   10e0 <fwrite@plt>
cmp    $0x1,%eax
jne    1417 <main+0x247>
mov    0x4(%rsp),%esi
lea    0xd73(%rip),%rdi
xor    %ebp,%ebp
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1450 <main+0x280>
mov    0x2bf9(%rip),%rax
mov    (%rax),%ebp
mov    0x2be8(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xd06(%rip),%rsi
mov    %ebp,%edi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebp
jmp    1458 <main+0x288>
mov    0x2bc2(%rip),%rax
mov    (%rax),%ebx
mov    0x4(%rsp),%eax
mov    %eax,0xc(%rsp)
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xcea(%rip),%rsi
mov    %ebx,%edi
mov    %r13,%rdx
mov    0xc(%rsp),%ecx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b56(%rip),%rax
mov    (%rax),%edi
lea    0xb6d(%rip),%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    0x2b32(%rip),%rax
mov    (%rax),%ebx
mov    0x2b21(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xb58(%rip),%rsi
jmp    14e5 <main+0x315>
mov    0x2b12(%rip),%rax
mov    (%rax),%ebx
mov    0x2b01(%rip),%rax
mov    (%rax),%edi
call   10f0 <strerror@plt>
lea    0xb62(%rip),%rsi
mov    %ebx,%edi
mov    %r13,%rdx
mov    %rbp,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"\0AUsage: %s INFILE OUTFILE\0A\0A\00"
@.str.1 = [23 x i8] c"%s: can't stat %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [16 x i8] c"%s is %d bytes\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [23 x i8] c"%s: can't read %s: %s\0A\00"
@.str.5 = [31 x i8] c"%s: can't malloc %d bytes: %s\0A\00"
@.str.6 = [29 x i8] c"%s: can't read %d bytes: %s\0A\00"
@.str.7 = [33 x i8] c"%s: can't allocate %d bytes: %s\0A\00"
@.str.8 = [37 x i8] c"%s: compression failed with code %d\0A\00"
@.str.9 = [33 x i8] c"Compressed %d bytes to %d bytes\0A\00"
@.str.10 = [3 x i8] c"wb\00"
@.str.11 = [35 x i8] c"%s: can't open %s for writing: %s\0A\00"
@.str.12 = [30 x i8] c"%s: can't write %d bytes: %s\0A\00"
@.str.13 = [22 x i8] c"wrote %d bytes to %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca %struct.stat
%11 = alloca i32
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %7
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i8* @strrchr(i8* %20, i8 signext 47)
store i8* %21, i8** %6
%22 = load i8*, i8** %6
%23 = icmp ne i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %2
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %6
br label %31
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
store i8* %30, i8** %6
br label %31
31: ; preds = %27, %24
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 3
br i1 %33, label %34, label %39
34: ; preds = %31
%35 = load i32, i32* @stderr
%36 = load i8*, i8** %6
%37 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %31
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
store i8* %42, i8** %8
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 2
%45 = load i8*, i8** %44
store i8* %45, i8** %9
%46 = load i8*, i8** %8
%47 = call i64 @stat(i8* %46, %struct.stat* %10)
%48 = icmp ne i64 0, %47
br i1 %48, label %49, label %57
49: ; preds = %39
%50 = load i32, i32* @stderr
%51 = load i8*, i8** %6
%52 = load i8*, i8** %8
%53 = load i32, i32* @errno
%54 = call i8* @strerror(i32 %53)
%55 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %52, i8* %54)
%56 = call i32 @exit(i32 1)
unreachable
57: ; preds = %39
%58 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%59 = load i32, i32* %58
store i32 %59, i32* %11
%60 = load i8*, i8** %8
%61 = load i32, i32* %11
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %60, i32 %61)
%63 = load i8*, i8** %8
%64 = call i32* @fopen(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %64, i32** %12
%65 = load i32*, i32** %12
%66 = icmp ne i32* %65, null
br i1 %66, label %75, label %67
67: ; preds = %57
%68 = load i32, i32* @stderr
%69 = load i8*, i8** %6
%70 = load i8*, i8** %8
%71 = load i32, i32* @errno
%72 = call i8* @strerror(i32 %71)
%73 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %68, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %69, i8* %70, i8* %72)
%74 = call i32 @exit(i32 1)
unreachable
75: ; preds = %57
%76 = load i32, i32* %11
%77 = call i32* @malloc(i32 %76)
store i32* %77, i32** %13
%78 = load i32*, i32** %13
%79 = icmp ne i32* %78, null
br i1 %79, label %87, label %80
80: ; preds = %75
%81 = load i32, i32* @stderr
%82 = load i8*, i8** %6
%83 = load i32, i32* %11
%84 = load i32, i32* @errno
%85 = call i8* @strerror(i32 %84)
%86 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %82, i32 %83, i8* %85)
br label %166
87: ; preds = %75
%88 = load i32*, i32** %13
%89 = load i32, i32* %11
%90 = load i32*, i32** %12
%91 = call i32 @fread(i32* %88, i32 %89, i32 1, i32* %90)
%92 = icmp ne i32 1, %91
br i1 %92, label %93, label %100
93: ; preds = %87
%94 = load i32, i32* @stderr
%95 = load i8*, i8** %6
%96 = load i32, i32* %11
%97 = load i32, i32* @errno
%98 = call i8* @strerror(i32 %97)
%99 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %95, i32 %96, i8* %98)
br label %163
100: ; preds = %87
%101 = load i32, i32* %11
store i32 %101, i32* %14
%102 = load i32, i32* %14
%103 = call i32* @malloc(i32 %102)
store i32* %103, i32** %15
%104 = load i32*, i32** %15
%105 = icmp ne i32* %104, null
br i1 %105, label %113, label %106
106: ; preds = %100
%107 = load i32, i32* @stderr
%108 = load i8*, i8** %6
%109 = load i32, i32* %14
%110 = load i32, i32* @errno
%111 = call i8* @strerror(i32 %110)
%112 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %107, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %108, i32 %109, i8* %111)
br label %163
113: ; preds = %100
%114 = load i32*, i32** %13
%115 = load i32, i32* %11
%116 = load i32*, i32** %15
%117 = call i32 @EfiCompress(i32* %114, i32 %115, i32* %116, i32* %14)
store i32 %117, i32* %16
%118 = load i32, i32* %16
%119 = icmp ne i32 %118, 0
br i1 %119, label %120, label %125
120: ; preds = %113
%121 = load i32, i32* @stderr
%122 = load i8*, i8** %6
%123 = load i32, i32* %16
%124 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %122, i32 %123)
br label %160
125: ; preds = %113
%126 = load i32, i32* %11
%127 = load i32, i32* %14
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %126, i32 %127)
%129 = load i8*, i8** %9
%130 = call i32* @fopen(i8* %129, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
store i32* %130, i32** %17
%131 = load i32*, i32** %17
%132 = icmp ne i32* %131, null
br i1 %132, label %140, label %133
133: ; preds = %125
%134 = load i32, i32* @stderr
%135 = load i8*, i8** %6
%136 = load i8*, i8** %9
%137 = load i32, i32* @errno
%138 = call i8* @strerror(i32 %137)
%139 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %134, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i8* %135, i8* %136, i8* %138)
br label %160
140: ; preds = %125
%141 = load i32*, i32** %15
%142 = load i32, i32* %14
%143 = load i32*, i32** %17
%144 = call i32 @fwrite(i32* %141, i32 %142, i32 1, i32* %143)
%145 = icmp ne i32 1, %144
br i1 %145, label %146, label %153
146: ; preds = %140
%147 = load i32, i32* @stderr
%148 = load i8*, i8** %6
%149 = load i32, i32* %14
%150 = load i32, i32* @errno
%151 = call i8* @strerror(i32 %150)
%152 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %147, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %148, i32 %149, i8* %151)
br label %157
153: ; preds = %140
%154 = load i32, i32* %14
%155 = load i8*, i8** %9
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %154, i8* %155)
store i32 0, i32* %7
br label %157
157: ; preds = %153, %146
%158 = load i32*, i32** %17
%159 = call i32 @fclose(i32* %158)
br label %160
160: ; preds = %157, %133, %120
%161 = load i32*, i32** %15
%162 = call i32 @free(i32* %161)
br label %163
163: ; preds = %160, %106, %93
%164 = load i32*, i32** %13
%165 = call i32 @free(i32* %164)
br label %166
166: ; preds = %163, %80
%167 = load i32*, i32** %12
%168 = call i32 @fclose(i32* %167)
%169 = load i32, i32* %7
ret i32 %169
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@stderr = global i32 0
@.str = [29 x i8] c"\0AUsage: %s INFILE OUTFILE\0A\0A\00"
@.str.1 = [23 x i8] c"%s: can't stat %s: %s\0A\00"
@errno = global i32 0
@.str.2 = [16 x i8] c"%s is %d bytes\0A\00"
@.str.3 = [3 x i8] c"rb\00"
@.str.4 = [23 x i8] c"%s: can't read %s: %s\0A\00"
@.str.5 = [31 x i8] c"%s: can't malloc %d bytes: %s\0A\00"
@.str.6 = [29 x i8] c"%s: can't read %d bytes: %s\0A\00"
@.str.7 = [33 x i8] c"%s: can't allocate %d bytes: %s\0A\00"
@.str.8 = [37 x i8] c"%s: compression failed with code %d\0A\00"
@.str.9 = [33 x i8] c"Compressed %d bytes to %d bytes\0A\00"
@.str.10 = [3 x i8] c"wb\00"
@.str.11 = [35 x i8] c"%s: can't open %s for writing: %s\0A\00"
@.str.12 = [30 x i8] c"%s: can't write %d bytes: %s\0A\00"
@.str.13 = [22 x i8] c"wrote %d bytes to %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = alloca i32
%5 = load i8*, i8** %1
%6 = tail call i8* @strrchr(i8* dereferenceable(1) %5, i8 signext 47)
%7 = icmp eq i8* %6, null
%8 = getelementptr inbounds i8, i8* %6, i64 1
%9 = select i1 %7, i8* %5, i8* %8
%10 = icmp eq i32 %0, 3
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %9)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = bitcast %struct.stat* %3 to i8*
%21 = call i64 @stat(i8* %17, %struct.stat* %3)
%22 = icmp eq i64 %21, 0
br i1 %22, label %29, label %23
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = load i32, i32* @errno
%26 = call i8* @strerror(i32 %25)
%27 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %17, i8* %26)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %15
%30 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %17, i32 %31)
%33 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp eq i32* %33, null
br i1 %34, label %35, label %41
35: ; preds = %29
%36 = load i32, i32* @stderr
%37 = load i32, i32* @errno
%38 = call i8* @strerror(i32 %37)
%39 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %9, i8* %17, i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %29
%42 = call i32* @malloc(i32 %31)
%43 = icmp eq i32* %42, null
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i32, i32* @stderr
%46 = load i32, i32* @errno
%47 = call i8* @strerror(i32 %46)
%48 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i8* %9, i32 %31, i8* %47)
br label %103
49: ; preds = %41
%50 = call i32 @fread(i32* %42, i32 %31, i32 1, i32* %33)
%51 = icmp eq i32 %50, 1
br i1 %51, label %57, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = load i32, i32* @errno
%55 = call i8* @strerror(i32 %54)
%56 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.6, i64 0, i64 0), i8* %9, i32 %31, i8* %55)
br label %100
57: ; preds = %49
store i32 %31, i32* %4
%58 = call i32* @malloc(i32 %31)
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %65
60: ; preds = %57
%61 = load i32, i32* @stderr
%62 = load i32, i32* @errno
%63 = call i8* @strerror(i32 %62)
%64 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %61, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %9, i32 %31, i8* %63)
br label %100
65: ; preds = %57
%66 = call i32 @EfiCompress(i32* %42, i32 %31, i32* %58, i32* %4)
%67 = icmp eq i32 %66, 0
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0), i8* %9, i32 %66)
br label %97
71: ; preds = %65
%72 = load i32, i32* %4
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i32 %31, i32 %72)
%74 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%75 = icmp eq i32* %74, null
br i1 %75, label %76, label %81
76: ; preds = %71
%77 = load i32, i32* @stderr
%78 = load i32, i32* @errno
%79 = call i8* @strerror(i32 %78)
%80 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.11, i64 0, i64 0), i8* %9, i8* %19, i8* %79)
br label %97
81: ; preds = %71
%82 = load i32, i32* %4
%83 = call i32 @fwrite(i32* %58, i32 %82, i32 1, i32* %74)
%84 = icmp eq i32 %83, 1
br i1 %84, label %91, label %85
85: ; preds = %81
%86 = load i32, i32* @stderr
%87 = load i32, i32* %4
%88 = load i32, i32* @errno
%89 = call i8* @strerror(i32 %88)
%90 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i8* %9, i32 %87, i8* %89)
br label %94
91: ; preds = %81
%92 = load i32, i32* %4
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %92, i8* %19)
br label %94
94: ; preds = %91, %85
%95 = phi i32 [ 1, %85 ], [ 0, %91 ]
%96 = call i32 @fclose(i32* %74)
br label %97
97: ; preds = %94, %76, %68
%98 = phi i32 [ 1, %68 ], [ %95, %94 ], [ 1, %76 ]
%99 = call i32 @free(i32* %58)
br label %100
100: ; preds = %97, %60, %52
%101 = phi i32 [ 1, %52 ], [ %98, %97 ], [ 1, %60 ]
%102 = call i32 @free(i32* %42)
br label %103
103: ; preds = %100, %44
%104 = phi i32 [ %101, %100 ], [ 1, %44 ]
%105 = call i32 @fclose(i32* %33)
ret i32 %104
}