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

/* Variables and functions */
int Z_OK;
int uncompress(unsigned char *, unsigned long *, unsigned char const *, int);
int gzip_uncompress(char *d, char *s, int size, int block_size, int *error) {
  int res;
  unsigned long bytes = block_size;
  res = uncompress((unsigned char *)d, &bytes, (const unsigned char *)s, size);
  *error = res;
  return res == Z_OK ? (int)bytes : -1;
}


x86 assembly (clang, -O0):
<gzip_uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movslq -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%ecx
lea    -0x30(%rbp),%rsi
call   1030 <uncompress@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%eax
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
jne    1170 <gzip_uncompress+0x60>
mov    -0x30(%rbp),%rax
mov    %eax,-0x34(%rbp)
jmp    117d <gzip_uncompress+0x6d>
mov    $0xffffffff,%eax
mov    %eax,-0x34(%rbp)
jmp    117d <gzip_uncompress+0x6d>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gzip_uncompress>:
push   %rbx
sub    $0x10,%rsp
mov    %r8,%rbx
mov    %edx,%eax
mov    %rsi,%rdx
movslq %ecx,%rcx
mov    %rcx,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %eax,%ecx
call   1030 <uncompress@plt>
mov    %eax,%ecx
mov    %eax,(%rbx)
mov    0x2eb4(%rip),%rdx
mov    $0xffffffff,%eax
cmp    (%rdx),%ecx
jne    1149 <gzip_uncompress+0x39>
mov    0x8(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@Z_OK = global i32 0
define i32 @gzip_uncompress(i8* %0, i8* %1, i32 %2, i32 %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32* %4, i32** %10
%13 = load i32, i32* %9
%14 = sext i32 %13 to i64
store i64 %14, i64* %12
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = load i32, i32* %8
%18 = call i32 @uncompress(i8* %15, i64* %12, i8* %16, i32 %17)
store i32 %18, i32* %11
%19 = load i32, i32* %11
%20 = load i32*, i32** %10
store i32 %19, i32* %20
%21 = load i32, i32* %11
%22 = load i32, i32* @Z_OK
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %27
24: ; preds = %5
%25 = load i64, i64* %12
%26 = trunc i64 %25 to i32
br label %28
27: ; preds = %5
br label %28
28: ; preds = %27, %24
%29 = phi i32 [ %26, %24 ], [ -1, %27 ]
ret i32 %29
}

LLVM IR (-O2):
@Z_OK = global i32 0
define i32 @gzip_uncompress(i8* %0, i8* %1, i32 %2, i32 %3, i32* nocapture writeonly %4) {
%6 = alloca i64
%7 = bitcast i64* %6 to i8*
%8 = sext i32 %3 to i64
store i64 %8, i64* %6
%9 = call i32 @uncompress(i8* %0, i64* %6, i8* %1, i32 %2)
store i32 %9, i32* %4
%10 = load i32, i32* @Z_OK
%11 = icmp eq i32 %9, %10
%12 = load i64, i64* %6
%13 = trunc i64 %12 to i32
%14 = select i1 %11, i32 %13, i32 -1
ret i32 %14
}