#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 */
int /*<<< orphan*/ memcpy(void *, int *, int);
void aes_invshiftrow(void *data, uint8_t shift) {
  uint8_t tmp[4];
  tmp[0] = ((uint8_t *)data)[(4 + 0 - shift) & 3];
  tmp[1] = ((uint8_t *)data)[(4 + 1 - shift) & 3];
  tmp[2] = ((uint8_t *)data)[(4 + 2 - shift) & 3];
  tmp[3] = ((uint8_t *)data)[(4 + 3 - shift) & 3];
  memcpy(data, tmp, 4);
}


x86 assembly (clang, -O0):
<aes_invshiftrow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x4,%ecx
sub    -0xc(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x5,%ecx
sub    -0xc(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x6,%ecx
sub    -0xc(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    $0x7,%ecx
sub    -0xc(%rbp),%ecx
and    $0x3,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aes_invshiftrow>:
sub    $0x18,%rsp
mov    $0x1,%eax
sub    %esi,%eax
mov    $0x2,%ecx
sub    %esi,%ecx
mov    $0x3,%edx
sub    %esi,%edx
neg    %esi
and    $0x3,%esi
mov    (%rdi,%rsi,4),%esi
mov    %esi,(%rsp)
and    $0x3,%eax
mov    (%rdi,%rax,4),%eax
mov    %eax,0x4(%rsp)
and    $0x3,%ecx
mov    (%rdi,%rcx,4),%eax
mov    %eax,0x8(%rsp)
and    $0x3,%edx
mov    (%rdi,%rdx,4),%eax
mov    %eax,0xc(%rsp)
mov    %rsp,%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
define void @aes_invshiftrow(i8* %0, i32 %1) {
%3 = alloca [4 x i32]
%4 = bitcast [4 x i32]* %3 to i8*
%5 = bitcast i8* %0 to i32*
%6 = sub i32 0, %1
%7 = and i32 %6, 3
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %5, i64 %8
%10 = load i32, i32* %9
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
store i32 %10, i32* %11
%12 = sub i32 1, %1
%13 = and i32 %12, 3
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %5, i64 %14
%16 = load i32, i32* %15
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
store i32 %16, i32* %17
%18 = sub i32 2, %1
%19 = and i32 %18, 3
%20 = zext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %5, i64 %20
%22 = load i32, i32* %21
%23 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
store i32 %22, i32* %23
%24 = sub i32 3, %1
%25 = and i32 %24, 3
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %5, i64 %26
%28 = load i32, i32* %27
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
store i32 %28, i32* %29
%30 = call i32 @memcpy(i8* %0, i32* %11, i32 4)
ret void
}