#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_SHUFFLE(int, int, int, int);
int /*<<< orphan*/ _mm_shuffle_epi32(int /*<<< orphan*/, int /*<<< orphan*/);
__attribute__((always_)) void diagonalize(__m128i *row0, __m128i *row2,
                                          __m128i *row3) {
  *row0 = _mm_shuffle_epi32(*row0, _MM_SHUFFLE(2, 1, 0, 3));
  *row3 = _mm_shuffle_epi32(*row3, _MM_SHUFFLE(1, 0, 3, 2));
  *row2 = _mm_shuffle_epi32(*row2, _MM_SHUFFLE(0, 3, 2, 1));
}


x86 assembly (clang, -O0):
<diagonalize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    $0x2,%edi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x3,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    -0x24(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x2,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
xor    %edi,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diagonalize>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%ebp
mov    $0x2,%edi
mov    $0x1,%esi
xor    %edx,%edx
mov    $0x3,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,(%rbx)
mov    (%r15),%ebx
mov    $0x1,%edi
xor    %esi,%esi
mov    $0x3,%edx
mov    $0x2,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,(%r15)
mov    (%r14),%ebx
xor    %edi,%edi
mov    $0x3,%esi
mov    $0x2,%edx
mov    $0x1,%ecx
call   1030 <_MM_SHUFFLE@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <_mm_shuffle_epi32@plt>
mov    %eax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @diagonalize(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = call i32 @_MM_SHUFFLE(i32 2, i32 1, i32 0, i32 3)
%10 = call i32 @_mm_shuffle_epi32(i32 %8, i32 %9)
%11 = load i32*, i32** %4
store i32 %10, i32* %11
%12 = load i32*, i32** %6
%13 = load i32, i32* %12
%14 = call i32 @_MM_SHUFFLE(i32 1, i32 0, i32 3, i32 2)
%15 = call i32 @_mm_shuffle_epi32(i32 %13, i32 %14)
%16 = load i32*, i32** %6
store i32 %15, i32* %16
%17 = load i32*, i32** %5
%18 = load i32, i32* %17
%19 = call i32 @_MM_SHUFFLE(i32 0, i32 3, i32 2, i32 1)
%20 = call i32 @_mm_shuffle_epi32(i32 %18, i32 %19)
%21 = load i32*, i32** %5
store i32 %20, i32* %21
ret void
}

LLVM IR (-O2):
define void @diagonalize(i32* nocapture %0, i32* nocapture %1, i32* nocapture %2) {
%4 = load i32, i32* %0
%5 = tail call i32 @_MM_SHUFFLE(i32 2, i32 1, i32 0, i32 3)
%6 = tail call i32 @_mm_shuffle_epi32(i32 %4, i32 %5)
store i32 %6, i32* %0
%7 = load i32, i32* %2
%8 = tail call i32 @_MM_SHUFFLE(i32 1, i32 0, i32 3, i32 2)
%9 = tail call i32 @_mm_shuffle_epi32(i32 %7, i32 %8)
store i32 %9, i32* %2
%10 = load i32, i32* %1
%11 = tail call i32 @_MM_SHUFFLE(i32 0, i32 3, i32 2, i32 1)
%12 = tail call i32 @_mm_shuffle_epi32(i32 %10, i32 %11)
store i32 %12, i32* %1
ret void
}