#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 /*<<< orphan*/ subQData;

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
void DecodeRawSubData(unsigned char *subbuffer) {
  unsigned char subQData[12];
  int i;
  memset(subQData, 0, sizeof(subQData));
  for (i = 0; i < 8 * 12; i++) {
    if (subbuffer[i] & (1 << 6)) {
      subQData[i >> 3] |= (1 << (7 - (i & 7)));
    }
  }
  memcpy(&subbuffer[12], subQData, 12);
}


x86 assembly (clang, -O0):
<DecodeRawSubData>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
movl   $0x0,-0x18(%rbp)
cmpl   $0x60,-0x18(%rbp)
jge    119f <DecodeRawSubData+0x7f>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
and    $0x40,%eax
cmp    $0x0,%eax
je     118c <DecodeRawSubData+0x6c>
mov    -0x18(%rbp),%eax
and    $0x7,%eax
mov    $0x7,%ecx
sub    %eax,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x18(%rbp),%eax
sar    $0x3,%eax
cltq
movzbl -0x14(%rbp,%rax,1),%ecx
or     %edx,%ecx
mov    %cl,-0x14(%rbp,%rax,1)
jmp    1191 <DecodeRawSubData+0x71>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1143 <DecodeRawSubData+0x23>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
lea    -0x14(%rbp),%rsi
mov    $0xc,%edx
call   1040 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DecodeRawSubData>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0xc,%edx
call   1030 <memset@plt>
jmp    114a <DecodeRawSubData+0x2a>
nop
add    $0x1,%rbx
cmp    $0x60,%rbx
je     1167 <DecodeRawSubData+0x47>
testb  $0x40,(%r14,%rbx,1)
je     1140 <DecodeRawSubData+0x20>
mov    %ebx,%ecx
not    %cl
and    $0x7,%cl
mov    $0x1,%al
shl    %cl,%al
mov    %ebx,%ecx
shr    $0x3,%ecx
or     %al,0xc(%rsp,%rcx,1)
jmp    1140 <DecodeRawSubData+0x20>
add    $0xc,%r14
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
mov    $0xc,%edx
call   1040 <memcpy@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @DecodeRawSubData(i8* %0) {
%2 = alloca i8*
%3 = alloca [12 x i8]
%4 = alloca i32
store i8* %0, i8** %2
%5 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 12)
store i32 0, i32* %4
br label %7
7: ; preds = %33, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 96
br i1 %9, label %10, label %36
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = and i32 %16, 64
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %32
19: ; preds = %10
%20 = load i32, i32* %4
%21 = and i32 %20, 7
%22 = sub nsw i32 7, %21
%23 = shl i32 1, %22
%24 = load i32, i32* %4
%25 = ashr i32 %24, 3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = or i32 %29, %23
%31 = trunc i32 %30 to i8
store i8 %31, i8* %27
br label %32
32: ; preds = %19, %10
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %7
36: ; preds = %7
%37 = load i8*, i8** %2
%38 = getelementptr inbounds i8, i8* %37, i64 12
%39 = getelementptr inbounds [12 x i8], [12 x i8]* %3, i64 0, i64 0
%40 = call i32 @memcpy(i8* %38, i8* %39, i32 12)
ret void
}

LLVM IR (-O2):
define void @DecodeRawSubData(i8* %0) {
%2 = alloca [12 x i8]
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 12)
br label %5
5: ; preds = %1, %21
%6 = phi i64 [ 0, %1 ], [ %22, %21 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i8, i8* %7
%9 = and i8 %8, 64
%10 = icmp eq i8 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %5
%12 = trunc i64 %6 to i8
%13 = and i8 %12, 7
%14 = xor i8 %13, 7
%15 = shl nuw i8 1, %14
%16 = lshr i64 %6, 3
%17 = and i64 %16, 536870911
%18 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = or i8 %19, %15
store i8 %20, i8* %18
br label %21
21: ; preds = %5, %11
%22 = add nuw nsw i64 %6, 1
%23 = icmp eq i64 %22, 96
br i1 %23, label %24, label %5
24: ; preds = %21
%25 = getelementptr inbounds i8, i8* %0, i64 12
%26 = call i32 @memcpy(i8* %25, i8* %3, i32 12)
ret void
}