#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*/ gzFile;
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
int /*<<< orphan*/ gzclose(int /*<<< orphan*/);
int /*<<< orphan*/ gzopen(char *, char *);
int gzread(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ gzwrite(char *, char *, int);
int decompress_one_file(char *infilename, char *outfilename) {
  gzFile infile = gzopen(infilename, "rb");
  char buffer[128];
  int num_read = 0;
  if (!infile)
    return -1;
  while ((num_read = gzread(infile, buffer, sizeof(buffer))) > 0) {
    gzwrite(buffer, outfilename, num_read);
  }
  gzclose(infile);
  return 0;
}


x86 assembly (clang, -O0):
<decompress_one_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1060 <gzopen@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0xa4(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1186 <decompress_one_file+0x46>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d8 <decompress_one_file+0x98>
jmp    118b <decompress_one_file+0x4b>
mov    -0x1c(%rbp),%edi
lea    -0xa0(%rbp),%rsi
mov    $0x80,%edx
call   1040 <gzread@plt>
mov    %eax,-0xa4(%rbp)
cmp    $0x0,%eax
jle    11c9 <decompress_one_file+0x89>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xa4(%rbp),%edx
call   1050 <gzwrite@plt>
jmp    118b <decompress_one_file+0x4b>
mov    -0x1c(%rbp),%edi
call   1030 <gzclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<decompress_one_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %rsi,%r14
lea    0xeab(%rip),%rsi
call   1060 <gzopen@plt>
test   %eax,%eax
je     11ab <decompress_one_file+0x6b>
mov    %eax,%ebp
mov    %rsp,%rsi
mov    %eax,%edi
mov    $0x80,%edx
call   1040 <gzread@plt>
test   %eax,%eax
jle    11a0 <decompress_one_file+0x60>
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1050 <gzwrite@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1040 <gzread@plt>
test   %eax,%eax
jg     1180 <decompress_one_file+0x40>
mov    %ebp,%edi
call   1030 <gzclose@plt>
xor    %eax,%eax
jmp    11b0 <decompress_one_file+0x70>
mov    $0xffffffff,%eax
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
define i32 @decompress_one_file(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %4
%10 = call i32 @gzopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
store i32 0, i32* %8
%11 = load i32, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %2
store i32 -1, i32* %3
br label %28
14: ; preds = %2
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %6
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%18 = call i32 @gzread(i32 %16, i8* %17, i32 128)
store i32 %18, i32* %8
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %15
%21 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = load i32, i32* %8
%24 = call i32 @gzwrite(i8* %21, i8* %22, i32 %23)
br label %15
25: ; preds = %15
%26 = load i32, i32* %6
%27 = call i32 @gzclose(i32 %26)
store i32 0, i32* %3
br label %28
28: ; preds = %25, %13
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
define i32 @decompress_one_file(i8* %0, i8* %1) {
%3 = alloca [128 x i8]
%4 = tail call i32 @gzopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %4, 0
br i1 %6, label %17, label %7
7: ; preds = %2
%8 = call i32 @gzread(i32 %4, i8* %5, i32 128)
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %7, %10
%11 = phi i32 [ %13, %10 ], [ %8, %7 ]
%12 = call i32 @gzwrite(i8* %5, i8* %1, i32 %11)
%13 = call i32 @gzread(i32 %4, i8* %5, i32 128)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %10, label %15
15: ; preds = %10, %7
%16 = call i32 @gzclose(i32 %4)
br label %17
17: ; preds = %2, %15
%18 = phi i32 [ 0, %15 ], [ -1, %2 ]
ret i32 %18
}