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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    113f <main+0xf>
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)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1212 <main+0xe2>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f6 <main+0xc6>
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    0xe1d(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ae <main+0x7e>
lea    0xe06(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119b <main+0x6b>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <is_magic@plt>
mov    %eax,%esi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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),%r14
lea    -0x2c(%rbp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    1160 <main+0x20>
mov    %rsp,-0x40(%rbp)
mov    %rcx,%rax
imul   %rcx,%rax
mov    %rsp,%r14
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
mov    -0x2c(%rbp),%edi
test   %edi,%edi
mov    %r14,-0x38(%rbp)
jle    120e <main+0xce>
shl    $0x2,%rcx
xor    %r12d,%r12d
lea    0xe55(%rip),%r15
mov    %rcx,-0x48(%rbp)
jmp    11de <main+0x9e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r12
movslq -0x2c(%rbp),%rdi
mov    -0x48(%rbp),%rcx
add    %rcx,%r14
cmp    %rdi,%r12
jge    120e <main+0xce>
test   %edi,%edi
jle    11c0 <main+0x80>
mov    %r14,%rbx
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     11f0 <main+0xb0>
jmp    11c0 <main+0x80>
mov    -0x38(%rbp),%rsi
call   1040 <is_magic@plt>
lea    0xde2(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
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"
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
br label %8
8: ; preds = %10, %0
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %8
%11 = load i32, i32* %2
%12 = icmp sle i32 %11, 0
br i1 %12, label %8, label %13
13: ; preds = %10
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
%16 = load i32, i32* %2
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %5
%19 = mul nuw i64 %15, %17
%20 = alloca i32, i64 %19
store i64 %15, i64* %6
store i64 %17, i64* %7
store i32 0, i32* %3
br label %21
21: ; preds = %44, %13
%22 = load i32, i32* %3
%23 = load i32, i32* %2
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %47
25: ; preds = %21
store i32 0, i32* %4
br label %26
26: ; preds = %39, %25
%27 = load i32, i32* %4
%28 = load i32, i32* %2
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %42
30: ; preds = %26
%31 = load i32, i32* %3
%32 = sext i32 %31 to i64
%33 = mul nsw i64 %32, %17
%34 = getelementptr inbounds i32, i32* %20, i64 %33
%35 = load i32, i32* %4
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %37)
br label %39
39: ; preds = %30
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %26
42: ; preds = %26
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %44
44: ; preds = %42
%45 = load i32, i32* %3
%46 = add nsw i32 %45, 1
store i32 %46, i32* %3
br label %21
47: ; preds = %21
%48 = load i32, i32* %2
%49 = bitcast i32* %20 to i32**
%50 = call i32 @is_magic(i32 %48, i32** %49)
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %50)
store i32 0, i32* %1
%52 = load i8*, i8** %5
%53 = load i32, i32* %1
ret i32 %53
}

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