#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 */
typedef int uint8_t;

/* Variables and functions */
int fastlz1_decompress(void const *, int, void *, int);
int fastlz2_decompress(void const *, int, void *, int);
int fastlz_decompress(const void *input, int length, void *output, int maxout) {
  int level = ((*(const uint8_t *)input) >> 5) + 1;
  if (level == 1)
    return fastlz1_decompress(input, length, output, maxout);
  if (level == 2)
    return fastlz2_decompress(input, length, output, maxout);
  return 0;
}


x86 assembly (clang, -O0):
<fastlz_decompress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x5,%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    116a <fastlz_decompress+0x4a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <fastlz1_decompress@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <fastlz_decompress+0x76>
cmpl   $0x2,-0x28(%rbp)
jne    118f <fastlz_decompress+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <fastlz2_decompress@plt>
mov    %eax,-0x4(%rbp)
jmp    1196 <fastlz_decompress+0x76>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fastlz_decompress>:
mov    (%rdi),%eax
cmp    $0x1f,%eax
ja     112c <fastlz_decompress+0xc>
jmp    1030 <fastlz1_decompress@plt>
and    $0xffffffe0,%eax
cmp    $0x20,%eax
jne    1139 <fastlz_decompress+0x19>
jmp    1040 <fastlz2_decompress@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i32 @fastlz_decompress(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i8*, i8** %6
%12 = bitcast i8* %11 to i32*
%13 = load i32, i32* %12
%14 = ashr i32 %13, 5
%15 = add nsw i32 %14, 1
store i32 %15, i32* %10
%16 = load i32, i32* %10
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %24
18: ; preds = %4
%19 = load i8*, i8** %6
%20 = load i32, i32* %7
%21 = load i8*, i8** %8
%22 = load i32, i32* %9
%23 = call i32 @fastlz1_decompress(i8* %19, i32 %20, i8* %21, i32 %22)
store i32 %23, i32* %5
br label %34
24: ; preds = %4
%25 = load i32, i32* %10
%26 = icmp eq i32 %25, 2
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i8*, i8** %6
%29 = load i32, i32* %7
%30 = load i8*, i8** %8
%31 = load i32, i32* %9
%32 = call i32 @fastlz2_decompress(i8* %28, i32 %29, i8* %30, i32 %31)
store i32 %32, i32* %5
br label %34
33: ; preds = %24
store i32 0, i32* %5
br label %34
34: ; preds = %33, %27, %18
%35 = load i32, i32* %5
ret i32 %35
}

LLVM IR (-O2):
define i32 @fastlz_decompress(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = bitcast i8* %0 to i32*
%6 = load i32, i32* %5
%7 = icmp ult i32 %6, 32
br i1 %7, label %8, label %10
8: ; preds = %4
%9 = tail call i32 @fastlz1_decompress(i8* %0, i32 %1, i8* %2, i32 %3)
br label %15
10: ; preds = %4
%11 = and i32 %6, -32
%12 = icmp eq i32 %11, 32
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @fastlz2_decompress(i8* %0, i32 %1, i8* %2, i32 %3)
br label %15
15: ; preds = %10, %13, %8
%16 = phi i32 [ %9, %8 ], [ %14, %13 ], [ 0, %10 ]
ret i32 %16
}