#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);
void idct8x8_12_transpose_16bit_4x8(const __m128i *const in,
                                    __m128i *const out) {
  const __m128i tr0_0 = _mm_unpackhi_epi16(in[0], in[1]);
  const __m128i tr0_1 = _mm_unpacklo_epi16(in[1], in[0]);
  const __m128i tr0_2 = _mm_unpacklo_epi16(in[2], in[3]);
  const __m128i tr0_3 = _mm_unpackhi_epi16(in[3], in[2]);
  const __m128i tr1_0 = _mm_unpacklo_epi32(tr0_0, tr0_1);
  const __m128i tr1_1 = _mm_unpacklo_epi32(tr0_2, tr0_3);
  const __m128i tr1_2 = _mm_unpackhi_epi32(tr0_0, tr0_1);
  const __m128i tr1_3 = _mm_unpackhi_epi32(tr0_2, tr0_3);
  out[0] = _mm_unpacklo_epi64(tr1_0, tr1_1);
  out[1] = _mm_unpackhi_epi64(tr1_0, tr1_1);
  out[2] = _mm_unpacklo_epi64(tr1_2, tr1_3);
  out[3] = _mm_unpackhi_epi64(tr1_2, tr1_3);
}


x86 assembly (clang, -O0):
<idct8x8_12_transpose_16bit_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   1040 <_mm_unpackhi_epi16@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
call   1060 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
call   1060 <_mm_unpacklo_epi16@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
call   1040 <_mm_unpackhi_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    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1070 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%edi
mov    -0x28(%rbp),%esi
call   1050 <_mm_unpackhi_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1070 <_mm_unpacklo_epi64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1050 <_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):
<idct8x8_12_transpose_16bit_4x8>:
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   1040 <_mm_unpackhi_epi16@plt>
mov    %eax,%r15d
mov    0x0(%rbp),%esi
mov    0x4(%rbp),%edi
call   1060 <_mm_unpacklo_epi16@plt>
mov    %eax,%ebx
mov    0x8(%rbp),%edi
mov    0xc(%rbp),%esi
call   1060 <_mm_unpacklo_epi16@plt>
mov    %eax,%r13d
mov    0x8(%rbp),%esi
mov    0xc(%rbp),%edi
call   1040 <_mm_unpackhi_epi16@plt>
mov    %eax,%ebp
mov    %r15d,%edi
mov    %ebx,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%r12d
mov    %r13d,%edi
mov    %ebp,%esi
call   1030 <_mm_unpacklo_epi32@plt>
mov    %eax,%r14d
mov    %r15d,%edi
mov    %ebx,%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %eax,%r15d
mov    %r13d,%edi
mov    %ebp,%esi
call   1080 <_mm_unpackhi_epi32@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %r14d,%esi
call   1070 <_mm_unpacklo_epi64@plt>
mov    (%rsp),%rbx
mov    %eax,(%rbx)
mov    %r12d,%edi
mov    %r14d,%esi
call   1050 <_mm_unpackhi_epi64@plt>
mov    %eax,0x4(%rbx)
mov    %r15d,%edi
mov    %ebp,%esi
call   1070 <_mm_unpacklo_epi64@plt>
mov    %eax,0x8(%rbx)
mov    %r15d,%edi
mov    %ebp,%esi
call   1050 <_mm_unpackhi_epi64@plt>
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 @idct8x8_12_transpose_16bit_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_unpackhi_epi16(i32 %15, i32 %18)
store i32 %19, i32* %5
%20 = load i32*, i32** %3
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 0
%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 2
%29 = load i32, i32* %28
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 3
%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 3
%36 = load i32, i32* %35
%37 = load i32*, i32** %3
%38 = getelementptr inbounds i32, i32* %37, i64 2
%39 = load i32, i32* %38
%40 = call i32 @_mm_unpackhi_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* %7
%45 = load i32, i32* %8
%46 = call i32 @_mm_unpacklo_epi32(i32 %44, i32 %45)
store i32 %46, i32* %10
%47 = load i32, i32* %5
%48 = load i32, i32* %6
%49 = call i32 @_mm_unpackhi_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* %10
%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* %10
%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* %11
%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* %11
%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 @idct8x8_12_transpose_16bit_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_unpackhi_epi16(i32 %3, i32 %5)
%7 = load i32, i32* %4
%8 = load i32, i32* %0
%9 = tail call i32 @_mm_unpacklo_epi16(i32 %7, i32 %8)
%10 = getelementptr inbounds i32, i32* %0, i64 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds i32, i32* %0, i64 3
%13 = load i32, i32* %12
%14 = tail call i32 @_mm_unpacklo_epi16(i32 %11, i32 %13)
%15 = load i32, i32* %12
%16 = load i32, i32* %10
%17 = tail call i32 @_mm_unpackhi_epi16(i32 %15, i32 %16)
%18 = tail call i32 @_mm_unpacklo_epi32(i32 %6, i32 %9)
%19 = tail call i32 @_mm_unpacklo_epi32(i32 %14, i32 %17)
%20 = tail call i32 @_mm_unpackhi_epi32(i32 %6, i32 %9)
%21 = tail call i32 @_mm_unpackhi_epi32(i32 %14, i32 %17)
%22 = tail call i32 @_mm_unpacklo_epi64(i32 %18, i32 %19)
store i32 %22, i32* %1
%23 = tail call i32 @_mm_unpackhi_epi64(i32 %18, i32 %19)
%24 = getelementptr inbounds i32, i32* %1, i64 1
store i32 %23, i32* %24
%25 = tail call i32 @_mm_unpacklo_epi64(i32 %20, i32 %21)
%26 = getelementptr inbounds i32, i32* %1, i64 2
store i32 %25, i32* %26
%27 = tail call i32 @_mm_unpackhi_epi64(i32 %20, i32 %21)
%28 = getelementptr inbounds i32, i32* %1, i64 3
store i32 %27, i32* %28
ret void
}