#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_in;
  int avail_out;
  void *next_out;
  void *next_in;
};
typedef TYPE_1__ z_stream;
typedef int uint32_t;

/* Variables and functions */
int Z_OK;
int /*<<< orphan*/ Z_SYNC_FLUSH;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int inflate(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int gtg_decompress_m2m(z_stream *z, void *in_buf, uint32_t len, void *out_buf,
                       uint32_t out_max_len) {
  int status;
  z->next_in = in_buf;
  z->avail_in = len;
  z->next_out = out_buf;
  z->avail_out = out_max_len;
  status = inflate(z, Z_SYNC_FLUSH);
  if (Z_OK != status) {
    fprintf(stderr, "error %d in compressing\n", status);
    return -1;
  }
  return out_max_len - z->avail_out;
}


x86 assembly (clang, -O0):
<gtg_decompress_m2m>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2e6f(%rip),%rax
mov    (%rax),%esi
call   1030 <inflate@plt>
mov    %eax,-0x30(%rbp)
mov    0x2e6e(%rip),%rax
mov    (%rax),%eax
cmp    -0x30(%rbp),%eax
je     11b1 <gtg_decompress_m2m+0x91>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%edx
lea    0xe60(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11be <gtg_decompress_m2m+0x9e>
mov    -0x2c(%rbp),%eax
mov    -0x10(%rbp),%rcx
sub    0x4(%rcx),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtg_decompress_m2m>:
push   %rbp
push   %rbx
push   %rax
mov    %r8d,%ebp
mov    %rdi,%rbx
mov    %rsi,0x10(%rdi)
mov    %edx,(%rdi)
mov    %rcx,0x8(%rdi)
mov    %r8d,0x4(%rdi)
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
call   1030 <inflate@plt>
mov    0x2ea4(%rip),%rcx
cmp    %eax,(%rcx)
jne    1155 <gtg_decompress_m2m+0x35>
sub    0x4(%rbx),%ebp
jmp    1171 <gtg_decompress_m2m+0x51>
mov    0x2e74(%rip),%rcx
mov    (%rcx),%edi
lea    0xe9b(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32, i32, i8*, i8* }
@Z_SYNC_FLUSH = global i32 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"error %d in compressing\0A\00"
define i32 @gtg_decompress_m2m(%struct.TYPE_4__* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.TYPE_4__*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%13 = load i8*, i8** %8
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 3
store i8* %13, i8** %15
%16 = load i32, i32* %9
%17 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 0
store i32 %16, i32* %18
%19 = load i8*, i8** %10
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%21 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %20, i32 0, i32 2
store i8* %19, i8** %21
%22 = load i32, i32* %11
%23 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %23, i32 0, i32 1
store i32 %22, i32* %24
%25 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%26 = load i32, i32* @Z_SYNC_FLUSH
%27 = call i32 @inflate(%struct.TYPE_4__* %25, i32 %26)
store i32 %27, i32* %12
%28 = load i32, i32* @Z_OK
%29 = load i32, i32* %12
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %35
31: ; preds = %5
%32 = load i32, i32* @stderr
%33 = load i32, i32* %12
%34 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %33)
store i32 -1, i32* %6
br label %41
35: ; preds = %5
%36 = load i32, i32* %11
%37 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%38 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %37, i32 0, i32 1
%39 = load i32, i32* %38
%40 = sub nsw i32 %36, %39
store i32 %40, i32* %6
br label %41
41: ; preds = %35, %31
%42 = load i32, i32* %6
ret i32 %42
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32, i32, i8*, i8* }
@Z_SYNC_FLUSH = global i32 0
@Z_OK = global i32 0
@stderr = global i32 0
@.str = [25 x i8] c"error %d in compressing\0A\00"
define i32 @gtg_decompress_m2m(%struct.TYPE_4__* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 3
store i8* %1, i8** %6
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
store i32 %2, i32* %7
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 2
store i8* %3, i8** %8
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 1
store i32 %4, i32* %9
%10 = load i32, i32* @Z_SYNC_FLUSH
%11 = tail call i32 @inflate(%struct.TYPE_4__* %0, i32 %10)
%12 = load i32, i32* @Z_OK
%13 = icmp eq i32 %12, %11
br i1 %13, label %17, label %14
14: ; preds = %5
%15 = load i32, i32* @stderr
%16 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %20
17: ; preds = %5
%18 = load i32, i32* %9
%19 = sub nsw i32 %4, %18
br label %20
20: ; preds = %17, %14
%21 = phi i32 [ -1, %14 ], [ %19, %17 ]
ret i32 %21
}