#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int avail_out;
  unsigned char *next_out;
};
typedef TYPE_1__ z_stream;
struct strbuf {
  int dummy;
};
typedef unsigned char Bytef;

/* Variables and functions */
int /*<<< orphan*/ Z_NO_FLUSH;
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ strbuf_add(struct strbuf *, char *, int);
int uncompress_chunk(z_stream *stream, struct strbuf *dest) {
  char buffer[16384] = {'\0'};
  stream->avail_out = 16384;
  stream->next_out = (Bytef *)buffer;
  int ret = inflate(stream, Z_NO_FLUSH);
  strbuf_add(dest, buffer, stream->next_out - (unsigned char *)buffer);
  return ret;
}


x86 assembly (clang, -O0):
<uncompress_chunk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4020,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4010(%rbp),%rdi
xor    %esi,%esi
mov    $0x4000,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rax
movl   $0x4000,(%rax)
lea    -0x4010(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rdi
mov    0x2e66(%rip),%rax
mov    (%rax),%esi
call   1030 <inflate@plt>
mov    %eax,-0x4014(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x4010(%rbp),%rsi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
lea    -0x4010(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1040 <strbuf_add@plt>
mov    -0x4014(%rbp),%eax
add    $0x4020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uncompress_chunk>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4008,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%r15
mov    $0x4000,%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movl   $0x4000,(%rbx)
mov    %r15,0x8(%rbx)
mov    0x2e7a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <inflate@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%edx
sub    %r15d,%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <strbuf_add@plt>
mov    %ebp,%eax
add    $0x4008,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i8* }
%struct.strbuf = type { i32 }
@Z_NO_FLUSH = global i32 0
define i32 @uncompress_chunk(%struct.TYPE_4__* %0, %struct.strbuf* %1) {
%3 = alloca %struct.TYPE_4__*
%4 = alloca %struct.strbuf*
%5 = alloca [16384 x i8]
%6 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %3
store %struct.strbuf* %1, %struct.strbuf** %4
%7 = bitcast [16384 x i8]* %5 to i8*
%8 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 0
store i32 16384, i32* %9
%10 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%11 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%12 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %11, i32 0, i32 1
store i8* %10, i8** %12
%13 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%14 = load i32, i32* @Z_NO_FLUSH
%15 = call i32 @inflate(%struct.TYPE_4__* %13, i32 %14)
store i32 %15, i32* %6
%16 = load %struct.strbuf*, %struct.strbuf** %4
%17 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 1
%20 = load i8*, i8** %19
%21 = getelementptr inbounds [16384 x i8], [16384 x i8]* %5, i64 0, i64 0
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = call i32 @strbuf_add(%struct.strbuf* %16, i8* %17, i32 %25)
%27 = load i32, i32* %6
ret i32 %27
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i8* }
%struct.strbuf = type { i32 }
@Z_NO_FLUSH = global i32 0
define i32 @uncompress_chunk(%struct.TYPE_4__* %0, %struct.strbuf* %1) {
%3 = alloca [16384 x i8]
%4 = getelementptr inbounds [16384 x i8], [16384 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
store i32 16384, i32* %5
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 1
store i8* %4, i8** %6
%7 = load i32, i32* @Z_NO_FLUSH
%8 = call i32 @inflate(%struct.TYPE_4__* %0, i32 %7)
%9 = load i8*, i8** %6
%10 = ptrtoint i8* %9 to i64
%11 = ptrtoint [16384 x i8]* %3 to i64
%12 = sub i64 %10, %11
%13 = trunc i64 %12 to i32
%14 = call i32 @strbuf_add(%struct.strbuf* %1, i8* %4, i32 %13)
ret i32 %8
}