#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 */
scalar_t__ IfSqrMagic(int **, int);
int /*<<< orphan*/ MakeASquare(int **, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int square[1000][1000];
  int size;
  scanf("%d", &size);
  MakeASquare(square, size);
  if (IfSqrMagic(square, size)) {
    printf("MAGIC\n");
  } else {
    printf("NO MAGIC\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d0920,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x3d0914(%rbp),%rsi
call   1050 <scanf@plt>
lea    -0x3d0910(%rbp),%rdi
mov    -0x3d0914(%rbp),%esi
call   1060 <MakeASquare@plt>
lea    -0x3d0910(%rbp),%rdi
mov    -0x3d0914(%rbp),%esi
call   1030 <IfSqrMagic@plt>
cmp    $0x0,%rax
je     11a4 <main+0x64>
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
jmp    11b0 <main+0x70>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x3d0920,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x3d0910,%rsp
lea    0xeb1(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <MakeASquare@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   1030 <IfSqrMagic@plt>
test   %rax,%rax
lea    0xe83(%rip),%rax
lea    0xe7f(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x3d0910,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"MAGIC\0A\00"
@.str.2 = [10 x i8] c"NO MAGIC\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [1000 x [1000 x i32]]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%5 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* %2, i64 0, i64 0
%6 = bitcast [1000 x i32]* %5 to i32**
%7 = load i32, i32* %3
%8 = call i32 @MakeASquare(i32** %6, i32 %7)
%9 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* %2, i64 0, i64 0
%10 = bitcast [1000 x i32]* %9 to i32**
%11 = load i32, i32* %3
%12 = call i64 @IfSqrMagic(i32** %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %16, %14
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [9 x i8] c"NO MAGIC\00"
@str.3 = [6 x i8] c"MAGIC\00"
define i32 @main() {
%1 = alloca [1000 x [1000 x i32]]
%2 = alloca i32
%3 = bitcast [1000 x [1000 x 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* %2)
%6 = bitcast [1000 x [1000 x i32]]* %1 to i32**
%7 = load i32, i32* %2
%8 = call i32 @MakeASquare(i32** %6, i32 %7)
%9 = load i32, i32* %2
%10 = call i64 @IfSqrMagic(i32** %6, i32 %9)
%11 = icmp eq i64 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0)
%13 = call i32 @puts(i8* dereferenceable(1) %12)
ret i32 0
}