#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 */
struct coder {
  int dummy;
};

/* Variables and functions */
int Ptngc_unpack_array_xtc2(struct coder *, unsigned char *, int *, int const);
int Ptngc_unpack_array_xtc3(unsigned char *, int *, int const, int const);
int unpack_array_bwlzh(struct coder *, unsigned char *, int *, int const,
                       int const);
int unpack_array_stop_bits(struct coder *, unsigned char *, int *, int const,
                           int const);
int unpack_array_triplet(struct coder *, unsigned char *, int *, int const,
                         int const);
int Ptngc_unpack_array(struct coder *coder_inst, unsigned char *packed,
                       int *output, const int length, const int coding,
                       const int coding_parameter, const int natoms) {
  if ((coding == 1) || (coding == 6))
    return unpack_array_stop_bits(coder_inst, packed, output, length,
                                  coding_parameter);
  else if ((coding == 2) || (coding == 3) || (coding == 7))
    return unpack_array_triplet(coder_inst, packed, output, length,
                                coding_parameter);
  else if (coding == 5)
    return Ptngc_unpack_array_xtc2(coder_inst, packed, output, length);
  else if ((coding == 8) || (coding == 9))
    return unpack_array_bwlzh(coder_inst, packed, output, length, natoms);
  else if (coding == 10)
    return Ptngc_unpack_array_xtc3(packed, output, length, natoms);
  return 1;
}


x86 assembly (clang, -O0):
<Ptngc_unpack_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
cmpl   $0x1,-0x28(%rbp)
je     1186 <Ptngc_unpack_array+0x36>
cmpl   $0x6,-0x28(%rbp)
jne    11a6 <Ptngc_unpack_array+0x56>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1060 <unpack_array_stop_bits@plt>
mov    %eax,-0x4(%rbp)
jmp    127e <Ptngc_unpack_array+0x12e>
cmpl   $0x2,-0x28(%rbp)
je     11c4 <Ptngc_unpack_array+0x74>
cmpl   $0x3,-0x28(%rbp)
je     11c4 <Ptngc_unpack_array+0x74>
cmpl   $0x7,-0x28(%rbp)
jne    11e4 <Ptngc_unpack_array+0x94>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1050 <unpack_array_triplet@plt>
mov    %eax,-0x4(%rbp)
jmp    127e <Ptngc_unpack_array+0x12e>
cmpl   $0x5,-0x28(%rbp)
jne    120a <Ptngc_unpack_array+0xba>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1030 <Ptngc_unpack_array_xtc2@plt>
mov    %eax,-0x4(%rbp)
jmp    127e <Ptngc_unpack_array+0x12e>
cmpl   $0x8,-0x28(%rbp)
je     121e <Ptngc_unpack_array+0xce>
cmpl   $0x9,-0x28(%rbp)
jne    123e <Ptngc_unpack_array+0xee>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
mov    0x10(%rbp),%r8d
call   1040 <unpack_array_bwlzh@plt>
mov    %eax,-0x4(%rbp)
jmp    127e <Ptngc_unpack_array+0x12e>
cmpl   $0xa,-0x28(%rbp)
jne    1263 <Ptngc_unpack_array+0x113>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
mov    0x10(%rbp),%ecx
call   1070 <Ptngc_unpack_array_xtc3@plt>
mov    %eax,-0x4(%rbp)
jmp    127e <Ptngc_unpack_array+0x12e>
jmp    1268 <Ptngc_unpack_array+0x118>
jmp    126d <Ptngc_unpack_array+0x11d>
jmp    1272 <Ptngc_unpack_array+0x122>
jmp    1277 <Ptngc_unpack_array+0x127>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Ptngc_unpack_array>:
mov    %r8d,%r10d
mov    0x8(%rsp),%r8d
cmp    $0x7,%r10d
ja     118f <Ptngc_unpack_array+0x3f>
mov    $0x8c,%eax
bt     %r10d,%eax
jb     117c <Ptngc_unpack_array+0x2c>
mov    $0x42,%eax
bt     %r10d,%eax
jae    1184 <Ptngc_unpack_array+0x34>
mov    %r9d,%r8d
jmp    1060 <unpack_array_stop_bits@plt>
mov    %r9d,%r8d
jmp    1050 <unpack_array_triplet@plt>
cmp    $0x5,%r10d
jne    118f <Ptngc_unpack_array+0x3f>
jmp    1030 <Ptngc_unpack_array_xtc2@plt>
mov    %r10d,%eax
and    $0xfffffffe,%eax
cmp    $0x8,%eax
jne    119f <Ptngc_unpack_array+0x4f>
jmp    1040 <unpack_array_bwlzh@plt>
cmp    $0xa,%r10d
jne    11b5 <Ptngc_unpack_array+0x65>
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %ecx,%edx
mov    %r8d,%ecx
jmp    1070 <Ptngc_unpack_array_xtc3@plt>
mov    $0x1,%eax
ret

