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


x86 assembly (clang, -O0):
<LZ4_compressHC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <LZ4_createHC@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1167 <LZ4_compressHC+0x37>
movl   $0x0,-0x4(%rbp)
jmp    118d <LZ4_compressHC+0x5d>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
call   1040 <LZ4_compressHC_continue@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <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>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %rdi,%rbp
call   1030 <LZ4_createHC@plt>
test   %rax,%rax
je     116c <LZ4_compressHC+0x3c>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
call   1040 <LZ4_compressHC_continue@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <LZ4_freeHC@plt>
mov    %ebp,%eax
jmp    116e <LZ4_compressHC+0x3e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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