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

/* Variables and functions */
int /*<<< orphan*/ _mm_unpackhi_epi8(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpacklo_epi8(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/ const);
void RGB24PackedToPlanarHelper_SSE2(const __m128i *const in,
                                    __m128i *const out) {
  out[0] = _mm_unpacklo_epi8(in[0], in[3]);
  out[1] = _mm_unpackhi_epi8(in[0], in[3]);
  out[2] = _mm_unpacklo_epi8(in[1], in[4]);
  out[3] = _mm_unpackhi_epi8(in[1], in[4]);
  out[4] = _mm_unpacklo_epi8(in[2], in[5]);
  out[5] = _mm_unpackhi_epi8(in[2], in[5]);
}


x86 assembly (clang, -O0):
<RGB24PackedToPlanarHelper_SSE2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RGB24PackedToPlanarHelper_SSE2>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
mov    0xc(%rbx),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,(%r14)
mov    (%rbx),%edi
mov    0xc(%rbx),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,0x4(%r14)
mov    0x4(%rbx),%edi
mov    0x10(%rbx),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,0x8(%r14)
mov    0x4(%rbx),%edi
mov    0x10(%rbx),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,0xc(%r14)
mov    0x8(%rbx),%edi
mov    0x14(%rbx),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,0x10(%r14)
mov    0x8(%rbx),%edi
mov    0x14(%rbx),%esi
call   1040 <_mm_unpackhi_epi8@plt>
mov    %eax,0x14(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @RGB24PackedToPlanarHelper_SSE2(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
store i32* %0, i32** %3
store i32* %1, i32** %4
%5 = load i32*, i32** %3
%6 = getelementptr inbounds i32, i32* %5, i64 0
%7 = load i32, i32* %6
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 3
%10 = load i32, i32* %9
%11 = call i32 @_mm_unpacklo_epi8(i32 %7, i32 %10)
%12 = load i32*, i32** %4
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 0
%16 = load i32, i32* %15
%17 = load i32*, i32** %3
%18 = getelementptr inbounds i32, i32* %17, i64 3
%19 = load i32, i32* %18
%20 = call i32 @_mm_unpackhi_epi8(i32 %16, i32 %19)
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 1
store i32 %20, i32* %22
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 1
%25 = load i32, i32* %24
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 4
%28 = load i32, i32* %27
%29 = call i32 @_mm_unpacklo_epi8(i32 %25, i32 %28)
%30 = load i32*, i32** %4
%31 = getelementptr inbounds i32, i32* %30, i64 2
store i32 %29, i32* %31
%32 = load i32*, i32** %3
%33 = getelementptr inbounds i32, i32* %32, i64 1
%34 = load i32, i32* %33
%35 = load i32*, i32** %3
%36 = getelementptr inbounds i32, i32* %35, i64 4
%37 = load i32, i32* %36
%38 = call i32 @_mm_unpackhi_epi8(i32 %34, i32 %37)
%39 = load i32*, i32** %4
%40 = getelementptr inbounds i32, i32* %39, i64 3
store i32 %38, i32* %40
%41 = load i32*, i32** %3
%42 = getelementptr inbounds i32, i32* %41, i64 2
%43 = load i32, i32* %42
%44 = load i32*, i32** %3
%45 = getelementptr inbounds i32, i32* %44, i64 5
%46 = load i32, i32* %45
%47 = call i32 @_mm_unpacklo_epi8(i32 %43, i32 %46)
%48 = load i32*, i32** %4
%49 = getelementptr inbounds i32, i32* %48, i64 4
store i32 %47, i32* %49
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i32, i32* %50, i64 2
%52 = load i32, i32* %51
%53 = load i32*, i32** %3
%54 = getelementptr inbounds i32, i32* %53, i64 5
%55 = load i32, i32* %54
%56 = call i32 @_mm_unpackhi_epi8(i32 %52, i32 %55)
%57 = load i32*, i32** %4
%58 = getelementptr inbounds i32, i32* %57, i64 5
store i32 %56, i32* %58
ret void
}

LLVM IR (-O2):
define void @RGB24PackedToPlanarHelper_SSE2(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* %0
%4 = getelementptr inbounds i32, i32* %0, i64 3
%5 = load i32, i32* %4
%6 = tail call i32 @_mm_unpacklo_epi8(i32 %3, i32 %5)
store i32 %6, i32* %1
%7 = load i32, i32* %0
%8 = load i32, i32* %4
%9 = tail call i32 @_mm_unpackhi_epi8(i32 %7, i32 %8)
%10 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %9, i32* %10
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = getelementptr inbounds i32, i32* %0, i64 4
%14 = load i32, i32* %13
%15 = tail call i32 @_mm_unpacklo_epi8(i32 %12, i32 %14)
%16 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %15, i32* %16
%17 = load i32, i32* %11
%18 = load i32, i32* %13
%19 = tail call i32 @_mm_unpackhi_epi8(i32 %17, i32 %18)
%20 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %19, i32* %20
%21 = getelementptr inbounds i32, i32* %0, i64 2
%22 = load i32, i32* %21
%23 = getelementptr inbounds i32, i32* %0, i64 5
%24 = load i32, i32* %23
%25 = tail call i32 @_mm_unpacklo_epi8(i32 %22, i32 %24)
%26 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %25, i32* %26
%27 = load i32, i32* %21
%28 = load i32, i32* %23
%29 = tail call i32 @_mm_unpackhi_epi8(i32 %27, i32 %28)
%30 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %29, i32* %30
ret void
}