#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(void *, unsigned long *, void *, int);
int gzip_uncompress(void *d, void *s, int size, int outsize, int *error) {
  int res;
  unsigned long bytes = outsize;
  res = uncompress(d, &bytes, s, size);
  if (res == Z_OK)
    return (int)bytes;
  else {
    *error = res;
    return -1;
  }
}


x86 assembly (clang, -O0):
<gzip_uncompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movslq -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    -0x38(%rbp),%rsi
call   1030 <uncompress@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e9d(%rip),%rcx
cmp    (%rcx),%eax
jne    1167 <gzip_uncompress+0x57>
mov    -0x38(%rbp),%rax
mov    %eax,-0x4(%rbp)
jmp    1177 <gzip_uncompress+0x67>
mov    -0x2c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%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    0x2eb8(%rip),%rcx
cmp    (%rcx),%eax
jne    1142 <gzip_uncompress+0x32>
mov    0x8(%rsp),%eax
jmp    1149 <gzip_uncompress+0x39>
mov    %eax,(%rbx)
mov    $0xffffffff,%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 i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i64
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32* %4, i32** %11
%14 = load i32, i32* %10
%15 = sext i32 %14 to i64
store i64 %15, i64* %13
%16 = load i8*, i8** %7
%17 = load i8*, i8** %8
%18 = load i32, i32* %9
%19 = call i32 @uncompress(i8* %16, i64* %13, i8* %17, i32 %18)
store i32 %19, i32* %12
%20 = load i32, i32* %12
%21 = load i32, i32* @Z_OK
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %5
%24 = load i64, i64* %13
%25 = trunc i64 %24 to i32
store i32 %25, i32* %6
br label %29
26: ; preds = %5
%27 = load i32, i32* %12
%28 = load i32*, i32** %11
store i32 %27, i32* %28
store i32 -1, i32* %6
br label %29
29: ; preds = %26, %23
%30 = load i32, i32* %6
ret i32 %30
}

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)
%10 = load i32, i32* @Z_OK
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %15
12: ; preds = %5
%13 = load i64, i64* %6
%14 = trunc i64 %13 to i32
br label %16
15: ; preds = %5
store i32 %9, i32* %4
br label %16
16: ; preds = %15, %12
%17 = phi i32 [ %14, %12 ], [ -1, %15 ]
ret i32 %17
}