#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 LZ4_compressHC_limitedOutput_continue(void *, char const *, char *, int,
                                          int);
void *LZ4_createHC(char const *);
int /*<<< orphan*/ LZ4_freeHC(void *);
int LZ4_compressHC_limitedOutput(const char *source, char *dest, int inputSize,
                                 int maxOutputSize) {
  void *ctx = LZ4_createHC(source);
  int result;
  if (ctx == NULL)
    return 0;
  result = LZ4_compressHC_limitedOutput_continue(ctx, source, dest, inputSize,
                                                 maxOutputSize);
  LZ4_freeHC(ctx);
  return result;
}


x86 assembly (clang, -O0):
<LZ4_compressHC_limitedOutput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <LZ4_createHC@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    116a <LZ4_compressHC_limitedOutput+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1194 <LZ4_compressHC_limitedOutput+0x64>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1050 <LZ4_compressHC_limitedOutput_continue@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <LZ4_freeHC@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LZ4_compressHC_limitedOutput>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%r12
mov    %rdi,%rbp
call   1030 <LZ4_createHC@plt>
test   %rax,%rax
je     1173 <LZ4_compressHC_limitedOutput+0x43>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
mov    %r14d,%r8d
call   1050 <LZ4_compressHC_limitedOutput_continue@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <LZ4_freeHC@plt>
mov    %ebp,%eax
jmp    1175 <LZ4_compressHC_limitedOutput+0x45>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @LZ4_compressHC_limitedOutput(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = tail call i8* @LZ4_createHC(i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i32 @LZ4_compressHC_limitedOutput_continue(i8* %5, i8* %0, i8* %1, i32 %2, i32 %3)
%9 = tail call i32 @LZ4_freeHC(i8* %5)
br label %10
10: ; preds = %4, %7
%11 = phi i32 [ %8, %7 ], [ 0, %4 ]
ret i32 %11
}