#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*/ transpose_16bit_8x8(int /*<<< orphan*/ *const,
                                       int /*<<< orphan*/ *const);
void transpose_16bit_16x16(__m128i *const left, __m128i *const right) {
  __m128i tbuf[8];
  transpose_16bit_8x8(left, left);
  transpose_16bit_8x8(right, tbuf);
  transpose_16bit_8x8(left + 8, right);
  transpose_16bit_8x8(right + 8, right + 8);
  left[8] = tbuf[0];
  left[9] = tbuf[1];
  left[10] = tbuf[2];
  left[11] = tbuf[3];
  left[12] = tbuf[4];
  left[13] = tbuf[5];
  left[14] = tbuf[6];
  left[15] = tbuf[7];
}


x86 assembly (clang, -O0):
<transpose_16bit_16x16>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <transpose_16bit_8x8@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <transpose_16bit_8x8@plt>
mov    -0x8(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
call   1030 <transpose_16bit_8x8@plt>
mov    -0x10(%rbp),%rdi
add    $0x20,%rdi
mov    -0x10(%rbp),%rsi
add    $0x20,%rsi
call   1030 <transpose_16bit_8x8@plt>
mov    -0x30(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x2c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x20(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x38(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x3c(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transpose_16bit_16x16>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdi,%rsi
call   1030 <transpose_16bit_8x8@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1030 <transpose_16bit_8x8@plt>
lea    0x20(%r14),%rdi
mov    %rbx,%rsi
call   1030 <transpose_16bit_8x8@plt>
add    $0x20,%rbx
mov    %rbx,%rdi
mov    %rbx,%rsi
call   1030 <transpose_16bit_8x8@plt>
movaps (%rsp),%xmm0
movups %xmm0,0x20(%r14)
movaps 0x10(%rsp),%xmm0
movups %xmm0,0x30(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define void @transpose_16bit_16x16(i32* %0, i32* %1) {
%3 = alloca [8 x i32]
%4 = bitcast [8 x i32]* %3 to i8*
%5 = tail call i32 @transpose_16bit_8x8(i32* %0, i32* %0)
%6 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%7 = call i32 @transpose_16bit_8x8(i32* %1, i32* %6)
%8 = getelementptr inbounds i32, i32* %0, i64 8
%9 = call i32 @transpose_16bit_8x8(i32* %8, i32* %1)
%10 = getelementptr inbounds i32, i32* %1, i64 8
%11 = call i32 @transpose_16bit_8x8(i32* %10, i32* %10)
%12 = bitcast [8 x i32]* %3 to <4 x i32>*
%13 = load <4 x i32>, <4 x i32>* %12
%14 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> %13, <4 x i32>* %14
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%16 = getelementptr inbounds i32, i32* %0, i64 12
%17 = bitcast i32* %15 to <4 x i32>*
%18 = load <4 x i32>, <4 x i32>* %17
%19 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> %18, <4 x i32>* %19
ret void
}