#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_epi32(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpackhi_epi64(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpacklo_epi16(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpacklo_epi32(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpacklo_epi64(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
void array_transpose_4X8(__m128i *in, __m128i *out) {
  const __m128i tr0_0 = _mm_unpacklo_epi16(in[0], in[1]);
  const __m128i tr0_1 = _mm_unpacklo_epi16(in[2], in[3]);
  const __m128i tr0_4 = _mm_unpacklo_epi16(in[4], in[5]);
  const __m128i tr0_5 = _mm_unpacklo_epi16(in[6], in[7]);
  const __m128i tr1_0 = _mm_unpacklo_epi32(tr0_0, tr0_1);
  const __m128i tr1_2 = _mm_unpackhi_epi32(tr0_0, tr0_1);
  const __m128i tr1_4 = _mm_unpacklo_epi32(tr0_4, tr0_5);
  const __m128i tr1_6 = _mm_unpackhi_epi32(tr0_4, tr0_5);
  out[0] = _mm_unpacklo_epi64(tr1_0, tr1_4);
  out[1] = _mm_unpackhi_epi64(tr1_0, tr1_4);
  out[2] = _mm_unpacklo_epi64(tr1_2, tr1_6);
  out[3] = _mm_unpackhi_epi64(tr1_2, tr1_6);
}


x86 assembly (clang, -O0):
<array_transpose_4X8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_transpose_4X8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
mov    0x4(%rbx),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,%r15d
mov    0x8(%rbx),%edi
mov    0xc(%rbx),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%edi
mov    0x14(%rbx),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,%r12d
mov    0x18(%rbx),%edi
mov    0x1c(%rbx),%esi
call   1050 <_mm_unpacklo_epi16@plt>
mov    %eax,%ebx
mov    %r15d,%edi
mov    %ebp,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%r13d
mov    %r15d,%edi
mov    %ebp,%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,%r15d
mov    %r12d,%edi
mov    %ebx,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %ebx,%esi
call   1070 <_mm_unpackhi_epi32@plt>
mov    %eax,%ebx
mov    %r13d,%edi
mov    %ebp,%esi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %eax,(%r14)
mov    %r13d,%edi
mov    %ebp,%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,0x4(%r14)
mov    %r15d,%edi
mov    %ebx,%esi
call   1060 <_mm_unpacklo_epi64@plt>
mov    %eax,0x8(%r14)
mov    %r15d,%edi
mov    %ebx,%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,0xc(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @array_transpose_4X8(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 0
%15 = load i32, i32* %14
%16 = load i32*, i32** %3
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32, i32* %17
%19 = call i32 @_mm_unpacklo_epi16(i32 %15, i32 %18)
store i32 %19, i32* %5
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 2
%22 = load i32, i32* %21
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 3
%25 = load i32, i32* %24
%26 = call i32 @_mm_unpacklo_epi16(i32 %22, i32 %25)
store i32 %26, i32* %6
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 4
%29 = load i32, i32* %28
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 5
%32 = load i32, i32* %31
%33 = call i32 @_mm_unpacklo_epi16(i32 %29, i32 %32)
store i32 %33, i32* %7
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i64 6
%36 = load i32, i32* %35
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 7
%39 = load i32, i32* %38
%40 = call i32 @_mm_unpacklo_epi16(i32 %36, i32 %39)
store i32 %40, i32* %8
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 @_mm_unpacklo_epi32(i32 %41, i32 %42)
store i32 %43, i32* %9
%44 = load i32, i32* %5
%45 = load i32, i32* %6
%46 = call i32 @_mm_unpackhi_epi32(i32 %44, i32 %45)
store i32 %46, i32* %10
%47 = load i32, i32* %7
%48 = load i32, i32* %8
%49 = call i32 @_mm_unpacklo_epi32(i32 %47, i32 %48)
store i32 %49, i32* %11
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 @_mm_unpackhi_epi32(i32 %50, i32 %51)
store i32 %52, i32* %12
%53 = load i32, i32* %9
%54 = load i32, i32* %11
%55 = call i32 @_mm_unpacklo_epi64(i32 %53, i32 %54)
%56 = load i32*, i32** %4
%57 = getelementptr inbounds i32, i32* %56, i64 0
store i32 %55, i32* %57
%58 = load i32, i32* %9
%59 = load i32, i32* %11
%60 = call i32 @_mm_unpackhi_epi64(i32 %58, i32 %59)
%61 = load i32*, i32** %4
%62 = getelementptr inbounds i32, i32* %61, i64 1
store i32 %60, i32* %62
%63 = load i32, i32* %10
%64 = load i32, i32* %12
%65 = call i32 @_mm_unpacklo_epi64(i32 %63, i32 %64)
%66 = load i32*, i32** %4
%67 = getelementptr inbounds i32, i32* %66, i64 2
store i32 %65, i32* %67
%68 = load i32, i32* %10
%69 = load i32, i32* %12
%70 = call i32 @_mm_unpackhi_epi64(i32 %68, i32 %69)
%71 = load i32*, i32** %4
%72 = getelementptr inbounds i32, i32* %71, i64 3
store i32 %70, i32* %72
ret void
}

LLVM IR (-O2):
define void @array_transpose_4X8(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 = tail call i32 @_mm_unpacklo_epi16(i32 %3, i32 %5)
%7 = getelementptr inbounds i32, i32* %0, i64 2
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %0, i64 3
%10 = load i32, i32* %9
%11 = tail call i32 @_mm_unpacklo_epi16(i32 %8, i32 %10)
%12 = getelementptr inbounds i32, i32* %0, i64 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds i32, i32* %0, i64 5
%15 = load i32, i32* %14
%16 = tail call i32 @_mm_unpacklo_epi16(i32 %13, i32 %15)
%17 = getelementptr inbounds i32, i32* %0, i64 6
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %0, i64 7
%20 = load i32, i32* %19
%21 = tail call i32 @_mm_unpacklo_epi16(i32 %18, i32 %20)
%22 = tail call i32 @_mm_unpacklo_epi32(i32 %6, i32 %11)
%23 = tail call i32 @_mm_unpackhi_epi32(i32 %6, i32 %11)
%24 = tail call i32 @_mm_unpacklo_epi32(i32 %16, i32 %21)
%25 = tail call i32 @_mm_unpackhi_epi32(i32 %16, i32 %21)
%26 = tail call i32 @_mm_unpacklo_epi64(i32 %22, i32 %24)
store i32 %26, i32* %1
%27 = tail call i32 @_mm_unpackhi_epi64(i32 %22, i32 %24)
%28 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %27, i32* %28
%29 = tail call i32 @_mm_unpacklo_epi64(i32 %23, i32 %25)
%30 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %29, i32* %30
%31 = tail call i32 @_mm_unpackhi_epi64(i32 %23, i32 %25)
%32 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %31, i32* %32
ret void
}