#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*/ print_image(size_t, unsigned int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rotate_image(size_t, unsigned int **);
int scanf(char *, ...);
int main(void) {
  printf("Enter N, followed by the NxN values\n");
  size_t dim;
  while (scanf("%zu", &dim) == 1) {
    unsigned image[dim][dim];
    size_t i, j;
    for (i = 0; i < dim; i++) {
      for (j = 0; j < dim; j++) {
        scanf("%u", &image[i][j]);
      }
    }
    printf("Before rotation:\n");
    print_image(dim, image);
    printf("After rotation:\n");
    rotate_image(dim, image);
    print_image(dim, image);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    127b <main+0x13b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    %rax,%rcx
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rax,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x40(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1230 <main+0xf0>
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    121a <main+0xda>
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rax
imul   -0x30(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
mov    -0x38(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11ce <main+0x8e>
jmp    121f <main+0xdf>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11b8 <main+0x78>
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1030 <print_image@plt>
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1050 <rotate_image@plt>
mov    -0x40(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1030 <print_image@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
jmp    115b <main+0x1b>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
lea    0xe9c(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1270 <main+0x130>
lea    0xe85(%rip),%rbx
jmp    11ef <main+0xaf>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%r14
mov    %r14,%rsi
call   1030 <print_image@plt>
lea    0xe89(%rip),%rdi
call   1040 <puts@plt>
mov    -0x30(%rbp),%rdi
mov    %r14,%rsi
call   1050 <rotate_image@plt>
mov    -0x30(%rbp),%rdi
mov    %r14,%rsi
call   1030 <print_image@plt>
mov    -0x48(%rbp),%rsp
lea    0xe25(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmp    $0x1,%eax
jne    1270 <main+0x130>
mov    %rsp,-0x48(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
imul   %rax,%rax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
cmpq   $0x0,-0x30(%rbp)
je     1190 <main+0x50>
shlq   $0x2,-0x40(%rbp)
mov    -0x38(%rbp),%r14
xor    %r12d,%r12d
nop
mov    %r14,%r15
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
add    $0x1,%r13
mov    -0x30(%rbp),%rax
add    $0x4,%r15
cmp    %rax,%r13
jb     1240 <main+0x100>
add    $0x1,%r12
add    -0x40(%rbp),%r14
cmp    %rax,%r12
jb     1230 <main+0xf0>
jmp    1190 <main+0x50>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter N, followed by the NxN values\0A\00"
@.str.1 = [4 x i8] c"%zu\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [18 x i8] c"Before rotation:\0A\00"
@.str.4 = [17 x i8] c"After rotation:\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %41, %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %2)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %54
12: ; preds = %9
%13 = load i64, i64* %2
%14 = load i64, i64* %2
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %3
%16 = mul nuw i64 %13, %14
%17 = alloca i32, i64 %16
store i64 %13, i64* %4
store i64 %14, i64* %5
store i64 0, i64* %6
br label %18
18: ; preds = %38, %12
%19 = load i64, i64* %6
%20 = load i64, i64* %2
%21 = icmp ult i64 %19, %20
br i1 %21, label %22, label %41
22: ; preds = %18
store i64 0, i64* %7
br label %23
23: ; preds = %34, %22
%24 = load i64, i64* %7
%25 = load i64, i64* %2
%26 = icmp ult i64 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load i64, i64* %6
%29 = mul nsw i64 %28, %14
%30 = getelementptr inbounds i32, i32* %17, i64 %29
%31 = load i64, i64* %7
%32 = getelementptr inbounds i32, i32* %30, i64 %31
%33 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %32)
br label %34
34: ; preds = %27
%35 = load i64, i64* %7
%36 = add i64 %35, 1
store i64 %36, i64* %7
br label %23
37: ; preds = %23
br label %38
38: ; preds = %37
%39 = load i64, i64* %6
%40 = add i64 %39, 1
store i64 %40, i64* %6
br label %18
41: ; preds = %18
%42 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%43 = load i64, i64* %2
%44 = bitcast i32* %17 to i32**
%45 = call i32 @print_image(i64 %43, i32** %44)
%46 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
%47 = load i64, i64* %2
%48 = bitcast i32* %17 to i32**
%49 = call i32 @rotate_image(i64 %47, i32** %48)
%50 = load i64, i64* %2
%51 = bitcast i32* %17 to i32**
%52 = call i32 @print_image(i64 %50, i32** %51)
%53 = load i8*, i8** %3
br label %9
54: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%zu\00"
@.str.2 = [3 x i8] c"%u\00"
@str = [36 x i8] c"Enter N, followed by the NxN values\00"
@str.5 = [17 x i8] c"Before rotation:\00"
@str.6 = [16 x i8] c"After rotation:\00"
define i32 @main() {
%1 = alloca i64
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%3 = bitcast i64* %1 to i8*
%4 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %39
6: ; preds = %0, %27
%7 = load i64, i64* %1
%8 = call i8* @llvm.stacksave()
%9 = mul nuw i64 %7, %7
%10 = alloca i32, i64 %9
%11 = load i64, i64* %1
%12 = icmp eq i64 %11, 0
br i1 %12, label %27, label %13
13: ; preds = %6, %24
%14 = phi i64 [ %25, %24 ], [ 0, %6 ]
%15 = mul nsw i64 %14, %7
%16 = getelementptr inbounds i32, i32* %10, i64 %15
br label %17
17: ; preds = %13, %17
%18 = phi i64 [ 0, %13 ], [ %21, %17 ]
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%21 = add nuw i64 %18, 1
%22 = load i64, i64* %1
%23 = icmp ult i64 %21, %22
br i1 %23, label %17, label %24
24: ; preds = %17
%25 = add nuw i64 %14, 1
%26 = icmp ult i64 %25, %22
br i1 %26, label %13, label %27
27: ; preds = %24, %6
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%29 = load i64, i64* %1
%30 = bitcast i32* %10 to i32**
%31 = call i32 @print_image(i64 %29, i32** %30)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.6, i64 0, i64 0))
%33 = load i64, i64* %1
%34 = call i32 @rotate_image(i64 %33, i32** %30)
%35 = load i64, i64* %1
%36 = call i32 @print_image(i64 %35, i32** %30)
%37 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%38 = icmp eq i32 %37, 1
br i1 %38, label %6, label %39
39: ; preds = %27, %0
ret i32 0
}