#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 inv_shift_rows(uint8_t *state) {
  uint8_t i, k, s, tmp;
  for (i = 1; i < 4; i++) {
    s = 0;
    while (s < i) {
      tmp = state[4 * i + 4 - 1];
      for (k = 4 - 1; k > 0; k--) {
        state[4 * i + k] = state[4 * i + k - 1];
      }
      state[4 * i + 0] = tmp;
      s++;
    }
  }
}


x86 assembly (clang, -O0):
<inv_shift_rows>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x4,-0xc(%rbp)
jge    11c4 <inv_shift_rows+0xc4>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b1 <inv_shift_rows+0xb1>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    $0x4,%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
movl   $0x3,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    118d <inv_shift_rows+0x8d>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    -0x10(%rbp),%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    114c <inv_shift_rows+0x4c>
mov    -0x18(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
shl    $0x2,%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1120 <inv_shift_rows+0x20>
jmp    11b6 <inv_shift_rows+0xb6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    110f <inv_shift_rows+0xf>
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @inv_shift_rows(i32* nocapture %0) {
%2 = getelementptr inbounds i32, i32* %0, i64 4
%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 3, i32 0, i32 1, i32 2>
%6 = bitcast i32* %2 to <4 x i32>*
store <4 x i32> %5, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %0, i64 8
%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 i32, i32* %0, i64 12
%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 1, i32 2, i32 3, i32 0>
%16 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> %15, <4 x i32>* %16
ret void
}