#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_epi16(int /*<<< orphan*/ const,
                                      int /*<<< orphan*/ const);
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*/ 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);
int /*<<< orphan*/ _mm_unpacklo_epi8(int /*<<< orphan*/ const,
                                     int /*<<< orphan*/ const);
void transpose_8bit_8x8(const __m128i *const in, __m128i *const out) {
  const __m128i a0 = _mm_unpacklo_epi8(in[0], in[1]);
  const __m128i a1 = _mm_unpacklo_epi8(in[2], in[3]);
  const __m128i a2 = _mm_unpacklo_epi8(in[4], in[5]);
  const __m128i a3 = _mm_unpacklo_epi8(in[6], in[7]);
  const __m128i b0 = _mm_unpacklo_epi16(a0, a1);
  const __m128i b1 = _mm_unpackhi_epi16(a0, a1);
  const __m128i b2 = _mm_unpacklo_epi16(a2, a3);
  const __m128i b3 = _mm_unpackhi_epi16(a2, a3);
  const __m128i c0 = _mm_unpacklo_epi32(b0, b2);
  const __m128i c1 = _mm_unpackhi_epi32(b0, b2);
  const __m128i c2 = _mm_unpacklo_epi32(b1, b3);
  const __m128i c3 = _mm_unpackhi_epi32(b1, b3);
  out[0] = _mm_unpacklo_epi64(c0, c0);
  out[1] = _mm_unpackhi_epi64(c0, c0);
  out[2] = _mm_unpacklo_epi64(c1, c1);
  out[3] = _mm_unpackhi_epi64(c1, c1);
  out[4] = _mm_unpacklo_epi64(c2, c2);
  out[5] = _mm_unpackhi_epi64(c2, c2);
  out[6] = _mm_unpacklo_epi64(c3, c3);
  out[7] = _mm_unpackhi_epi64(c3, c3);
}


x86 assembly (clang, -O0):
<transpose_8bit_8x8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
call   1030 <_mm_unpacklo_epi8@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1070 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1050 <_mm_unpackhi_epi16@plt>
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1070 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1050 <_mm_unpackhi_epi16@plt>
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1040 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x34(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1090 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1040 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1090 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x40(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1080 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1060 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x38(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1080 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x38(%rbp),%edi
mov    -0x38(%rbp),%esi
call   1060 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1080 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x3c(%rbp),%edi
mov    -0x3c(%rbp),%esi
call   1060 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x40(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1080 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x40(%rbp),%edi
mov    -0x40(%rbp),%esi
call   1060 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x1c(%rax)
add    $0x40,%rsp
pop    %rbp
ret

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

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