#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 */

/* Type definitions */
typedef unsigned long uint32_t;

/* Variables and functions */
#define Z_BUF_ERROR 131
#define Z_DATA_ERROR 130
#define Z_MEM_ERROR 129
#define Z_OK 128
int compress(unsigned char *, unsigned long *, unsigned char const *,
             unsigned long);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int compress_gzip(const unsigned char *old, uint32_t old_size,
                  unsigned char *new, uint32_t new_size) {
  int rc;
  unsigned long len = old_size;
  rc = compress(new, &len, old, new_size);
  switch (rc) {
  case Z_OK:
    rc = len;
    break;
  case Z_MEM_ERROR: {
    fprintf(stderr, "ERROR: ");
    fprintf(stderr, "Z_MEM_ERROR (not enough memory)!\n");
  };
    rc = -1;
    break;
  case Z_BUF_ERROR:
    rc = -1;
    break;
  case Z_DATA_ERROR: {
    fprintf(stderr, "ERROR: ");
    fprintf(stderr, "Z_DATA_ERROR (input data corrupted)!\n");
  };
    rc = -1;
    break;
  default: {
    fprintf(stderr, "ERROR: ");
    fprintf(stderr, "Z_UNKNOWN_ERROR (rc 0x%x unknown)!\n", rc);
  };
    rc = -1;
    break;
  }
  return rc;
}


x86 assembly (clang, -O0):
<compress_gzip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x30(%rbp),%rsi
call   1030 <compress@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x3,%eax
ja     120d <compress_gzip+0xed>
mov    -0x38(%rbp),%rax
lea    0xe88(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x30(%rbp),%rax
mov    %eax,-0x24(%rbp)
jmp    1245 <compress_gzip+0x125>
mov    0x2e4c(%rip),%rax
mov    (%rax),%edi
lea    0xe73(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    1245 <compress_gzip+0x125>
movl   $0xffffffff,-0x24(%rbp)
jmp    1245 <compress_gzip+0x125>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
lea    0xe2d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x24(%rbp)
jmp    1245 <compress_gzip+0x125>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%edx
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compress_gzip>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rax
mov    %rsi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rdx,%rdi
mov    %rax,%rdx
call   1030 <compress@plt>
mov    %eax,%ebx
mov    $0xffffffff,%ebp
lea    -0x80(%rbx),%eax
cmp    $0x3,%eax
ja     1165 <compress_gzip+0x45>
lea    0xeaa(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x8(%rsp),%ebp
jmp    11db <compress_gzip+0xbb>
mov    0x2e74(%rip),%r14
mov    (%r14),%edi
lea    0xe9a(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%r14),%edi
lea    0xed9(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
jmp    11db <compress_gzip+0xbb>
mov    0x2e47(%rip),%rbx
mov    (%rbx),%edi
lea    0xe6e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe66(%rip),%rsi
jmp    11d4 <compress_gzip+0xb4>
mov    0x2e25(%rip),%rbx
mov    (%rbx),%edi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    (%rbx),%edi
lea    0xe66(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [34 x i8] c"Z_MEM_ERROR (not enough memory)!\0A\00"
@.str.2 = [38 x i8] c"Z_DATA_ERROR (input data corrupted)!\0A\00"
@.str.3 = [36 x i8] c"Z_UNKNOWN_ERROR (rc 0x%x unknown)!\0A\00"
define i32 @compress_gzip(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%11 = load i64, i64* %6
store i64 %11, i64* %10
%12 = load i8*, i8** %7
%13 = load i8*, i8** %5
%14 = load i64, i64* %8
%15 = call i32 @compress(i8* %12, i64* %10, i8* %13, i64 %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
switch i32 %16, label %31 [
i32 128, label %17
i32 129, label %20
i32 131, label %25
i32 130, label %26
]
17: ; preds = %4
%18 = load i64, i64* %10
%19 = trunc i64 %18 to i32
store i32 %19, i32* %9
br label %37
20: ; preds = %4
%21 = load i32, i32* @stderr
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %9
br label %37
25: ; preds = %4
store i32 -1, i32* %9
br label %37
26: ; preds = %4
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %9
br label %37
31: ; preds = %4
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%34 = load i32, i32* @stderr
%35 = load i32, i32* %9
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %35)
store i32 -1, i32* %9
br label %37
37: ; preds = %31, %26, %25, %20, %17
%38 = load i32, i32* %9
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"ERROR: \00"
@.str.1 = [34 x i8] c"Z_MEM_ERROR (not enough memory)!\0A\00"
@.str.2 = [38 x i8] c"Z_DATA_ERROR (input data corrupted)!\0A\00"
@.str.3 = [36 x i8] c"Z_UNKNOWN_ERROR (rc 0x%x unknown)!\0A\00"
define i32 @compress_gzip(i8* %0, i64 %1, i8* %2, i64 %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
store i64 %1, i64* %5
%7 = call i32 @compress(i8* %2, i64* %5, i8* %0, i64 %3)
switch i32 %7, label %21 [
i32 128, label %8
i32 129, label %11
i32 131, label %26
i32 130, label %16
]
8: ; preds = %4
%9 = load i64, i64* %5
%10 = trunc i64 %9 to i32
br label %26
11: ; preds = %4
%12 = load i32, i32* @stderr
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %26
16: ; preds = %4
%17 = load i32, i32* @stderr
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
br label %26
21: ; preds = %4
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i32 %7)
br label %26
26: ; preds = %4, %21, %16, %11, %8
%27 = phi i32 [ -1, %21 ], [ -1, %16 ], [ -1, %11 ], [ %10, %8 ], [ -1, %4 ]
ret i32 %27
}