#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 ULONG_MAX;
unsigned long blz_pack(void const *, void *, unsigned long, void *);
unsigned long blz_pack_btparse(void const *, void *, unsigned long, void *, int,
                               int);
unsigned long blz_pack_hashbucket(void const *, void *, unsigned long, void *,
                                  int, int);
unsigned long blz_pack_lazy(void const *, void *, unsigned long, void *);
unsigned long blz_pack_leparse(void const *, void *, unsigned long, void *, int,
                               int);
unsigned long blz_pack_level(const void *src, void *dst, unsigned long src_size,
                             void *workmem, int level) {
  switch (level) {
  case 1:
    return blz_pack(src, dst, src_size, workmem);
  case 2:
    return blz_pack_lazy(src, dst, src_size, workmem);
  case 3:
    return blz_pack_hashbucket(src, dst, src_size, workmem, 2, 16);
  case 4:
    return blz_pack_hashbucket(src, dst, src_size, workmem, 4, 16);
  case 5:
    return blz_pack_leparse(src, dst, src_size, workmem, 1, 16);
  case 6:
    return blz_pack_leparse(src, dst, src_size, workmem, 8, 32);
  case 7:
    return blz_pack_leparse(src, dst, src_size, workmem, 64, 64);
  case 8:
    return blz_pack_btparse(src, dst, src_size, workmem, 16, 96);
  case 9:
    return blz_pack_btparse(src, dst, src_size, workmem, 32, 224);
  case 10:
    return blz_pack_btparse(src, dst, src_size, workmem, ULONG_MAX, ULONG_MAX);
  default:
    return ((unsigned long)(-1));
  }
}


