#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 uint8_t;

/* Variables and functions */
void ShiftRow(uint8_t state[4][4]) {
  uint8_t i, j;
  uint8_t tmp[4];
  for (i = 1; i < 4; i++) {
    for (j = 0; j < 4; j++) {
      tmp[j] = state[i][j];
    }
    for (j = 0; j < 4; j++) {
      state[i][j] = tmp[(j + i) & 3];
    }
  }
}


x86 assembly (clang, -O0):
<ShiftRow>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11ad <ShiftRow+0xad>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1156 <ShiftRow+0x56>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x10(%rbp),%rax
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1120 <ShiftRow+0x20>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    119a <ShiftRow+0x9a>
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
and    $0x3,%eax
cltq
mov    -0x20(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <ShiftRow+0x5d>
jmp    119f <ShiftRow+0x9f>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <ShiftRow+0xf>
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShiftRow>:
movdqu 0x10(%rdi),%xmm0
movdqu 0x20(%rdi),%xmm1
movdqu 0x30(%rdi),%xmm2
pshufd $0x39,%xmm0,%xmm0
movdqu %xmm0,0x10(%rdi)
pshufd $0x4e,%xmm1,%xmm0
movdqu %xmm0,0x20(%rdi)
pshufd $0x93,%xmm2,%xmm0
movdqu %xmm0,0x30(%rdi)
ret

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

LLVM IR (-O2):
define void @ShiftRow([4 x i32]* nocapture %0) {
%2 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 1, i64 0
%3 = bitcast i32* %2 to <4 x i32>*
%4 = load <4 x i32>, <4 x i32>* %3
%5 = shufflevector <4 x i32> %4, <4 x i32> poison, <4 x i32> <i32 1, i32 2, i32 3, i32 0>
%6 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %6
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 2, i64 0
%8 = bitcast i32* %7 to <4 x i32>*
%9 = load <4 x i32>, <4 x i32>* %8
%10 = shufflevector <4 x i32> %9, <4 x i32> poison, <4 x i32> <i32 2, i32 3, i32 0, i32 1>
%11 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> %10, <4 x i32>* %11
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %0, i64 3, i64 0
%13 = bitcast i32* %12 to <4 x i32>*
%14 = load <4 x i32>, <4 x i32>* %13
%15 = shufflevector <4 x i32> %14, <4 x i32> poison, <4 x i32> <i32 3, i32 0, i32 1, i32 2>
%16 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %16
ret void
}