#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__ {
  int total_in;
  int avail_in;
  int total_out;
  int avail_out;
  void *opaque;
  void *zfree;
  void *zalloc;
  int /*<<< orphan*/ *next_out;
  int /*<<< orphan*/ *next_in;
  int /*<<< orphan*/ member_0;
};
typedef TYPE_1__ z_stream;
typedef int /*<<< orphan*/ Bytef;

/* Variables and functions */
int /*<<< orphan*/ Z_FINISH;
void *Z_NULL;
int Z_OK;
int Z_STREAM_END;
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int inflateInit2(TYPE_1__ *, int);
int _inflate(const void *src, int srcLen, void *dst, int dstLen) {
  z_stream strm = {0};
  strm.total_in = strm.avail_in = srcLen;
  strm.total_out = strm.avail_out = dstLen;
  strm.next_in = (Bytef *)src;
  strm.next_out = (Bytef *)dst;
  strm.zalloc = Z_NULL;
  strm.zfree = Z_NULL;
  strm.opaque = Z_NULL;
  int err = -1;
  int ret = -1;
  err = inflateInit2(&strm, (15 + 32));
  if (err == Z_OK) {
    err = inflate(&strm, Z_FINISH);
    if (err == Z_STREAM_END) {
      ret = strm.total_out;
    } else {
      inflateEnd(&strm);
      return err;
    }
  } else {
    inflateEnd(&strm);
    return err;
  }
  inflateEnd(&strm);
  return ret;
}


x86 assembly (clang, -O0):
<_inflate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
lea    -0x68(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    %eax,-0x68(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    %eax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    0x2e41(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    0x2e25(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x58(%rbp)
movl   $0xffffffff,-0x6c(%rbp)
movl   $0xffffffff,-0x70(%rbp)
lea    -0x68(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <inflateInit2@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    0x2e15(%rip),%rcx
cmp    (%rcx),%eax
jne    122e <_inflate+0xee>
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
lea    -0x68(%rbp),%rdi
call   1030 <inflate@plt>
mov    %eax,-0x6c(%rbp)
mov    -0x6c(%rbp),%eax
mov    0x2dde(%rip),%rcx
cmp    (%rcx),%eax
jne    1215 <_inflate+0xd5>
mov    -0x60(%rbp),%eax
mov    %eax,-0x70(%rbp)
jmp    1229 <_inflate+0xe9>
lea    -0x68(%rbp),%rdi
call   1060 <inflateEnd@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1251 <_inflate+0x111>
jmp    1242 <_inflate+0x102>
lea    -0x68(%rbp),%rdi
call   1060 <inflateEnd@plt>
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1251 <_inflate+0x111>
lea    -0x68(%rbp),%rdi
call   1060 <inflateEnd@plt>
mov    -0x70(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_inflate>:
push   %rbx
sub    $0x40,%rsp
movq   $0x0,0x38(%rsp)
mov    %esi,0x4(%rsp)
mov    %esi,(%rsp)
mov    %ecx,0xc(%rsp)
mov    %ecx,0x8(%rsp)
mov    %rdi,0x30(%rsp)
mov    %rdx,0x28(%rsp)
mov    0x2e72(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    %rax,0x18(%rsp)
mov    %rax,0x10(%rsp)
mov    %rsp,%rdi
mov    $0x2f,%esi
call   1040 <inflateInit2@plt>
mov    %eax,%ebx
mov    0x2e6a(%rip),%rax
cmp    (%rax),%ebx
jne    11ac <_inflate+0x7c>
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdi
call   1030 <inflate@plt>
mov    %eax,%ebx
mov    0x2e3c(%rip),%rax
cmp    (%rax),%ebx
jne    11ac <_inflate+0x7c>
mov    0x8(%rsp),%ebx
mov    %rsp,%rdi
call   1050 <inflateEnd@plt>
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

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