#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 **array2d(int);
int /*<<< orphan*/ display(int **, int);
int /*<<< orphan*/ free(int **);
int /*<<< orphan*/ rotate(int **, int);
int main(int argc, char **argv) {
  int dimension = 5;
  int **array = array2d(dimension);
  for (int i = 0; i < dimension; i++) {
    for (int j = 0; j < dimension; j++) {
      array[i][j] = i * dimension + j;
    }
  }
  display(array, dimension);
  rotate(array, dimension);
  display(array, dimension);
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x5,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <array2d@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11cd <main+0x8d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ba <main+0x7a>
mov    -0x24(%rbp),%edx
imul   -0x14(%rbp),%edx
add    -0x28(%rbp),%edx
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x28(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1183 <main+0x43>
jmp    11bf <main+0x7f>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1170 <main+0x30>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <display@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <rotate@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <display@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x5,%edi
call   1050 <array2d@plt>
mov    %rax,%rbx
mov    (%rax),%rax
movaps 0xea8(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x4,0x10(%rax)
mov    0x8(%rbx),%rax
movaps 0xea3(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x9,0x10(%rax)
mov    0x10(%rbx),%rax
movaps 0xe9e(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0xe,0x10(%rax)
mov    0x18(%rbx),%rax
movaps 0xe99(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x13,0x10(%rax)
mov    0x20(%rbx),%rax
movaps 0xe94(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x18,0x10(%rax)
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <display@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1060 <rotate@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <display@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32** @array2d(i32 5)
%4 = load i32*, i32** %3
%5 = bitcast i32* %4 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = getelementptr inbounds i32, i32* %4, i64 4
store i32 4, i32* %6
%7 = getelementptr inbounds i32*, i32** %3, i64 1
%8 = load i32*, i32** %7
%9 = bitcast i32* %8 to <4 x i32>*
store <4 x i32> <i32 5, i32 6, i32 7, i32 8>, <4 x i32>* %9
%10 = getelementptr inbounds i32, i32* %8, i64 4
store i32 9, i32* %10
%11 = getelementptr inbounds i32*, i32** %3, i64 2
%12 = load i32*, i32** %11
%13 = bitcast i32* %12 to <4 x i32>*
store <4 x i32> <i32 10, i32 11, i32 12, i32 13>, <4 x i32>* %13
%14 = getelementptr inbounds i32, i32* %12, i64 4
store i32 14, i32* %14
%15 = getelementptr inbounds i32*, i32** %3, i64 3
%16 = load i32*, i32** %15
%17 = bitcast i32* %16 to <4 x i32>*
store <4 x i32> <i32 15, i32 16, i32 17, i32 18>, <4 x i32>* %17
%18 = getelementptr inbounds i32, i32* %16, i64 4
store i32 19, i32* %18
%19 = getelementptr inbounds i32*, i32** %3, i64 4
%20 = load i32*, i32** %19
%21 = bitcast i32* %20 to <4 x i32>*
store <4 x i32> <i32 20, i32 21, i32 22, i32 23>, <4 x i32>* %21
%22 = getelementptr inbounds i32, i32* %20, i64 4
store i32 24, i32* %22
%23 = tail call i32 @display(i32** %3, i32 5)
%24 = tail call i32 @rotate(i32** %3, i32 5)
%25 = tail call i32 @display(i32** %3, i32 5)
%26 = tail call i32 @free(i32** %3)
ret i32 0
}