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

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


x86 assembly (clang, -O0):
<gtg_compress_m2m>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
call   1030 <deflate@plt>
mov    %eax,-0x34(%rbp)
mov    0x2e62(%rip),%rax
mov    (%rax),%eax
cmp    -0x34(%rbp),%eax
je     11bd <gtg_compress_m2m+0x9d>
mov    0x2e30(%rip),%rax
mov    (%rax),%edi
mov    -0x34(%rbp),%edx
lea    0xe54(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d4 <gtg_compress_m2m+0xb4>
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
sub    %rcx,%rax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gtg_compress_m2m>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rdi,%rbx
mov    %r8,(%rdi)
mov    %rdx,0x18(%rdi)
mov    %rcx,0x10(%rdi)
mov    %rsi,0x8(%rdi)
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
call   1030 <deflate@plt>
mov    0x2ea2(%rip),%rcx
cmp    %eax,(%rcx)
jne    1157 <gtg_compress_m2m+0x37>
sub    (%rbx),%r14d
jmp    1174 <gtg_compress_m2m+0x54>
mov    0x2e72(%rip),%rcx
mov    (%rcx),%edi
lea    0xe99(%rip),%rsi
mov    %eax,%edx
call   1040 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i8*, i8*, 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_compress_m2m(%struct.TYPE_4__* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca %struct.TYPE_4__*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
store i32 0, i32* %13
%14 = load i8*, i8** %11
%15 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%16 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %15, i32 0, i32 0
store i8* %14, i8** %16
%17 = load i8*, i8** %9
%18 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%19 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %18, i32 0, i32 3
store i8* %17, i8** %19
%20 = load i8*, i8** %10
%21 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%22 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %21, i32 0, i32 2
store i8* %20, i8** %22
%23 = load i8*, i8** %8
%24 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%25 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %24, i32 0, i32 1
store i8* %23, i8** %25
%26 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%27 = load i32, i32* @Z_SYNC_FLUSH
%28 = call i32 @deflate(%struct.TYPE_4__* %26, i32 %27)
store i32 %28, i32* %12
%29 = load i32, i32* @Z_OK
%30 = load i32, i32* %12
%31 = icmp ne i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %5
%33 = load i32, i32* @stderr
%34 = load i32, i32* %12
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 -1, i32* %6
br label %46
36: ; preds = %5
%37 = load i8*, i8** %11
%38 = load %struct.TYPE_4__*, %struct.TYPE_4__** %7
%39 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %38, i32 0, i32 0
%40 = load i8*, i8** %39
%41 = ptrtoint i8* %37 to i64
%42 = ptrtoint i8* %40 to i64
%43 = sub i64 %41, %42
%44 = trunc i64 %43 to i32
store i32 %44, i32* %13
%45 = load i32, i32* %13
store i32 %45, i32* %6
br label %46
46: ; preds = %36, %32
%47 = load i32, i32* %6
ret i32 %47
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i8*, i8*, 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_compress_m2m(%struct.TYPE_4__* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
store i8* %4, i8** %6
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 3
store i8* %2, i8** %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 i8* %1, i8** %9
%10 = load i32, i32* @Z_SYNC_FLUSH
%11 = tail call i32 @deflate(%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 %23
17: ; preds = %5
%18 = load i8*, i8** %6
%19 = ptrtoint i8* %4 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
%22 = trunc i64 %21 to i32
br label %23
23: ; preds = %17, %14
%24 = phi i32 [ -1, %14 ], [ %22, %17 ]
ret i32 %24
}