#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;
typedef int uint32_t;

/* Variables and functions */
void Decompress16x3bitIndices(const uint8_t *packed, uint8_t *unpacked) {
  uint32_t tmp, block, i;
  for (block = 0; block < 2; ++block) {
    tmp = 0;
    for (i = 0; i < 3; ++i) {
      tmp |= ((uint32_t)packed[i]) << (i * 8);
    }
    for (i = 0; i < 8; ++i) {
      unpacked[i] = (tmp >> (i * 3)) & 0x7;
    }
    packed += 3;
    unpacked += 8;
  }
}


x86 assembly (clang, -O0):
<Decompress16x3bitIndices>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x2,-0x18(%rbp)
jge    11b8 <Decompress16x3bitIndices+0xb8>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    115c <Decompress16x3bitIndices+0x5c>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x1c(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112b <Decompress16x3bitIndices+0x2b>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x8,-0x1c(%rbp)
jge    1192 <Decompress16x3bitIndices+0x92>
mov    -0x14(%rbp),%edx
imul   $0x3,-0x1c(%rbp),%ecx
sar    %cl,%edx
and    $0x7,%edx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <Decompress16x3bitIndices+0x63>
mov    -0x8(%rbp),%rax
add    $0xc,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x20,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1113 <Decompress16x3bitIndices+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<Decompress16x3bitIndices>:
mov    (%rdi),%eax
mov    0x4(%rdi),%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    0x8(%rdi),%r8d
shl    $0x10,%r8d
or     %ecx,%r8d
mov    %eax,%edx
and    $0x7,%edx
mov    %edx,(%rsi)
shr    $0x3,%eax
and    $0x7,%eax
mov    %eax,0x4(%rsi)
mov    %ecx,%eax
shr    $0x6,%eax
and    $0x7,%eax
mov    %eax,0x8(%rsi)
mov    %ecx,%eax
shr    $0x9,%eax
and    $0x7,%eax
mov    %eax,0xc(%rsi)
shr    $0xc,%ecx
and    $0x7,%ecx
mov    %ecx,0x10(%rsi)
mov    %r8d,%eax
shr    $0xf,%eax
and    $0x7,%eax
mov    %eax,0x14(%rsi)
mov    %r8d,%eax
shr    $0x12,%eax
and    $0x7,%eax
mov    %eax,0x18(%rsi)
shr    $0x15,%r8d
and    $0x7,%r8d
mov    %r8d,0x1c(%rsi)
mov    0xc(%rdi),%edx
mov    0x10(%rdi),%ecx
shl    $0x8,%ecx
or     %edx,%ecx
mov    0x14(%rdi),%eax
shl    $0x10,%eax
or     %ecx,%eax
mov    %edx,%edi
and    $0x7,%edi
mov    %edi,0x20(%rsi)
shr    $0x3,%edx
and    $0x7,%edx
mov    %edx,0x24(%rsi)
mov    %ecx,%edx
shr    $0x6,%edx
and    $0x7,%edx
mov    %edx,0x28(%rsi)
mov    %ecx,%edx
shr    $0x9,%edx
and    $0x7,%edx
mov    %edx,0x2c(%rsi)
shr    $0xc,%ecx
and    $0x7,%ecx
mov    %ecx,0x30(%rsi)
mov    %eax,%ecx
shr    $0xf,%ecx
and    $0x7,%ecx
mov    %ecx,0x34(%rsi)
mov    %eax,%ecx
shr    $0x12,%ecx
and    $0x7,%ecx
mov    %ecx,0x38(%rsi)
shr    $0x15,%eax
and    $0x7,%eax
mov    %eax,0x3c(%rsi)
ret

LLVM IR (-O0):
define void @Decompress16x3bitIndices(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
br label %8
8: ; preds = %51, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %54
11: ; preds = %8
store i32 0, i32* %5
store i32 0, i32* %7
br label %12
12: ; preds = %26, %11
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %29
15: ; preds = %12
%16 = load i32*, i32** %3
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %7
%22 = mul nsw i32 %21, 8
%23 = shl i32 %20, %22
%24 = load i32, i32* %5
%25 = or i32 %24, %23
store i32 %25, i32* %5
br label %26
26: ; preds = %15
%27 = load i32, i32* %7
%28 = add nsw i32 %27, 1
store i32 %28, i32* %7
br label %12
29: ; preds = %12
store i32 0, i32* %7
br label %30
30: ; preds = %43, %29
%31 = load i32, i32* %7
%32 = icmp slt i32 %31, 8
br i1 %32, label %33, label %46
33: ; preds = %30
%34 = load i32, i32* %5
%35 = load i32, i32* %7
%36 = mul nsw i32 %35, 3
%37 = ashr i32 %34, %36
%38 = and i32 %37, 7
%39 = load i32*, i32** %4
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
br label %43
43: ; preds = %33
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %30
46: ; preds = %30
%47 = load i32*, i32** %3
%48 = getelementptr inbounds i32, i32* %47, i64 3
store i32* %48, i32** %3
%49 = load i32*, i32** %4
%50 = getelementptr inbounds i32, i32* %49, i64 8
store i32* %50, i32** %4
br label %51
51: ; preds = %46
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %8
54: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @Decompress16x3bitIndices(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* %0
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = load i32, i32* %4
%6 = shl i32 %5, 8
%7 = or i32 %6, %3
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = shl i32 %9, 16
%11 = or i32 %10, %7
%12 = and i32 %3, 7
store i32 %12, i32* %1
%13 = lshr i32 %3, 3
%14 = and i32 %13, 7
%15 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %14, i32* %15
%16 = lshr i32 %7, 6
%17 = and i32 %16, 7
%18 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %17, i32* %18
%19 = lshr i32 %7, 9
%20 = and i32 %19, 7
%21 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %20, i32* %21
%22 = lshr i32 %7, 12
%23 = and i32 %22, 7
%24 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %23, i32* %24
%25 = lshr i32 %11, 15
%26 = and i32 %25, 7
%27 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %26, i32* %27
%28 = lshr i32 %11, 18
%29 = and i32 %28, 7
%30 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %29, i32* %30
%31 = lshr i32 %11, 21
%32 = and i32 %31, 7
%33 = getelementptr inbounds i32, i32* %1, i64 7
store i32 %32, i32* %33
%34 = getelementptr inbounds i32, i32* %0, i64 3
%35 = getelementptr inbounds i32, i32* %1, i64 8
%36 = load i32, i32* %34
%37 = getelementptr inbounds i32, i32* %0, i64 4
%38 = load i32, i32* %37
%39 = shl i32 %38, 8
%40 = or i32 %39, %36
%41 = getelementptr inbounds i32, i32* %0, i64 5
%42 = load i32, i32* %41
%43 = shl i32 %42, 16
%44 = or i32 %43, %40
%45 = and i32 %36, 7
store i32 %45, i32* %35
%46 = lshr i32 %36, 3
%47 = and i32 %46, 7
%48 = getelementptr inbounds i32, i32* %1, i64 9
store i32 %47, i32* %48
%49 = lshr i32 %40, 6
%50 = and i32 %49, 7
%51 = getelementptr inbounds i32, i32* %1, i64 10
store i32 %50, i32* %51
%52 = lshr i32 %40, 9
%53 = and i32 %52, 7
%54 = getelementptr inbounds i32, i32* %1, i64 11
store i32 %53, i32* %54
%55 = lshr i32 %40, 12
%56 = and i32 %55, 7
%57 = getelementptr inbounds i32, i32* %1, i64 12
store i32 %56, i32* %57
%58 = lshr i32 %44, 15
%59 = and i32 %58, 7
%60 = getelementptr inbounds i32, i32* %1, i64 13
store i32 %59, i32* %60
%61 = lshr i32 %44, 18
%62 = and i32 %61, 7
%63 = getelementptr inbounds i32, i32* %1, i64 14
store i32 %62, i32* %63
%64 = lshr i32 %44, 21
%65 = and i32 %64, 7
%66 = getelementptr inbounds i32, i32* %1, i64 15
store i32 %65, i32* %66
ret void
}