#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*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpackhi_epi64(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpacklo_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ _mm_unpacklo_epi64(int /*<<< orphan*/, int /*<<< orphan*/);
__attribute__((always_)) void transpose_vecs(__m128i vecs[4]) {
  __m128i ab_01 = _mm_unpacklo_epi32(vecs[0], vecs[1]);
  __m128i ab_23 = _mm_unpackhi_epi32(vecs[0], vecs[1]);
  __m128i cd_01 = _mm_unpacklo_epi32(vecs[2], vecs[3]);
  __m128i cd_23 = _mm_unpackhi_epi32(vecs[2], vecs[3]);
  __m128i abcd_0 = _mm_unpacklo_epi64(ab_01, cd_01);
  __m128i abcd_1 = _mm_unpackhi_epi64(ab_01, cd_01);
  __m128i abcd_2 = _mm_unpacklo_epi64(ab_23, cd_23);
  __m128i abcd_3 = _mm_unpackhi_epi64(ab_23, cd_23);
  vecs[0] = abcd_0;
  vecs[1] = abcd_1;
  vecs[2] = abcd_2;
  vecs[3] = abcd_3;
}


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

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

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

LLVM IR (-O2):
define void @transpose_vecs(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = getelementptr inbounds i32, i32* %0, i64 1
%4 = load i32, i32* %3
%5 = tail call i32 @_mm_unpacklo_epi32(i32 %2, i32 %4)
%6 = load i32, i32* %0
%7 = load i32, i32* %3
%8 = tail call i32 @_mm_unpackhi_epi32(i32 %6, i32 %7)
%9 = getelementptr inbounds i32, i32* %0, i64 2
%10 = load i32, i32* %9
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = load i32, i32* %11
%13 = tail call i32 @_mm_unpacklo_epi32(i32 %10, i32 %12)
%14 = load i32, i32* %9
%15 = load i32, i32* %11
%16 = tail call i32 @_mm_unpackhi_epi32(i32 %14, i32 %15)
%17 = tail call i32 @_mm_unpacklo_epi64(i32 %5, i32 %13)
%18 = tail call i32 @_mm_unpackhi_epi64(i32 %5, i32 %13)
%19 = tail call i32 @_mm_unpacklo_epi64(i32 %8, i32 %16)
%20 = tail call i32 @_mm_unpackhi_epi64(i32 %8, i32 %16)
store i32 %17, i32* %0
store i32 %18, i32* %3
store i32 %19, i32* %9
store i32 %20, i32* %11
ret void
}