x86 assembly (clang, -O0):
<blz_pack_level>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x9,%eax
ja     1326 <blz_pack_level+0x1d6>
mov    -0x38(%rbp),%rax
lea    0xe74(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1050 <blz_pack@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   1060 <blz_pack_lazy@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x2,%r8d
mov    $0x10,%r9d
call   1030 <blz_pack_hashbucket@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x4,%r8d
mov    $0x10,%r9d
call   1030 <blz_pack_hashbucket@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x1,%r8d
mov    $0x10,%r9d
call   1040 <blz_pack_leparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x8,%r8d
mov    $0x20,%r9d
call   1040 <blz_pack_leparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x40,%r9d
mov    %r9d,%r8d
call   1040 <blz_pack_leparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x10,%r8d
mov    $0x60,%r9d
call   1070 <blz_pack_btparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0x20,%r8d
mov    $0xe0,%r9d
call   1070 <blz_pack_btparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    0x2ccd(%rip),%rax
mov    (%rax),%r8d
mov    0x2cc3(%rip),%rax
mov    (%rax),%r9d
call   1070 <blz_pack_btparse@plt>
mov    %rax,-0x8(%rbp)
jmp    132e <blz_pack_level+0x1de>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blz_pack_level>:
add    $0xffffffff,%r8d
cmp    $0x9,%r8d
ja     116f <blz_pack_level+0x1f>
lea    0xe9f(%rip),%r9
movslq (%r9,%r8,4),%rax
add    %r9,%rax
jmp    *%rax
jmp    1050 <blz_pack@plt>
mov    $0xffffffffffffffff,%rax
ret
jmp    1060 <blz_pack_lazy@plt>
mov    $0x2,%r8d
mov    $0x10,%r9d
jmp    1030 <blz_pack_hashbucket@plt>
mov    $0x4,%r8d
mov    $0x10,%r9d
jmp    1030 <blz_pack_hashbucket@plt>
mov    $0x1,%r8d
mov    $0x10,%r9d
jmp    1040 <blz_pack_leparse@plt>
mov    $0x8,%r8d
mov    $0x20,%r9d
jmp    1040 <blz_pack_leparse@plt>
mov    $0x40,%r8d
mov    $0x40,%r9d
jmp    1040 <blz_pack_leparse@plt>
mov    $0x10,%r8d
mov    $0x60,%r9d
jmp    1070 <blz_pack_btparse@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%r8d
mov    %r8d,%r9d
jmp    1070 <blz_pack_btparse@plt>
mov    $0x20,%r8d
mov    $0xe0,%r9d
jmp    1070 <blz_pack_btparse@plt>

LLVM IR (-O0):
@ULONG_MAX = global i32 0
define i64 @blz_pack_level(i8* %0, i8* %1, i64 %2, i8* %3, i32 %4) {
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%12 = load i32, i32* %11
switch i32 %12, label %75 [
i32 1, label %13
i32 2, label %19
i32 3, label %25
i32 4, label %31
i32 5, label %37
i32 6, label %43
i32 7, label %49
i32 8, label %55
i32 9, label %61
i32 10, label %67
]
13: ; preds = %5
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i64, i64* %9
%17 = load i8*, i8** %10
%18 = call i64 @blz_pack(i8* %14, i8* %15, i64 %16, i8* %17)
store i64 %18, i64* %6
br label %76
19: ; preds = %5
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = load i64, i64* %9
%23 = load i8*, i8** %10
%24 = call i64 @blz_pack_lazy(i8* %20, i8* %21, i64 %22, i8* %23)
store i64 %24, i64* %6
br label %76
25: ; preds = %5
%26 = load i8*, i8** %7
%27 = load i8*, i8** %8
%28 = load i64, i64* %9
%29 = load i8*, i8** %10
%30 = call i64 @blz_pack_hashbucket(i8* %26, i8* %27, i64 %28, i8* %29, i32 2, i32 16)
store i64 %30, i64* %6
br label %76
31: ; preds = %5
%32 = load i8*, i8** %7
%33 = load i8*, i8** %8
%34 = load i64, i64* %9
%35 = load i8*, i8** %10
%36 = call i64 @blz_pack_hashbucket(i8* %32, i8* %33, i64 %34, i8* %35, i32 4, i32 16)
store i64 %36, i64* %6
br label %76
37: ; preds = %5
%38 = load i8*, i8** %7
%39 = load i8*, i8** %8
%40 = load i64, i64* %9
%41 = load i8*, i8** %10
%42 = call i64 @blz_pack_leparse(i8* %38, i8* %39, i64 %40, i8* %41, i32 1, i32 16)
store i64 %42, i64* %6
br label %76
43: ; preds = %5
%44 = load i8*, i8** %7
%45 = load i8*, i8** %8
%46 = load i64, i64* %9
%47 = load i8*, i8** %10
%48 = call i64 @blz_pack_leparse(i8* %44, i8* %45, i64 %46, i8* %47, i32 8, i32 32)
store i64 %48, i64* %6
br label %76
49: ; preds = %5
%50 = load i8*, i8** %7
%51 = load i8*, i8** %8
%52 = load i64, i64* %9
%53 = load i8*, i8** %10
%54 = call i64 @blz_pack_leparse(i8* %50, i8* %51, i64 %52, i8* %53, i32 64, i32 64)
store i64 %54, i64* %6
br label %76
55: ; preds = %5
%56 = load i8*, i8** %7
%57 = load i8*, i8** %8
%58 = load i64, i64* %9
%59 = load i8*, i8** %10
%60 = call i64 @blz_pack_btparse(i8* %56, i8* %57, i64 %58, i8* %59, i32 16, i32 96)
store i64 %60, i64* %6
br label %76
61: ; preds = %5
%62 = load i8*, i8** %7
%63 = load i8*, i8** %8
%64 = load i64, i64* %9
%65 = load i8*, i8** %10
%66 = call i64 @blz_pack_btparse(i8* %62, i8* %63, i64 %64, i8* %65, i32 32, i32 224)
store i64 %66, i64* %6
br label %76
67: ; preds = %5
%68 = load i8*, i8** %7
%69 = load i8*, i8** %8
%70 = load i64, i64* %9
%71 = load i8*, i8** %10
%72 = load i32, i32* @ULONG_MAX
%73 = load i32, i32* @ULONG_MAX
%74 = call i64 @blz_pack_btparse(i8* %68, i8* %69, i64 %70, i8* %71, i32 %72, i32 %73)
store i64 %74, i64* %6
br label %76
75: ; preds = %5
store i64 -1, i64* %6
br label %76
76: ; preds = %75, %67, %61, %55, %49, %43, %37, %31, %25, %19, %13
%77 = load i64, i64* %6
ret i64 %77
}

LLVM IR (-O2):
@ULONG_MAX = global i32 0
define i64 @blz_pack_level(i8* %0, i8* %1, i64 %2, i8* %3, i32 %4) {
switch i32 %4, label %27 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
i32 6, label %16
i32 7, label %18
i32 8, label %20
i32 9, label %22
i32 10, label %24
]
6: ; preds = %5
%7 = tail call i64 @blz_pack(i8* %0, i8* %1, i64 %2, i8* %3)
br label %27
8: ; preds = %5
%9 = tail call i64 @blz_pack_lazy(i8* %0, i8* %1, i64 %2, i8* %3)
br label %27
10: ; preds = %5
%11 = tail call i64 @blz_pack_hashbucket(i8* %0, i8* %1, i64 %2, i8* %3, i32 2, i32 16)
br label %27
12: ; preds = %5
%13 = tail call i64 @blz_pack_hashbucket(i8* %0, i8* %1, i64 %2, i8* %3, i32 4, i32 16)
br label %27
14: ; preds = %5
%15 = tail call i64 @blz_pack_leparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 1, i32 16)
br label %27
16: ; preds = %5
%17 = tail call i64 @blz_pack_leparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 8, i32 32)
br label %27
18: ; preds = %5
%19 = tail call i64 @blz_pack_leparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 64, i32 64)
br label %27
20: ; preds = %5
%21 = tail call i64 @blz_pack_btparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 16, i32 96)
br label %27
22: ; preds = %5
%23 = tail call i64 @blz_pack_btparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 32, i32 224)
br label %27
24: ; preds = %5
%25 = load i32, i32* @ULONG_MAX
%26 = tail call i64 @blz_pack_btparse(i8* %0, i8* %1, i64 %2, i8* %3, i32 %25, i32 %25)
br label %27
27: ; preds = %5, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
%28 = phi i64 [ %26, %24 ], [ %23, %22 ], [ %21, %20 ], [ %19, %18 ], [ %17, %16 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ], [ %7, %6 ], [ -1, %5 ]
ret i64 %28
}