#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*/ FILE;

/* Variables and functions */
int Z_OK;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(char *);
char *zlib_error2str(int);
int zlib_inflate(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  FILE *fin, *fout;
  int result;
  if (argc != 3) {
    usage(argv[0]);
    exit(1);
  }
  fin = fopen(argv[1], "r");
  if (fin == NULL) {
    fprintf(stderr, "couldn't open input file '%s'\n", argv[1]);
    exit(1);
  }
  fout = fopen(argv[2], "w");
  if (fin == NULL) {
    fprintf(stderr, "couldn't open output file '%s'\n", argv[2]);
    exit(1);
  }
  result = zlib_inflate(fin, fout);
  if (result != Z_OK) {
    fprintf(stderr, "zlib error %s\n", zlib_error2str(result));
    exit(1);
  }
  fclose(fin);
  fclose(fout);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11a6 <main+0x36>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1070 <usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11f0 <main+0x80>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe21(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe22(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123a <main+0xca>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdf8(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <zlib_inflate@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    0x2d9c(%rip),%rcx
cmp    (%rcx),%eax
je     128c <main+0x11c>
mov    0x2d75(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <zlib_error2str@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xdc6(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    11a7 <main+0x37>
mov    0x8(%rbx),%rdi
lea    0xe79(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
jne    11b9 <main+0x49>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe5d(%rip),%rsi
jmp    1218 <main+0xa8>
mov    (%rbx),%rdi
call   1070 <usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
lea    0xe5a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <zlib_inflate@plt>
mov    0x2e0f(%rip),%rcx
cmp    (%rcx),%eax
jne    11fc <main+0x8c>
mov    %r14,%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2dd5(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1030 <zlib_error2str@plt>
lea    0xe10(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"couldn't open input file '%s'\0A\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [32 x i8] c"couldn't open output file '%s'\0A\00"
@Z_OK = global i32 0
@.str.4 = [15 x i8] c"zlib error %s\0A\00"
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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 3
br i1 %10, label %11, label %17
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @usage(i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %31
24: ; preds = %17
%25 = load i32, i32* @stderr
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %17
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %35, i32** %7
%36 = load i32*, i32** %6
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %45
38: ; preds = %31
%39 = load i32, i32* @stderr
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 2
%42 = load i8*, i8** %41
%43 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* %42)
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %31
%46 = load i32*, i32** %6
%47 = load i32*, i32** %7
%48 = call i32 @zlib_inflate(i32* %46, i32* %47)
store i32 %48, i32* %8
%49 = load i32, i32* %8
%50 = load i32, i32* @Z_OK
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %58
52: ; preds = %45
%53 = load i32, i32* @stderr
%54 = load i32, i32* %8
%55 = call i8* @zlib_error2str(i32 %54)
%56 = call i32 @fprintf(i32 %53, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %45
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
%61 = load i32*, i32** %7
%62 = call i32 @fclose(i32* %61)
%63 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [31 x i8] c"couldn't open input file '%s'\0A\00"
@.str.2 = [2 x i8] c"w\00"
@Z_OK = global i32 0
@.str.4 = [15 x i8] c"zlib error %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %8
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @zlib_inflate(i32* %11, i32* %21)
%23 = load i32, i32* @Z_OK
%24 = icmp eq i32 %22, %23
br i1 %24, label %30, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = tail call i8* @zlib_error2str(i32 %22)
%28 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 1)
unreachable
30: ; preds = %18
%31 = tail call i32 @fclose(i32* %11)
%32 = tail call i32 @fclose(i32* %21)
%33 = tail call i32 @exit(i32 0)
unreachable
}