#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*/ scanf(char *, int *);
int /*<<< orphan*/ transposer(int *, int);
int main() {
  int n, i = 0, j = 0;
  scanf("%d", &n);
  int transpose[n][n];
  for (; i < n; i++) {
    for (j = 0; j < n; j++)
      scanf("%d", &transpose[i][j]);
    printf("\n");
  }
  transposer(&transpose[0][0], n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf(" %d ", transpose[i][j]);
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeac(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    120f <main+0xdf>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f3 <main+0xc3>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
movslq -0xc(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe20(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ab <main+0x7b>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1198 <main+0x68>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rax
imul   $0x0,%rax,%rax
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x8(%rbp),%esi
call   1040 <transposer@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a6 <main+0x176>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    128a <main+0x15a>
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rdx
movslq -0xc(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1244 <main+0x114>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1231 <main+0x101>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%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   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xea8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%ecx
mov    %rcx,%rax
imul   %rcx,%rax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%esi
test   %esi,%esi
mov    %rcx,-0x38(%rbp)
jle    11fe <main+0xbe>
lea    0x0(,%rcx,4),%rax
mov    %rax,-0x48(%rbp)
xor    %eax,%eax
lea    0xe5c(%rip),%r14
mov    %r15,%r12
jmp    11cf <main+0x8f>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
movslq -0x2c(%rbp),%rsi
add    -0x48(%rbp),%r12
cmp    %rsi,%rax
jge    11fe <main+0xbe>
mov    %rax,-0x50(%rbp)
test   %esi,%esi
jle    11b0 <main+0x70>
mov    %r12,%rbx
xor    %r13d,%r13d
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11e0 <main+0xa0>
jmp    11b0 <main+0x70>
mov    %r15,%rdi
call   1050 <transposer@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
mov    -0x38(%rbp),%r13
jle    126d <main+0x12d>
shl    $0x2,%r13
lea    0xde7(%rip),%r14
xor    %r12d,%r12d
jmp    124a <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rax
add    %r13,%r15
cmp    %rax,%r12
jge    126d <main+0x12d>
test   %eax,%eax
jle    1230 <main+0xf0>
xor    %ebx,%ebx
mov    (%r15,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     1250 <main+0x110>
jmp    1230 <main+0xf0>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c" %d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = zext i32 %9 to i64
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %5
%14 = mul nuw i64 %10, %12
%15 = alloca i32, i64 %14
store i64 %10, i64* %6
store i64 %12, i64* %7
br label %16
16: ; preds = %39, %0
%17 = load i32, i32* %3
%18 = load i32, i32* %2
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %42
20: ; preds = %16
store i32 0, i32* %4
br label %21
21: ; preds = %34, %20
%22 = load i32, i32* %4
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = mul nsw i64 %27, %12
%29 = getelementptr inbounds i32, i32* %15, i64 %28
%30 = load i32, i32* %4
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
%33 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %32)
br label %34
34: ; preds = %25
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %21
37: ; preds = %21
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %16
42: ; preds = %16
%43 = mul nsw i64 0, %12
%44 = getelementptr inbounds i32, i32* %15, i64 %43
%45 = getelementptr inbounds i32, i32* %44, i64 0
%46 = load i32, i32* %2
%47 = call i32 @transposer(i32* %45, i32 %46)
store i32 0, i32* %3
br label %48
48: ; preds = %72, %42
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = icmp slt i32 %49, %50
br i1 %51, label %52, label %75
52: ; preds = %48
store i32 0, i32* %4
br label %53
53: ; preds = %67, %52
%54 = load i32, i32* %4
%55 = load i32, i32* %2
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %70
57: ; preds = %53
%58 = load i32, i32* %3
%59 = sext i32 %58 to i64
%60 = mul nsw i64 %59, %12
%61 = getelementptr inbounds i32, i32* %15, i64 %60
%62 = load i32, i32* %4
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds i32, i32* %61, i64 %63
%65 = load i32, i32* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %65)
br label %67
67: ; preds = %57
%68 = load i32, i32* %4
%69 = add nsw i32 %68, 1
store i32 %69, i32* %4
br label %53
70: ; preds = %53
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %72
72: ; preds = %70
%73 = load i32, i32* %3
%74 = add nsw i32 %73, 1
store i32 %74, i32* %3
br label %48
75: ; preds = %48
store i32 0, i32* %1
%76 = load i8*, i8** %5
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c" %d \00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = zext i32 %4 to i64
%6 = call i8* @llvm.stacksave()
%7 = mul nuw i64 %5, %5
%8 = alloca i32, i64 %7
%9 = load i32, i32* %1
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %32
11: ; preds = %0, %26
%12 = phi i32 [ %29, %26 ], [ %9, %0 ]
%13 = phi i64 [ %28, %26 ], [ 0, %0 ]
%14 = icmp sgt i32 %12, 0
br i1 %14, label %15, label %26
15: ; preds = %11
%16 = mul nuw nsw i64 %13, %5
%17 = getelementptr inbounds i32, i32* %8, i64 %16
br label %18
18: ; preds = %15, %18
%19 = phi i64 [ 0, %15 ], [ %22, %18 ]
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %26
26: ; preds = %18, %11
%27 = call i32 @putchar(i32 10)
%28 = add nuw nsw i64 %13, 1
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %28, %30
br i1 %31, label %11, label %32
32: ; preds = %26, %0
%33 = phi i32 [ %9, %0 ], [ %29, %26 ]
%34 = call i32 @transposer(i32* %8, i32 %33)
%35 = load i32, i32* %1
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %59
37: ; preds = %32, %53
%38 = phi i32 [ %56, %53 ], [ %35, %32 ]
%39 = phi i64 [ %55, %53 ], [ 0, %32 ]
%40 = icmp sgt i32 %38, 0
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = mul nuw nsw i64 %39, %5
%43 = getelementptr inbounds i32, i32* %8, i64 %42
br label %44
44: ; preds = %41, %44
%45 = phi i64 [ 0, %41 ], [ %49, %44 ]
%46 = getelementptr inbounds i32, i32* %43, i64 %45
%47 = load i32, i32* %46
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%49 = add nuw nsw i64 %45, 1
%50 = load i32, i32* %1
%51 = sext i32 %50 to i64
%52 = icmp slt i64 %49, %51
br i1 %52, label %44, label %53
53: ; preds = %44, %37
%54 = call i32 @putchar(i32 10)
%55 = add nuw nsw i64 %39, 1
%56 = load i32, i32* %1
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %55, %57
br i1 %58, label %37, label %59
59: ; preds = %53, %32
ret i32 0
}