#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 avail_in;
  char *next_out;
  int avail_out;
  int total_out;
  scalar_t__ zfree;
  scalar_t__ zalloc;
  int /*<<< orphan*/ *next_in;
};
typedef TYPE_1__ z_stream;
typedef scalar_t__ free_func;
typedef scalar_t__ alloc_func;
typedef int /*<<< orphan*/ Bytef;

/* Variables and functions */
int /*<<< orphan*/ MAX_WBITS;
int /*<<< orphan*/ Z_FINISH;
int /*<<< orphan*/ inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ inflateEnd(TYPE_1__ *);
int /*<<< orphan*/ inflateInit2(TYPE_1__ *, int /*<<< orphan*/);
unsigned inflatemem(char *dest, const char *source) {
  z_stream stream;
  stream.next_in = (Bytef *)source;
  stream.avail_in = 65535;
  stream.next_out = dest;
  stream.avail_out = 65535;
  stream.zalloc = (alloc_func)0;
  stream.zfree = (free_func)0;
  inflateInit2(&stream, -MAX_WBITS);
  inflate(&stream, Z_FINISH);
  inflateEnd(&stream);
  return stream.total_out;
}


x86 assembly (clang, -O0):
<inflatemem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0xffff,-0x40(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0xffff,-0x30(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
xor    %esi,%esi
mov    0x2e71(%rip),%rax
sub    (%rax),%esi
lea    -0x40(%rbp),%rdi
call   1040 <inflateInit2@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdi
call   1030 <inflate@plt>
lea    -0x40(%rbp),%rdi
call   1050 <inflateEnd@plt>
mov    -0x2c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inflatemem>:
push   %rbx
sub    $0x30,%rsp
mov    %rsi,0x28(%rsp)
movl   $0xffff,(%rsp)
mov    %rdi,0x8(%rsp)
movl   $0xffff,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
mov    0x2e8b(%rip),%rax
xor    %esi,%esi
sub    (%rax),%esi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <inflateInit2@plt>
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <inflate@plt>
mov    %rbx,%rdi
call   1050 <inflateEnd@plt>
mov    0x14(%rsp),%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i8*, i32, i32, i64, i64, i32* }
@MAX_WBITS = global i32 0
@Z_FINISH = global i32 0
define i32 @inflatemem(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca %struct.TYPE_5__
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = bitcast i8* %6 to i32*
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 6
store i32* %7, i32** %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
store i32 65535, i32* %9
%10 = load i8*, i8** %3
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 1
store i8* %10, i8** %11
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 2
store i32 65535, i32* %12
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 5
store i64 0, i64* %13
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 4
store i64 0, i64* %14
%15 = load i32, i32* @MAX_WBITS
%16 = sub nsw i32 0, %15
%17 = call i32 @inflateInit2(%struct.TYPE_5__* %5, i32 %16)
%18 = load i32, i32* @Z_FINISH
%19 = call i32 @inflate(%struct.TYPE_5__* %5, i32 %18)
%20 = call i32 @inflateEnd(%struct.TYPE_5__* %5)
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 3
%22 = load i32, i32* %21
ret i32 %22
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i8*, i32, i32, i64, i64, i32* }
@MAX_WBITS = global i32 0
@Z_FINISH = global i32 0
define i32 @inflatemem(i8* %0, i8* %1) {
%3 = alloca %struct.TYPE_5__
%4 = bitcast %struct.TYPE_5__* %3 to i8*
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 6
%6 = bitcast i32** %5 to i8**
store i8* %1, i8** %6
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
store i32 65535, i32* %7
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
store i8* %0, i8** %8
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 2
store i32 65535, i32* %9
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 4
%11 = bitcast i64* %10 to i8*
%12 = load i32, i32* @MAX_WBITS
%13 = sub nsw i32 0, %12
%14 = call i32 @inflateInit2(%struct.TYPE_5__* %3, i32 %13)
%15 = load i32, i32* @Z_FINISH
%16 = call i32 @inflate(%struct.TYPE_5__* %3, i32 %15)
%17 = call i32 @inflateEnd(%struct.TYPE_5__* %3)
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 3
%19 = load i32, i32* %18
ret i32 %19
}