#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*/ Rotate(int, unsigned char *);
void shift_rows(unsigned char box[4][4], int inv) {
  for (int shift = 1; shift < 4; ++shift) {
    if (inv)
      Rotate(shift, box[4 - shift]);
    else
      Rotate(shift, box[shift]);
  }
  return;
}


x86 assembly (clang, -O0):
<shift_rows>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1186 <shift_rows+0x76>
cmpl   $0x0,-0xc(%rbp)
je     115c <shift_rows+0x4c>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x4,%eax
sub    -0x10(%rbp),%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <Rotate@plt>
jmp    1173 <shift_rows+0x63>
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <Rotate@plt>
jmp    1178 <shift_rows+0x68>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <shift_rows+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shift_rows>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %eax,%eax
test   %esi,%esi
sete   %bl
setne  %al
lea    (%rdi,%rax,8),%rsi
add    $0x4,%rsi
mov    $0x1,%edi
call   1030 <Rotate@plt>
lea    0x8(%r14),%rsi
mov    $0x2,%edi
call   1030 <Rotate@plt>
lea    (%r14,%rbx,8),%rsi
add    $0x4,%rsi
mov    $0x3,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <Rotate@plt>

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

LLVM IR (-O2):
define void @shift_rows([4 x i8]* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = select i1 %3, i64 1, i64 3
%5 = select i1 %3, i64 3, i64 1
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %0, i64 %4, i64 0
%7 = tail call i32 @Rotate(i32 1, i8* %6)
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %0, i64 2, i64 0
%9 = tail call i32 @Rotate(i32 2, i8* %8)
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %0, i64 %5, i64 0
%11 = tail call i32 @Rotate(i32 3, i8* %10)
ret void
}