#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*/ printf(char *);
int /*<<< orphan*/ rotateMatrix(int, int **);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  void fillMatrix(int n, int matrix[n][n]);
  void printMatrix(int n, int matrix[n][n]);
  int n = 0;
  printf("Please enter matrix's dimension: ");
  scanf("%d", &n);
  int matrix[n][n];
  fillMatrix(n, matrix);
  printMatrix(n, matrix);
  printf("\n");
  rotateMatrix(n, matrix);
  printMatrix(n, matrix);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe93(%rip),%rdi
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rsp,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rsi
sub    %rdx,%rsi
mov    %rsi,-0x28(%rbp)
mov    %rsi,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
call   1070 <fillMatrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1050 <printMatrix@plt>
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <rotateMatrix@plt>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1050 <printMatrix@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,-0x14(%rbp)
lea    0xe87(%rip),%rdi
call   1050 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,%r14
mov    -0x14(%rbp),%eax
imul   %rax,%rax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1080 <fillMatrix@plt>
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1060 <printMatrix@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1030 <rotateMatrix@plt>
mov    -0x14(%rbp),%edi
mov    %rbx,%rsi
call   1060 <printMatrix@plt>
mov    %r14,%rsp
xor    %eax,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Please enter matrix's dimension: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %3
%13 = mul nuw i64 %9, %11
%14 = alloca i32, i64 %13
store i64 %9, i64* %4
store i64 %11, i64* %5
%15 = load i32, i32* %2
%16 = load i32, i32* %2
%17 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* %2
%19 = bitcast i32* %14 to i32**
%20 = call i32 @rotateMatrix(i32 %18, i32** %19)
%21 = load i32, i32* %2
store i32 0, i32* %1
%22 = load i8*, i8** %3
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [34 x i8] c"Please enter matrix's dimension: \00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = zext i32 %5 to i64
%7 = call i8* @llvm.stacksave()
%8 = mul nuw i64 %6, %6
%9 = alloca i32, i64 %8
%10 = load i32, i32* %1
%11 = load i32, i32* %1
%12 = call i32 @putchar(i32 10)
%13 = load i32, i32* %1
%14 = bitcast i32* %9 to i32**
%15 = call i32 @rotateMatrix(i32 %13, i32** %14)
%16 = load i32, i32* %1
ret i32 0
}