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

/* Variables and functions */
int /*<<< orphan*/ Z_FINISH;
void *Z_NULL;
int /*<<< orphan*/ inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int /*<<< orphan*/ inflateInit2(TYPE_1__ *, int);
int inflate_zlib(unsigned char *data, u_int32_t length,
                 unsigned char *decompressed, u_int32_t maxDecompressed) {
  z_stream infstream;
  infstream.zalloc = Z_NULL;
  infstream.zfree = Z_NULL;
  infstream.opaque = Z_NULL;
  infstream.avail_in = length;
  infstream.next_in = data;
  infstream.avail_out = maxDecompressed;
  infstream.next_out = decompressed;
  inflateInit2(&infstream, 32);
  inflate(&infstream, Z_FINISH);
  inflateEnd(&infstream);
  return infstream.total_out;
}


x86 assembly (clang, -O0):
<inflate_zlib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    0x2e91(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    0x2e75(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x20,%esi
call   1040 <inflateInit2@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%esi
lea    -0x60(%rbp),%rdi
call   1030 <inflate@plt>
lea    -0x60(%rbp),%rdi
call   1050 <inflateEnd@plt>
mov    -0x50(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inflate_zlib>:
push   %rbx
sub    $0x40,%rsp
mov    0x2ea4(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x38(%rsp)
mov    %rax,0x30(%rsp)
mov    %rax,0x28(%rsp)
mov    %rsi,0x20(%rsp)
mov    %rdi,(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x8(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <inflateInit2@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <inflate@plt>
mov    %rbx,%rdi
call   1050 <inflateEnd@plt>
mov    0x10(%rsp),%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i8*, i8*, i32, i8*, i8*, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_FINISH = global i32 0
define i32 @inflate_zlib(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.TYPE_5__
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%10 = load i8*, i8** @Z_NULL
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 7
store i8* %10, i8** %11
%12 = load i8*, i8** @Z_NULL
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 6
store i8* %12, i8** %13
%14 = load i8*, i8** @Z_NULL
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 5
store i8* %14, i8** %15
%16 = load i8*, i8** %6
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 4
store i8* %16, i8** %17
%18 = load i8*, i8** %5
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 0
store i8* %18, i8** %19
%20 = load i8*, i8** %8
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 3
store i8* %20, i8** %21
%22 = load i8*, i8** %7
%23 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 1
store i8* %22, i8** %23
%24 = call i32 @inflateInit2(%struct.TYPE_5__* %9, i32 32)
%25 = load i32, i32* @Z_FINISH
%26 = call i32 @inflate(%struct.TYPE_5__* %9, i32 %25)
%27 = call i32 @inflateEnd(%struct.TYPE_5__* %9)
%28 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i32 0, i32 2
%29 = load i32, i32* %28
ret i32 %29
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i8*, i8*, i32, i8*, i8*, i8*, i8*, i8* }
@Z_NULL = global i8* null
@Z_FINISH = global i32 0
define i32 @inflate_zlib(i8* %0, i8* %1, i8* %2, i8* %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 7
store i8* %7, i8** %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 6
store i8* %7, i8** %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 5
store i8* %7, i8** %10
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 4
store i8* %1, i8** %11
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 0
store i8* %0, i8** %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 3
store i8* %3, i8** %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 1
store i8* %2, i8** %14
%15 = call i32 @inflateInit2(%struct.TYPE_5__* %5, i32 32)
%16 = load i32, i32* @Z_FINISH
%17 = call i32 @inflate(%struct.TYPE_5__* %5, i32 %16)
%18 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i64 0, i32 2
%20 = load i32, i32* %19
ret i32 %20
}