#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 */

/* Variables and functions */
int /*<<< orphan*/ memcpy(unsigned char **, unsigned char **, int);
void ShiftRows(unsigned char state[4][4]) {
  int i, j;
  unsigned char tmp[4][4];
  for (i = 0; i < 4; i++) {
    for (j = 0; j < 4; j++)
      tmp[i][j] = state[i][(j + i) % 4];
  }
  memcpy(state, tmp, 4 * 4);
}


x86 assembly (clang, -O0):
<ShiftRows>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11a0 <ShiftRows+0x90>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    118d <ShiftRows+0x7d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    -0x28(%rbp),%rax
movslq %edx,%rcx
mov    (%rax,%rcx,1),%dl
movslq -0xc(%rbp),%rcx
lea    -0x20(%rbp),%rax
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1134 <ShiftRows+0x24>
jmp    1192 <ShiftRows+0x82>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <ShiftRows+0x13>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ShiftRows>:
sub    $0x18,%rsp
movdqu (%rdi),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufhw $0x39,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0xe1,%xmm0,%xmm0
pshufhw $0x93,%xmm0,%xmm0
packuswb %xmm0,%xmm2
movdqa %xmm2,(%rsp)
mov    %rsp,%rsi
mov    $0x10,%edx
call   1030 <memcpy@plt>
add    $0x18,%rsp
ret

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

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