#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 */
scalar_t__ malloc(int);
int **returnRotateMatrix(int arr[3][3]) {
  int **newArr = (int **)malloc(3 * sizeof(int *));
  for (int i = 0; i < 3; i++)
    newArr[i] = (int *)malloc(3 * sizeof(int));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++)
      newArr[i][3 - j - 1] = arr[j][i];
  return newArr;
}


x86 assembly (clang, -O0):
<returnRotateMatrix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1162 <returnRotateMatrix+0x52>
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1131 <returnRotateMatrix+0x21>
movl   $0x0,-0x18(%rbp)
cmpl   $0x3,-0x18(%rbp)
jge    11d8 <returnRotateMatrix+0xc8>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3,-0x1c(%rbp)
jge    11c5 <returnRotateMatrix+0xb5>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0xc,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    $0x3,%ecx
sub    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117a <returnRotateMatrix+0x6a>
jmp    11ca <returnRotateMatrix+0xba>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1169 <returnRotateMatrix+0x59>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<returnRotateMatrix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x18,%edi
call   1030 <malloc@plt>
mov    %rax,%r14
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,(%r14)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x8(%r14)
mov    $0xc,%edi
call   1030 <malloc@plt>
mov    %rax,0x10(%r14)
mov    (%r14),%rcx
mov    (%rbx),%edx
mov    %edx,0x8(%rcx)
mov    0xc(%rbx),%edx
mov    %edx,0x4(%rcx)
mov    0x18(%rbx),%edx
mov    %edx,(%rcx)
mov    0x8(%r14),%rcx
mov    0x4(%rbx),%edx
mov    %edx,0x8(%rcx)
mov    0x10(%rbx),%edx
mov    %edx,0x4(%rcx)
mov    0x1c(%rbx),%edx
mov    %edx,(%rcx)
mov    0x8(%rbx),%ecx
mov    %ecx,0x8(%rax)
mov    0x14(%rbx),%ecx
mov    %ecx,0x4(%rax)
mov    0x20(%rbx),%ecx
mov    %ecx,(%rax)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32** @returnRotateMatrix([3 x i32]* nocapture %0) {
%2 = tail call i64 @malloc(i32 24)
%3 = inttoptr i64 %2 to i32**
%4 = tail call i64 @malloc(i32 12)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %3
%6 = tail call i64 @malloc(i32 12)
%7 = inttoptr i64 %6 to i32*
%8 = getelementptr inbounds i32*, i32** %3, i64 1
store i32* %7, i32** %8
%9 = tail call i64 @malloc(i32 12)
%10 = inttoptr i64 %9 to i32*
%11 = getelementptr inbounds i32*, i32** %3, i64 2
store i32* %10, i32** %11
%12 = load i32*, i32** %3
%13 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 0, i64 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds i32, i32* %12, i64 2
store i32 %14, i32* %15
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 1, i64 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds i32, i32* %12, i64 1
store i32 %17, i32* %18
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 2, i64 0
%20 = load i32, i32* %19
store i32 %20, i32* %12
%21 = load i32*, i32** %8
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 0, i64 1
%23 = load i32, i32* %22
%24 = getelementptr inbounds i32, i32* %21, i64 2
store i32 %23, i32* %24
%25 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 1, i64 1
%26 = load i32, i32* %25
%27 = getelementptr inbounds i32, i32* %21, i64 1
store i32 %26, i32* %27
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 2, i64 1
%29 = load i32, i32* %28
store i32 %29, i32* %21
%30 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 0, i64 2
%31 = load i32, i32* %30
%32 = getelementptr inbounds i32, i32* %10, i64 2
store i32 %31, i32* %32
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 1, i64 2
%34 = load i32, i32* %33
%35 = getelementptr inbounds i32, i32* %10, i64 1
store i32 %34, i32* %35
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %0, i64 2, i64 2
%37 = load i32, i32* %36
store i32 %37, i32* %10
ret i32** %3
}