#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 deflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ deflateEnd(TYPE_1__ *);
int deflateInit(TYPE_1__ *, int);
int zCompress(int level, 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 = deflateInit(&strm, level);
  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 = deflate(&strm, Z_FINISH);
  *avail_out -= strm.avail_out;
  (void)deflateEnd(&strm);
  return ret ? Z_OK : -1;
}


x86 assembly (clang, -O0):
<zCompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    0x2e86(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e78(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%esi
lea    -0x68(%rbp),%rdi
call   1040 <deflateInit@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e62(%rip),%rcx
cmp    (%rcx),%eax
je     11a1 <zCompress+0x71>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <zCompress+0xf1>
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    0x2e05(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdi
call   1030 <deflate@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 <deflateEnd@plt>
cmpl   $0x0,-0x2c(%rbp)
je     120e <zCompress+0xde>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
jmp    121b <zCompress+0xeb>
mov    $0xffffffff,%eax
mov    %eax,-0x6c(%rbp)
jmp    121b <zCompress+0xeb>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zCompress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8,%r15
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %edi,%esi
mov    0x2e85(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rax,0x20(%rsp)
mov    %rsp,%rdi
call   1040 <deflateInit@plt>
mov    0x2e7c(%rip),%r13
cmp    0x0(%r13),%eax
jne    11bf <zCompress+0x8f>
mov    %r12,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r14,0x10(%rsp)
mov    (%r15),%rax
mov    %rax,0x18(%rsp)
mov    0x2e39(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <deflate@plt>
mov    %eax,%ebp
mov    0x18(%rsp),%rax
sub    %rax,(%r15)
mov    %rbx,%rdi
call   1050 <deflateEnd@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 @zCompress(i32 %0, i8* %1, i64 %2, i8* %3, i64* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64*
%12 = alloca i32
%13 = alloca %struct.TYPE_5__
store i32 %0, i32* %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i8* %3, i8** %10
store i64* %4, i64** %11
%14 = load i8*, i8** @Z_NULL
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 6
store i8* %14, i8** %15
%16 = load i8*, i8** @Z_NULL
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 5
store i8* %16, i8** %17
%18 = load i8*, i8** @Z_NULL
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 4
store i8* %18, i8** %19
%20 = load i32, i32* %7
%21 = call i32 @deflateInit(%struct.TYPE_5__* %13, i32 %20)
store i32 %21, i32* %12
%22 = load i32, i32* %12
%23 = load i32, i32* @Z_OK
%24 = icmp ne i32 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %5
%26 = load i32, i32* %12
store i32 %26, i32* %6
br label %52
27: ; preds = %5
%28 = load i64, i64* %9
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 0
store i64 %28, i64* %29
%30 = load i8*, i8** %8
%31 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 1
store i8* %30, i8** %31
%32 = load i8*, i8** %10
%33 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 2
store i8* %32, i8** %33
%34 = load i64*, i64** %11
%35 = load i64, i64* %34
%36 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 3
store i64 %35, i64* %36
%37 = load i32, i32* @Z_FINISH
%38 = call i32 @deflate(%struct.TYPE_5__* %13, i32 %37)
store i32 %38, i32* %12
%39 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 3
%40 = load i64, i64* %39
%41 = load i64*, i64** %11
%42 = load i64, i64* %41
%43 = sub i64 %42, %40
store i64 %43, i64* %41
%44 = call i32 @deflateEnd(%struct.TYPE_5__* %13)
%45 = load i32, i32* %12
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %27
%48 = load i32, i32* @Z_OK
br label %50
49: ; preds = %27
br label %50
50: ; preds = %49, %47
%51 = phi i32 [ %48, %47 ], [ -1, %49 ]
store i32 %51, i32* %6
br label %52
52: ; preds = %50, %25
%53 = load i32, i32* %6
ret i32 %53
}

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 @zCompress(i32 %0, i8* %1, i64 %2, i8* %3, i64* nocapture %4) {
%6 = alloca %struct.TYPE_5__
%7 = bitcast %struct.TYPE_5__* %6 to i8*
%8 = load i8*, i8** @Z_NULL
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 6
store i8* %8, i8** %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 5
store i8* %8, i8** %10
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 4
store i8* %8, i8** %11
%12 = call i32 @deflateInit(%struct.TYPE_5__* %6, i32 %0)
%13 = load i32, i32* @Z_OK
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %30
15: ; preds = %5
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 0
store i64 %2, i64* %16
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 1
store i8* %1, i8** %17
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 2
store i8* %3, i8** %18
%19 = load i64, i64* %4
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 3
store i64 %19, i64* %20
%21 = load i32, i32* @Z_FINISH
%22 = call i32 @deflate(%struct.TYPE_5__* %6, i32 %21)
%23 = load i64, i64* %20
%24 = load i64, i64* %4
%25 = sub i64 %24, %23
store i64 %25, i64* %4
%26 = call i32 @deflateEnd(%struct.TYPE_5__* %6)
%27 = icmp eq i32 %22, 0
%28 = load i32, i32* @Z_OK
%29 = select i1 %27, i32 -1, i32 %28
br label %30
30: ; preds = %5, %15
%31 = phi i32 [ %29, %15 ], [ %12, %5 ]
ret i32 %31
}