#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 isMagic(int, int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int size, i, j, num;
  scanf("%d", &size);
  int square[size][size];
  for (i = 0; i < size; i++) {
    for (j = 0; j < size; j++) {
      scanf("%d", &num);
      square[i][j] = num;
    }
  }
  int isMagicS = isMagic(size, square);
  if (isMagicS) {
    printf("Magic");
  } else {
    printf("No Magic");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%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,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1202 <main+0xd2>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11ef <main+0xbf>
lea    0xe49(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rax
mov    -0x14(%rbp),%edx
movslq -0xc(%rbp),%rcx
imul   %rsi,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a4 <main+0x74>
jmp    11f4 <main+0xc4>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1191 <main+0x61>
mov    -0x40(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1040 <isMagic@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     122c <main+0xfc>
lea    0xde4(%rip),%rdi
call   1030 <printf@plt>
jmp    1238 <main+0x108>
lea    0xdd0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x20(%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    0xeb8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%ecx
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    11e5 <main+0xb5>
shl    $0x2,%rcx
xor    %r12d,%r12d
lea    0xe73(%rip),%r15
lea    -0x30(%rbp),%rbx
mov    %rcx,-0x48(%rbp)
jmp    11af <main+0x7f>
nopw   0x0(%rax,%rax,1)
movslq %edi,%rax
add    $0x1,%r12
add    %rcx,%r14
cmp    %rax,%r12
jge    11e5 <main+0xb5>
test   %edi,%edi
jle    11a0 <main+0x70>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,(%r14,%r13,4)
add    $0x1,%r13
movslq -0x2c(%rbp),%rdi
cmp    %rdi,%r13
jl     11c0 <main+0x90>
mov    -0x48(%rbp),%rcx
jmp    11a0 <main+0x70>
mov    -0x38(%rbp),%rsi
call   1040 <isMagic@plt>
test   %eax,%eax
lea    0xe0c(%rip),%rax
lea    0xe08(%rip),%rdi
cmove  %rax,%rdi
call   1030 <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 = [6 x i8] c"Magic\00"
@.str.2 = [9 x i8] c"No Magic\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = load i32, i32* %2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %6
%16 = mul nuw i64 %12, %14
%17 = alloca i32, i64 %16
store i64 %12, i64* %7
store i64 %14, i64* %8
store i32 0, i32* %3
br label %18
18: ; preds = %41, %0
%19 = load i32, i32* %3
%20 = load i32, i32* %2
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %44
22: ; preds = %18
store i32 0, i32* %4
br label %23
23: ; preds = %37, %22
%24 = load i32, i32* %4
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %40
27: ; preds = %23
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%29 = load i32, i32* %5
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = mul nsw i64 %31, %14
%33 = getelementptr inbounds i32, i32* %17, i64 %32
%34 = load i32, i32* %4
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i32, i32* %33, i64 %35
store i32 %29, i32* %36
br label %37
37: ; preds = %27
%38 = load i32, i32* %4
%39 = add nsw i32 %38, 1
store i32 %39, i32* %4
br label %23
40: ; preds = %23
br label %41
41: ; preds = %40
%42 = load i32, i32* %3
%43 = add nsw i32 %42, 1
store i32 %43, i32* %3
br label %18
44: ; preds = %18
%45 = load i32, i32* %2
%46 = bitcast i32* %17 to i32**
%47 = call i32 @isMagic(i32 %45, i32** %46)
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %54
52: ; preds = %44
%53 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
%55 = load i8*, i8** %6
%56 = load i32, i32* %1
ret i32 %56
}

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