#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 unsigned int uLongf;

/* Variables and functions */
int Z_BUF_ERROR;
int Z_OK;
int compress2(char *, unsigned int *, char *, unsigned int, int);
int comp_zlib_compress(char *outbuf, unsigned int *outlen, char *source,
                       unsigned int sourcelen, int level) {
  int r;
  uLongf t_outlen = *outlen;
  r = compress2(outbuf, &t_outlen, source, sourcelen, level);
  *outlen = t_outlen;
  if (r == Z_OK)
    return 0;
  if (r == Z_BUF_ERROR)
    return 1;
  return 3;
}


x86 assembly (clang, -O0):
<comp_zlib_compress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x28(%rbp),%r8d
lea    -0x30(%rbp),%rsi
call   1030 <compress2@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x2c(%rbp),%eax
mov    0x2e8e(%rip),%rcx
cmp    (%rcx),%eax
jne    1176 <comp_zlib_compress+0x66>
movl   $0x0,-0x4(%rbp)
jmp    119b <comp_zlib_compress+0x8b>
mov    -0x2c(%rbp),%eax
mov    0x2e60(%rip),%rcx
cmp    (%rcx),%eax
jne    1194 <comp_zlib_compress+0x84>
movl   $0x1,-0x4(%rbp)
jmp    119b <comp_zlib_compress+0x8b>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<comp_zlib_compress>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    (%rsi),%eax
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1030 <compress2@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,(%rbx)
mov    0x2ebb(%rip),%rcx
mov    0x2ea4(%rip),%rdx
xor    %esi,%esi
cmp    (%rdx),%eax
setne  %sil
xor    %edx,%edx
cmp    (%rcx),%eax
lea    0x1(%rsi,%rsi,1),%eax
cmove  %edx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@Z_OK = global i32 0
@Z_BUF_ERROR = global i32 0
define i32 @comp_zlib_compress(i8* %0, i32* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %7
store i32* %1, i32** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%14 = load i32*, i32** %8
%15 = load i32, i32* %14
store i32 %15, i32* %13
%16 = load i8*, i8** %7
%17 = load i8*, i8** %9
%18 = load i32, i32* %10
%19 = load i32, i32* %11
%20 = call i32 @compress2(i8* %16, i32* %13, i8* %17, i32 %18, i32 %19)
store i32 %20, i32* %12
%21 = load i32, i32* %13
%22 = load i32*, i32** %8
store i32 %21, i32* %22
%23 = load i32, i32* %12
%24 = load i32, i32* @Z_OK
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %5
store i32 0, i32* %6
br label %33
27: ; preds = %5
%28 = load i32, i32* %12
%29 = load i32, i32* @Z_BUF_ERROR
%30 = icmp eq i32 %28, %29
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %6
br label %33
32: ; preds = %27
store i32 3, i32* %6
br label %33
33: ; preds = %32, %31, %26
%34 = load i32, i32* %6
ret i32 %34
}

LLVM IR (-O2):
@Z_OK = global i32 0
@Z_BUF_ERROR = global i32 0
define i32 @comp_zlib_compress(i8* %0, i32* nocapture %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = load i32, i32* %1
store i32 %8, i32* %6
%9 = call i32 @compress2(i8* %0, i32* %6, i8* %2, i32 %3, i32 %4)
%10 = load i32, i32* %6
store i32 %10, i32* %1
%11 = load i32, i32* @Z_OK
%12 = icmp eq i32 %9, %11
%13 = load i32, i32* @Z_BUF_ERROR
%14 = icmp eq i32 %9, %13
%15 = select i1 %14, i32 1, i32 3
%16 = select i1 %12, i32 0, i32 %15
ret i32 %16
}