#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 /*<<< orphan*/ aplib_unpack(unsigned char *, unsigned char *);
int /*<<< orphan*/ rle4b_unpack(unsigned char *, unsigned char *);
int /*<<< orphan*/ rlemap_unpack(unsigned char *, unsigned char *);
void unpack(unsigned short compression, unsigned char *src,
            unsigned char *dest) {
  switch (compression) {
  default:
    break;
  case 1:
    aplib_unpack(src, dest);
    break;
  case 3:
    rle4b_unpack(src, dest);
    break;
  case 4:
    rlemap_unpack(src, dest);
    break;
  }
}


x86 assembly (clang, -O0):
<unpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movzwl -0x2(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     1183 <unpack+0x53>
jmp    115c <unpack+0x2c>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     1195 <unpack+0x65>
jmp    116d <unpack+0x3d>
mov    -0x1c(%rbp),%eax
sub    $0x4,%eax
je     11a7 <unpack+0x77>
jmp    117e <unpack+0x4e>
jmp    11b4 <unpack+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <aplib_unpack@plt>
jmp    11b4 <unpack+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <rle4b_unpack@plt>
jmp    11b4 <unpack+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <rlemap_unpack@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unpack>:
cmp    $0x4,%di
je     114d <unpack+0x1d>
cmp    $0x3,%di
je     1158 <unpack+0x28>
cmp    $0x1,%di
jne    1163 <unpack+0x33>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1030 <aplib_unpack@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1050 <rlemap_unpack@plt>
mov    %rsi,%rdi
mov    %rdx,%rsi
jmp    1040 <rle4b_unpack@plt>
ret

LLVM IR (-O0):
define void @unpack(i16 zeroext %0, i8* %1, i8* %2) {
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i8*
store i16 %0, i16* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i16, i16* %4
%8 = zext i16 %7 to i32
switch i32 %8, label %9 [
i32 1, label %10
i32 3, label %14
i32 4, label %18
]
9: ; preds = %3
br label %22
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = call i32 @aplib_unpack(i8* %11, i8* %12)
br label %22
14: ; preds = %3
%15 = load i8*, i8** %5
%16 = load i8*, i8** %6
%17 = call i32 @rle4b_unpack(i8* %15, i8* %16)
br label %22
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = load i8*, i8** %6
%21 = call i32 @rlemap_unpack(i8* %19, i8* %20)
br label %22
22: ; preds = %18, %14, %10, %9
ret void
}

LLVM IR (-O2):
define void @unpack(i16 zeroext %0, i8* %1, i8* %2) {
switch i16 %0, label %10 [
i16 1, label %4
i16 3, label %6
i16 4, label %8
]
4: ; preds = %3
%5 = tail call i32 @aplib_unpack(i8* %1, i8* %2)
br label %10
6: ; preds = %3
%7 = tail call i32 @rle4b_unpack(i8* %1, i8* %2)
br label %10
8: ; preds = %3
%9 = tail call i32 @rlemap_unpack(i8* %1, i8* %2)
br label %10
10: ; preds = %3, %8, %6, %4
ret void
}