#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_epi32(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
int /*<<< orphan*/ _mm_unpacklo_epi64(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
void transpose_32bit_8x4(const __m128i *const in, __m128i *const out) {
  const __m128i a0 = _mm_unpacklo_epi32(in[0], in[2]);
  const __m128i a1 = _mm_unpacklo_epi32(in[4], in[6]);
  const __m128i a2 = _mm_unpackhi_epi32(in[0], in[2]);
  const __m128i a3 = _mm_unpackhi_epi32(in[4], in[6]);
  const __m128i a4 = _mm_unpacklo_epi32(in[1], in[3]);
  const __m128i a5 = _mm_unpacklo_epi32(in[5], in[7]);
  const __m128i a6 = _mm_unpackhi_epi32(in[1], in[3]);
  const __m128i a7 = _mm_unpackhi_epi32(in[5], in[7]);
  out[0] = _mm_unpacklo_epi64(a0, a1);
  out[1] = _mm_unpackhi_epi64(a0, a1);
  out[2] = _mm_unpacklo_epi64(a2, a3);
  out[3] = _mm_unpackhi_epi64(a2, a3);
  out[4] = _mm_unpacklo_epi64(a4, a5);
  out[5] = _mm_unpackhi_epi64(a4, a5);
  out[6] = _mm_unpacklo_epi64(a6, a7);
  out[7] = _mm_unpackhi_epi64(a6, a7);
}


x86 assembly (clang, -O0):
<transpose_32bit_8x4>:
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    0x8(%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
call   1060 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%esi
call   1060 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1060 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
call   1060 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
add    $0x30,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @transpose_32bit_8x4(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 2
%18 = load i32, i32* %17
%19 = call i32 @_mm_unpacklo_epi32(i32 %15, i32 %18)
store i32 %19, i32* %5
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 4
%22 = load i32, i32* %21
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 6
%25 = load i32, i32* %24
%26 = call i32 @_mm_unpacklo_epi32(i32 %22, i32 %25)
store i32 %26, i32* %6
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 0
%29 = load i32, i32* %28
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 2
%32 = load i32, i32* %31
%33 = call i32 @_mm_unpackhi_epi32(i32 %29, i32 %32)
store i32 %33, i32* %7
%34 = load i32*, i32** %3
%35 = getelementptr inbounds i32, i32* %34, i64 4
%36 = load i32, i32* %35
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 6
%39 = load i32, i32* %38
%40 = call i32 @_mm_unpackhi_epi32(i32 %36, i32 %39)
store i32 %40, i32* %8
%41 = load i32*, i32** %3
%42 = getelementptr inbounds i32, i32* %41, i64 1
%43 = load i32, i32* %42
%44 = load i32*, i32** %3
%45 = getelementptr inbounds i32, i32* %44, i64 3
%46 = load i32, i32* %45
%47 = call i32 @_mm_unpacklo_epi32(i32 %43, i32 %46)
store i32 %47, i32* %9
%48 = load i32*, i32** %3
%49 = getelementptr inbounds i32, i32* %48, i64 5
%50 = load i32, i32* %49
%51 = load i32*, i32** %3
%52 = getelementptr inbounds i32, i32* %51, i64 7
%53 = load i32, i32* %52
%54 = call i32 @_mm_unpacklo_epi32(i32 %50, i32 %53)
store i32 %54, i32* %10
%55 = load i32*, i32** %3
%56 = getelementptr inbounds i32, i32* %55, i64 1
%57 = load i32, i32* %56
%58 = load i32*, i32** %3
%59 = getelementptr inbounds i32, i32* %58, i64 3
%60 = load i32, i32* %59
%61 = call i32 @_mm_unpackhi_epi32(i32 %57, i32 %60)
store i32 %61, i32* %11
%62 = load i32*, i32** %3
%63 = getelementptr inbounds i32, i32* %62, i64 5
%64 = load i32, i32* %63
%65 = load i32*, i32** %3
%66 = getelementptr inbounds i32, i32* %65, i64 7
%67 = load i32, i32* %66
%68 = call i32 @_mm_unpackhi_epi32(i32 %64, i32 %67)
store i32 %68, i32* %12
%69 = load i32, i32* %5
%70 = load i32, i32* %6
%71 = call i32 @_mm_unpacklo_epi64(i32 %69, i32 %70)
%72 = load i32*, i32** %4
%73 = getelementptr inbounds i32, i32* %72, i64 0
store i32 %71, i32* %73
%74 = load i32, i32* %5
%75 = load i32, i32* %6
%76 = call i32 @_mm_unpackhi_epi64(i32 %74, i32 %75)
%77 = load i32*, i32** %4
%78 = getelementptr inbounds i32, i32* %77, i64 1
store i32 %76, i32* %78
%79 = load i32, i32* %7
%80 = load i32, i32* %8
%81 = call i32 @_mm_unpacklo_epi64(i32 %79, i32 %80)
%82 = load i32*, i32** %4
%83 = getelementptr inbounds i32, i32* %82, i64 2
store i32 %81, i32* %83
%84 = load i32, i32* %7
%85 = load i32, i32* %8
%86 = call i32 @_mm_unpackhi_epi64(i32 %84, i32 %85)
%87 = load i32*, i32** %4
%88 = getelementptr inbounds i32, i32* %87, i64 3
store i32 %86, i32* %88
%89 = load i32, i32* %9
%90 = load i32, i32* %10
%91 = call i32 @_mm_unpacklo_epi64(i32 %89, i32 %90)
%92 = load i32*, i32** %4
%93 = getelementptr inbounds i32, i32* %92, i64 4
store i32 %91, i32* %93
%94 = load i32, i32* %9
%95 = load i32, i32* %10
%96 = call i32 @_mm_unpackhi_epi64(i32 %94, i32 %95)
%97 = load i32*, i32** %4
%98 = getelementptr inbounds i32, i32* %97, i64 5
store i32 %96, i32* %98
%99 = load i32, i32* %11
%100 = load i32, i32* %12
%101 = call i32 @_mm_unpacklo_epi64(i32 %99, i32 %100)
%102 = load i32*, i32** %4
%103 = getelementptr inbounds i32, i32* %102, i64 6
store i32 %101, i32* %103
%104 = load i32, i32* %11
%105 = load i32, i32* %12
%106 = call i32 @_mm_unpackhi_epi64(i32 %104, i32 %105)
%107 = load i32*, i32** %4
%108 = getelementptr inbounds i32, i32* %107, i64 7
store i32 %106, i32* %108
ret void
}

LLVM IR (-O2):
define void @transpose_32bit_8x4(i32* nocapture %0, i32* nocapture writeonly %1) {
%3 = load i32, i32* %0
%4 = getelementptr inbounds i32, i32* %0, i64 2
%5 = load i32, i32* %4
%6 = tail call i32 @_mm_unpacklo_epi32(i32 %3, i32 %5)
%7 = getelementptr inbounds i32, i32* %0, i64 4
%8 = load i32, i32* %7
%9 = getelementptr inbounds i32, i32* %0, i64 6
%10 = load i32, i32* %9
%11 = tail call i32 @_mm_unpacklo_epi32(i32 %8, i32 %10)
%12 = load i32, i32* %0
%13 = load i32, i32* %4
%14 = tail call i32 @_mm_unpackhi_epi32(i32 %12, i32 %13)
%15 = load i32, i32* %7
%16 = load i32, i32* %9
%17 = tail call i32 @_mm_unpackhi_epi32(i32 %15, i32 %16)
%18 = getelementptr inbounds i32, i32* %0, i64 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds i32, i32* %0, i64 3
%21 = load i32, i32* %20
%22 = tail call i32 @_mm_unpacklo_epi32(i32 %19, i32 %21)
%23 = getelementptr inbounds i32, i32* %0, i64 5
%24 = load i32, i32* %23
%25 = getelementptr inbounds i32, i32* %0, i64 7
%26 = load i32, i32* %25
%27 = tail call i32 @_mm_unpacklo_epi32(i32 %24, i32 %26)
%28 = load i32, i32* %18
%29 = load i32, i32* %20
%30 = tail call i32 @_mm_unpackhi_epi32(i32 %28, i32 %29)
%31 = load i32, i32* %23
%32 = load i32, i32* %25
%33 = tail call i32 @_mm_unpackhi_epi32(i32 %31, i32 %32)
%34 = tail call i32 @_mm_unpacklo_epi64(i32 %6, i32 %11)
store i32 %34, i32* %1
%35 = tail call i32 @_mm_unpackhi_epi64(i32 %6, i32 %11)
%36 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %35, i32* %36
%37 = tail call i32 @_mm_unpacklo_epi64(i32 %14, i32 %17)
%38 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %37, i32* %38
%39 = tail call i32 @_mm_unpackhi_epi64(i32 %14, i32 %17)
%40 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %39, i32* %40
%41 = tail call i32 @_mm_unpacklo_epi64(i32 %22, i32 %27)
%42 = getelementptr inbounds i32, i32* %1, i64 4
store i32 %41, i32* %42
%43 = tail call i32 @_mm_unpackhi_epi64(i32 %22, i32 %27)
%44 = getelementptr inbounds i32, i32* %1, i64 5
store i32 %43, i32* %44
%45 = tail call i32 @_mm_unpacklo_epi64(i32 %30, i32 %33)
%46 = getelementptr inbounds i32, i32* %1, i64 6
store i32 %45, i32* %46
%47 = tail call i32 @_mm_unpackhi_epi64(i32 %30, i32 %33)
%48 = getelementptr inbounds i32, i32* %1, i64 7
store i32 %47, i32* %48
ret void
}