#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 */
long long gunzip(char *, long long, char **, long long *, int);
long long int replace_gzipped_with_gunzipped(char **inoutbuf,
                                             long long int inlen,
                                             int max_growth) {
  long long int outlen;
  long long int retcode;
  char *temp_inoutbuf = *inoutbuf;
  retcode = gunzip(*inoutbuf, inlen, &temp_inoutbuf, &outlen, max_growth);
  if (retcode == 0) {
    *inoutbuf = temp_inoutbuf;
    return (outlen);
  } else {
    return (retcode * -1);
  }
}


x86 assembly (clang, -O0):
<replace_gzipped_with_gunzipped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%r8d
lea    -0x38(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1030 <gunzip@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1171 <replace_gzipped_with_gunzipped+0x61>
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117a <replace_gzipped_with_gunzipped+0x6a>
imul   $0xffffffffffffffff,-0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<replace_gzipped_with_gunzipped>:
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r8d
mov    %rdi,%rbx
mov    (%rdi),%rdi
mov    %rdi,(%rsp)
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
call   1030 <gunzip@plt>
test   %rax,%rax
je     1139 <replace_gzipped_with_gunzipped+0x29>
neg    %rax
jmp    1145 <replace_gzipped_with_gunzipped+0x35>
mov    (%rsp),%rax
mov    %rax,(%rbx)
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i64 @replace_gzipped_with_gunzipped(i8** %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
store i8** %0, i8*** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%11 = load i8**, i8*** %5
%12 = load i8*, i8** %11
store i8* %12, i8** %10
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = load i64, i64* %6
%16 = load i32, i32* %7
%17 = call i64 @gunzip(i8* %14, i64 %15, i8** %10, i64* %8, i32 %16)
store i64 %17, i64* %9
%18 = load i64, i64* %9
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %3
%21 = load i8*, i8** %10
%22 = load i8**, i8*** %5
store i8* %21, i8** %22
%23 = load i64, i64* %8
store i64 %23, i64* %4
br label %27
24: ; preds = %3
%25 = load i64, i64* %9
%26 = mul nsw i64 %25, -1
store i64 %26, i64* %4
br label %27
27: ; preds = %24, %20
%28 = load i64, i64* %4
ret i64 %28
}

LLVM IR (-O2):
define i64 @replace_gzipped_with_gunzipped(i8** nocapture %0, i64 %1, i32 %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = bitcast i64* %4 to i8*
%7 = bitcast i8** %5 to i8*
%8 = load i8*, i8** %0
store i8* %8, i8** %5
%9 = call i64 @gunzip(i8* %8, i64 %1, i8** %5, i64* %4, i32 %2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load i8*, i8** %5
store i8* %12, i8** %0
%13 = load i64, i64* %4
br label %16
14: ; preds = %3
%15 = sub nsw i64 0, %9
br label %16
16: ; preds = %14, %11
%17 = phi i64 [ %13, %11 ], [ %15, %14 ]
ret i64 %17
}