#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*/);
void transpose_state(__m128i *stateOut, __m128i *stateIn) {
  __m128i tmpi;
  __m128i tmpj;
  tmpi = _mm_unpacklo_epi32(stateIn[0], stateIn[1]);
  tmpj = _mm_unpacklo_epi32(stateIn[2], stateIn[3]);
  stateOut[0] = _mm_unpacklo_epi64(tmpi, tmpj);
  stateOut[1] = _mm_unpackhi_epi64(tmpi, tmpj);
  tmpi = _mm_unpackhi_epi32(stateIn[0], stateIn[1]);
  tmpj = _mm_unpackhi_epi32(stateIn[2], stateIn[3]);
  stateOut[2] = _mm_unpacklo_epi64(tmpi, tmpj);
  stateOut[3] = _mm_unpackhi_epi64(tmpi, tmpj);
}


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

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

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

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