#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 int **, unsigned int **, int);
void apply_pi(unsigned m[8][8]) {
  unsigned t[8][8];
  int i, j;
  for (i = 0; i < 8; i++)
    for (j = 0; j < 8; j++)
      t[i][j] = m[(8 + i - j) & 7][j];
  memcpy(m, t, sizeof t);
}


x86 assembly (clang, -O0):
<apply_pi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x114(%rbp)
cmpl   $0x8,-0x114(%rbp)
jge    11c3 <apply_pi+0xb3>
movl   $0x0,-0x118(%rbp)
cmpl   $0x8,-0x118(%rbp)
jge    11aa <apply_pi+0x9a>
mov    -0x8(%rbp),%rax
mov    -0x114(%rbp),%ecx
add    $0x8,%ecx
sub    -0x118(%rbp),%ecx
and    $0x7,%ecx
movslq %ecx,%rcx
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x118(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
movslq -0x114(%rbp),%rcx
lea    -0x110(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movslq -0x118(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x118(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x118(%rbp)
jmp    1140 <apply_pi+0x30>
jmp    11af <apply_pi+0x9f>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1129 <apply_pi+0x19>
mov    -0x8(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<apply_pi>:
sub    $0x108,%rsp
mov    $0x7,%eax
xor    %ecx,%ecx
xchg   %ax,%ax
mov    (%rdi,%rcx,1),%edx
mov    %edx,(%rsp,%rcx,1)
mov    %eax,%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x4(%rdi,%rdx,1),%edx
mov    %edx,0x4(%rsp,%rcx,1)
lea    -0x1(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x8(%rdi,%rdx,1),%edx
mov    %edx,0x8(%rsp,%rcx,1)
lea    -0x2(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0xc(%rdi,%rdx,1),%edx
mov    %edx,0xc(%rsp,%rcx,1)
lea    -0x3(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x10(%rdi,%rdx,1),%edx
mov    %edx,0x10(%rsp,%rcx,1)
lea    -0x4(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x14(%rdi,%rdx,1),%edx
mov    %edx,0x14(%rsp,%rcx,1)
lea    -0x5(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x18(%rdi,%rdx,1),%edx
mov    %edx,0x18(%rsp,%rcx,1)
lea    -0x6(%rax),%edx
and    $0x7,%edx
shl    $0x5,%rdx
mov    0x1c(%rdi,%rdx,1),%edx
mov    %edx,0x1c(%rsp,%rcx,1)
add    $0x1,%rax
add    $0x20,%rcx
cmp    $0xf,%rax
jne    1120 <apply_pi+0x10>
mov    %rsp,%rsi
mov    $0x100,%edx
call   1030 <memcpy@plt>
add    $0x108,%rsp
ret

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

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