#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__ {
  size_t avail_in;
  unsigned char const *next_in;
  unsigned char *next_out;
  size_t avail_out;
  void *opaque;
  void *zfree;
  void *zalloc;
};
typedef TYPE_1__ z_stream;

/* Variables and functions */
int /*<<< orphan*/ Z_FINISH;
void *Z_NULL;
int Z_OK;
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int inflateInit(TYPE_1__ *);
int zDecompress(const unsigned char *data, size_t avail_in,
                unsigned char *odata, size_t *avail_out) {
  int ret;
  z_stream strm;
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  ret = inflateInit(&strm);
  if (ret != Z_OK)
    return ret;
  strm.avail_in = avail_in;
  strm.next_in = data;
  strm.next_out = odata;
  strm.avail_out = *avail_out;
  ret = inflate(&strm, Z_FINISH);
  *avail_out -= strm.avail_out;
  (void)inflateEnd(&strm);
  return ret ? Z_OK : -1;
}


x86 assembly (clang, -O0):
<zDecompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    0x2e89(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e7b(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e6d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
lea    -0x68(%rbp),%rdi
call   1040 <inflateInit@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e68(%rip),%rcx
cmp    (%rcx),%eax
je     119b <zDecompress+0x6b>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    121b <zDecompress+0xeb>
mov    -0x18(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    0x2e0b(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x50(%rbp),%rdx
mov    -0x28(%rbp),%rax
mov    (%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,(%rax)
lea    -0x68(%rbp),%rdi
call   1050 <inflateEnd@plt>
cmpl   $0x0,-0x2c(%rbp)
je     1208 <zDecompress+0xd8>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
jmp    1215 <zDecompress+0xe5>
mov    $0xffffffff,%eax
mov    %eax,-0x6c(%rbp)
jmp    1215 <zDecompress+0xe5>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zDecompress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    0x2e87(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rsp,%rdi
call   1040 <inflateInit@plt>
mov    0x2e7e(%rip),%r13
cmp    0x0(%r13),%eax
jne    11bd <zDecompress+0x8d>
mov    %r12,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <inflate@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%rax
sub    %rax,(%r15)
mov    %rbx,%rdi
call   1050 <inflateEnd@plt>
cmp    $0x1,%ebp
sbb    %eax,%eax
or     0x0(%r13),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i64, i8*, i8*, i64, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_OK = global i32 0
@Z_FINISH = global i32 0
define i32 @zDecompress(i8* %0, i64 %1, i8* %2, i64* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca %struct.TYPE_5__
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i64* %3, i64** %9
%12 = load i8*, i8** @Z_NULL
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 6
store i8* %12, i8** %13
%14 = load i8*, i8** @Z_NULL
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 5
store i8* %14, i8** %15
%16 = load i8*, i8** @Z_NULL
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 4
store i8* %16, i8** %17
%18 = call i32 @inflateInit(%struct.TYPE_5__* %11)
store i32 %18, i32* %10
%19 = load i32, i32* %10
%20 = load i32, i32* @Z_OK
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = load i32, i32* %10
store i32 %23, i32* %5
br label %49
24: ; preds = %4
%25 = load i64, i64* %7
%26 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 0
store i64 %25, i64* %26
%27 = load i8*, i8** %6
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 1
store i8* %27, i8** %28
%29 = load i8*, i8** %8
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 2
store i8* %29, i8** %30
%31 = load i64*, i64** %9
%32 = load i64, i64* %31
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 3
store i64 %32, i64* %33
%34 = load i32, i32* @Z_FINISH
%35 = call i32 @inflate(%struct.TYPE_5__* %11, i32 %34)
store i32 %35, i32* %10
%36 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 3
%37 = load i64, i64* %36
%38 = load i64*, i64** %9
%39 = load i64, i64* %38
%40 = sub i64 %39, %37
store i64 %40, i64* %38
%41 = call i32 @inflateEnd(%struct.TYPE_5__* %11)
%42 = load i32, i32* %10
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %24
%45 = load i32, i32* @Z_OK
br label %47
46: ; preds = %24
br label %47
47: ; preds = %46, %44
%48 = phi i32 [ %45, %44 ], [ -1, %46 ]
store i32 %48, i32* %5
br label %49
49: ; preds = %47, %22
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i64, i8*, i8*, i64, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_OK = global i32 0
@Z_FINISH = global i32 0
define i32 @zDecompress(i8* %0, i64 %1, i8* %2, i64* nocapture %3) {
%5 = alloca %struct.TYPE_5__
%6 = bitcast %struct.TYPE_5__* %5 to i8*
%7 = load i8*, i8** @Z_NULL
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 6
store i8* %7, i8** %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 5
store i8* %7, i8** %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 4
store i8* %7, i8** %10
%11 = call i32 @inflateInit(%struct.TYPE_5__* %5)
%12 = load i32, i32* @Z_OK
%13 = icmp eq i32 %11, %12
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 0
store i64 %1, i64* %15
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 1
store i8* %0, i8** %16
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 2
store i8* %2, i8** %17
%18 = load i64, i64* %3
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 3
store i64 %18, i64* %19
%20 = load i32, i32* @Z_FINISH
%21 = call i32 @inflate(%struct.TYPE_5__* %5, i32 %20)
%22 = load i64, i64* %19
%23 = load i64, i64* %3
%24 = sub i64 %23, %22
store i64 %24, i64* %3
%25 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%26 = icmp eq i32 %21, 0
%27 = load i32, i32* @Z_OK
%28 = select i1 %26, i32 -1, i32 %27
br label %29
29: ; preds = %4, %14
%30 = phi i32 [ %28, %14 ], [ %11, %4 ]
ret i32 %30
}