#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*/ assert(int);
scalar_t__ memcmp(int *, int *, int);
int /*<<< orphan*/ rotate(int **, int);
int main() {
  int matrix[5][5] = {{1, 2, 3, 4, 5},
                      {1, 2, 3, 4, 5},
                      {1, 2, 3, 4, 5},
                      {1, 2, 3, 4, 5},
                      {1, 2, 3, 4, 5}};
  int expected[5][5] = {{5, 5, 5, 5, 5},
                        {4, 4, 4, 4, 4},
                        {3, 3, 3, 3, 3},
                        {2, 2, 2, 2, 2},
                        {1, 1, 1, 1, 1}};
  rotate(matrix, 5);
  for (int i = 0; i < 5; i++) {
    assert(memcmp(matrix[i], expected[i], 5) == 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xefb(%rip),%rsi
mov    $0x64,%edx
call   1050 <memcpy@plt>
lea    -0x70(%rbp),%rdi
mov    $0x5,%esi
call   1060 <rotate@plt>
movl   $0x0,-0xe4(%rbp)
cmpl   $0x5,-0xe4(%rbp)
jge    11fa <main+0xba>
movslq -0xe4(%rbp),%rax
lea    -0x70(%rbp),%rdi
imul   $0x14,%rax,%rax
add    %rax,%rdi
movslq -0xe4(%rbp),%rax
lea    -0xe0(%rbp),%rsi
imul   $0x14,%rax,%rax
add    %rax,%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1197 <main+0x57>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xe0,%rsp
mov    0xf1e(%rip),%eax
mov    %eax,0xd0(%rsp)
movaps 0xf00(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
lea    0xc0(%rsp),%r14
mov    0xf22(%rip),%eax
mov    %eax,0x60(%rsp)
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x50(%rsp),%r15
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <rotate@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0x5,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0x84(%rsp),%rdi
lea    0x14(%rsp),%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0x98(%rsp),%rdi
lea    0x28(%rsp),%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
lea    0xac(%rsp),%rdi
lea    0x3c(%rsp),%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x5,%edx
call   1030 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0xe0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.matrix = [5 x [5 x i32]] [[5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]]
@__const.main.expected = [5 x [5 x i32]] [[5 x i32] [i32 5, i32 5, i32 5, i32 5, i32 5], [5 x i32] [i32 4, i32 4, i32 4, i32 4, i32 4], [5 x i32] [i32 3, i32 3, i32 3, i32 3, i32 3], [5 x i32] [i32 2, i32 2, i32 2, i32 2, i32 2], [5 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1]]
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x [5 x i32]]
%3 = alloca [5 x [5 x i32]]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [5 x [5 x i32]]* %2 to i8*
%6 = bitcast [5 x [5 x i32]]* %3 to i8*
%7 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 0
%8 = bitcast [5 x i32]* %7 to i32**
%9 = call i32 @rotate(i32** %8, i32 5)
store i32 0, i32* %4
br label %10
10: ; preds = %26, %0
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 5
br i1 %12, label %13, label %29
13: ; preds = %10
%14 = load i32, i32* %4
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 %15
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %16, i64 0, i64 0
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %3, i64 0, i64 %19
%21 = getelementptr inbounds [5 x i32], [5 x i32]* %20, i64 0, i64 0
%22 = call i64 @memcmp(i32* %17, i32* %21, i32 5)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
br label %26
26: ; preds = %13
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %10
29: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@__const.main.matrix = [5 x [5 x i32]] [[5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5], [5 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5]]
@__const.main.expected = [5 x [5 x i32]] [[5 x i32] [i32 5, i32 5, i32 5, i32 5, i32 5], [5 x i32] [i32 4, i32 4, i32 4, i32 4, i32 4], [5 x i32] [i32 3, i32 3, i32 3, i32 3, i32 3], [5 x i32] [i32 2, i32 2, i32 2, i32 2, i32 2], [5 x i32] [i32 1, i32 1, i32 1, i32 1, i32 1]]
define i32 @main() {
%1 = alloca [5 x [5 x i32]]
%2 = alloca [5 x [5 x i32]]
%3 = bitcast [5 x [5 x i32]]* %1 to i8*
%4 = bitcast [5 x [5 x i32]]* %2 to i8*
%5 = bitcast [5 x [5 x i32]]* %1 to i32**
%6 = call i32 @rotate(i32** %5, i32 5)
%7 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 0, i64 0
%8 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 0, i64 0
%9 = call i64 @memcmp(i32* %7, i32* %8, i32 5)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
%12 = call i32 @assert(i32 %11)
%13 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 1, i64 0
%14 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 1, i64 0
%15 = call i64 @memcmp(i32* %13, i32* %14, i32 5)
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 2, i64 0
%20 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 2, i64 0
%21 = call i64 @memcmp(i32* %19, i32* %20, i32 5)
%22 = icmp eq i64 %21, 0
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 3, i64 0
%26 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 3, i64 0
%27 = call i64 @memcmp(i32* %25, i32* %26, i32 5)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %1, i64 0, i64 4, i64 0
%32 = getelementptr inbounds [5 x [5 x i32]], [5 x [5 x i32]]* %2, i64 0, i64 4, i64 0
%33 = call i64 @memcmp(i32* %31, i32* %32, i32 5)
%34 = icmp eq i64 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
ret i32 0
}