LLVM IR (-O0):
%struct.coder = type { i32 }
define i32 @Ptngc_unpack_array(%struct.coder* %0, i8* %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i32
%9 = alloca %struct.coder*
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store %struct.coder* %0, %struct.coder** %9
store i8* %1, i8** %10
store i32* %2, i32** %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
%16 = load i32, i32* %13
%17 = icmp eq i32 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %7
%19 = load i32, i32* %13
%20 = icmp eq i32 %19, 6
br i1 %20, label %21, label %28
21: ; preds = %18, %7
%22 = load %struct.coder*, %struct.coder** %9
%23 = load i8*, i8** %10
%24 = load i32*, i32** %11
%25 = load i32, i32* %12
%26 = load i32, i32* %14
%27 = call i32 @unpack_array_stop_bits(%struct.coder* %22, i8* %23, i32* %24, i32 %25, i32 %26)
store i32 %27, i32* %8
br label %80
28: ; preds = %18
%29 = load i32, i32* %13
%30 = icmp eq i32 %29, 2
br i1 %30, label %37, label %31
31: ; preds = %28
%32 = load i32, i32* %13
%33 = icmp eq i32 %32, 3
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %13
%36 = icmp eq i32 %35, 7
br i1 %36, label %37, label %44
37: ; preds = %34, %31, %28
%38 = load %struct.coder*, %struct.coder** %9
%39 = load i8*, i8** %10
%40 = load i32*, i32** %11
%41 = load i32, i32* %12
%42 = load i32, i32* %14
%43 = call i32 @unpack_array_triplet(%struct.coder* %38, i8* %39, i32* %40, i32 %41, i32 %42)
store i32 %43, i32* %8
br label %80
44: ; preds = %34
%45 = load i32, i32* %13
%46 = icmp eq i32 %45, 5
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load %struct.coder*, %struct.coder** %9
%49 = load i8*, i8** %10
%50 = load i32*, i32** %11
%51 = load i32, i32* %12
%52 = call i32 @Ptngc_unpack_array_xtc2(%struct.coder* %48, i8* %49, i32* %50, i32 %51)
store i32 %52, i32* %8
br label %80
53: ; preds = %44
%54 = load i32, i32* %13
%55 = icmp eq i32 %54, 8
br i1 %55, label %59, label %56
56: ; preds = %53
%57 = load i32, i32* %13
%58 = icmp eq i32 %57, 9
br i1 %58, label %59, label %66
59: ; preds = %56, %53
%60 = load %struct.coder*, %struct.coder** %9
%61 = load i8*, i8** %10
%62 = load i32*, i32** %11
%63 = load i32, i32* %12
%64 = load i32, i32* %15
%65 = call i32 @unpack_array_bwlzh(%struct.coder* %60, i8* %61, i32* %62, i32 %63, i32 %64)
store i32 %65, i32* %8
br label %80
66: ; preds = %56
%67 = load i32, i32* %13
%68 = icmp eq i32 %67, 10
br i1 %68, label %69, label %75
69: ; preds = %66
%70 = load i8*, i8** %10
%71 = load i32*, i32** %11
%72 = load i32, i32* %12
%73 = load i32, i32* %15
%74 = call i32 @Ptngc_unpack_array_xtc3(i8* %70, i32* %71, i32 %72, i32 %73)
store i32 %74, i32* %8
br label %80
75: ; preds = %66
br label %76
76: ; preds = %75
br label %77
77: ; preds = %76
br label %78
78: ; preds = %77
br label %79
79: ; preds = %78
store i32 1, i32* %8
br label %80
80: ; preds = %79, %69, %59, %47, %37, %21
%81 = load i32, i32* %8
ret i32 %81
}

LLVM IR (-O2):
%struct.coder = type { i32 }
define i32 @Ptngc_unpack_array(%struct.coder* %0, i8* %1, i32* %2, i32 %3, i32 %4, i32 %5, i32 %6) {
switch i32 %4, label %14 [
i32 6, label %8
i32 1, label %8
i32 7, label %10
i32 3, label %10
i32 2, label %10
i32 5, label %12
]
8: ; preds = %7, %7
%9 = tail call i32 @unpack_array_stop_bits(%struct.coder* %0, i8* %1, i32* %2, i32 %3, i32 %5)
br label %23
10: ; preds = %7, %7, %7
%11 = tail call i32 @unpack_array_triplet(%struct.coder* %0, i8* %1, i32* %2, i32 %3, i32 %5)
br label %23
12: ; preds = %7
%13 = tail call i32 @Ptngc_unpack_array_xtc2(%struct.coder* %0, i8* %1, i32* %2, i32 %3)
br label %23
14: ; preds = %7
%15 = and i32 %4, -2
%16 = icmp eq i32 %15, 8
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = tail call i32 @unpack_array_bwlzh(%struct.coder* %0, i8* %1, i32* %2, i32 %3, i32 %6)
br label %23
19: ; preds = %14
%20 = icmp eq i32 %4, 10
br i1 %20, label %21, label %23
21: ; preds = %19
%22 = tail call i32 @Ptngc_unpack_array_xtc3(i8* %1, i32* %2, i32 %3, i32 %6)
br label %23
23: ; preds = %19, %21, %17, %12, %10, %8
%24 = phi i32 [ %9, %8 ], [ %11, %10 ], [ %13, %12 ], [ %18, %17 ], [ %22, %21 ], [ 1, %19 ]
ret i32 %24
}