#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 main() {
  int size;
  int square[size][size];
  int row, col = 0;
  int sum, sum1, sum2;
  int magic = 0;
  while (size < 0 && size > 999) {
    printf("Size (max 999): ");
    scanf("%d", &size);
  }
  printf("Enter numbers: ");
  for (row = 0; row < size; row++) {
    for (col = 0; col < size; col++) {
      scanf("%d", &square[row][col]);
    }
  }
  sum = 0;
  for (row = 0; row < size; row++) {
    for (col = 0; col < size; col++) {
      if (row == col)
        sum = sum + square[row][col];
    }
  }
  for (row = 0; row < size; row++) {
    sum1 = 0;
    for (col = 0; col < size; col++) {
      sum1 = sum1 + square[row][col];
    }
    if (sum == sum1)
      magic = 1;
    else
      magic = 0;
  }
  for (row = 0; row < size; row++) {
    sum2 = 0;
    for (col = 0; col < size; col++) {
      sum2 = sum2 + square[col][row];
    }
    if (sum == sum2)
      magic = 1;
    else
      magic = 0;
  }
  if (magic = 1)
    printf("\nMAGIC");
  else
    printf("\nNOT MAGIC");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x10(%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,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x8(%rbp)
mov    %al,-0x49(%rbp)
jge    1194 <main+0x74>
cmpl   $0x3e7,-0x8(%rbp)
setg   %al
mov    %al,-0x49(%rbp)
mov    -0x49(%rbp),%al
test   $0x1,%al
jne    11a4 <main+0x84>
jmp    11c5 <main+0xa5>
lea    0xe55(%rip),%rdi
call   1030 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
jmp    1178 <main+0x58>
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1246 <main+0x126>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1233 <main+0x113>
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rcx
movslq -0x24(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdf1(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11eb <main+0xcb>
jmp    1238 <main+0x118>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d8 <main+0xb8>
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c9 <main+0x1a9>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12b6 <main+0x196>
mov    -0x24(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    12a3 <main+0x183>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rsi
mov    -0x2c(%rbp),%eax
movslq -0x24(%rbp),%rdx
imul   %rsi,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
movslq -0x28(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x2c(%rbp)
jmp    12a8 <main+0x188>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1267 <main+0x147>
jmp    12bb <main+0x19b>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1254 <main+0x134>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    135a <main+0x23a>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1328 <main+0x208>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rsi
mov    -0x30(%rbp),%eax
movslq -0x24(%rbp),%rdx
imul   %rsi,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
movslq -0x28(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    12ea <main+0x1ca>
mov    -0x2c(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    1340 <main+0x220>
movl   $0x1,-0x38(%rbp)
jmp    1347 <main+0x227>
movl   $0x0,-0x38(%rbp)
jmp    134c <main+0x22c>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    12d0 <main+0x1b0>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13eb <main+0x2cb>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13b9 <main+0x299>
mov    -0x40(%rbp),%rcx
mov    -0x48(%rbp),%rsi
mov    -0x34(%rbp),%eax
movslq -0x28(%rbp),%rdx
imul   %rsi,%rdx
shl    $0x2,%rdx
add    %rdx,%rcx
movslq -0x24(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    137b <main+0x25b>
mov    -0x2c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    13d1 <main+0x2b1>
movl   $0x1,-0x38(%rbp)
jmp    13d8 <main+0x2b8>
movl   $0x0,-0x38(%rbp)
jmp    13dd <main+0x2bd>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1361 <main+0x241>
movl   $0x1,-0x38(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1401 <main+0x2e1>
jmp    1412 <main+0x2f2>
lea    0xc1c(%rip),%rdi
call   1030 <printf@plt>
jmp    141e <main+0x2fe>
lea    0xc12(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Size (max 999): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [16 x i8] c"Enter numbers: \00"
@.str.3 = [7 x i8] c"\0AMAGIC\00"
@.str.4 = [11 x i8] c"\0ANOT MAGIC\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = load i32, i32* %2
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %3
%17 = mul nuw i64 %13, %15
%18 = alloca i32, i64 %17
store i64 %13, i64* %4
store i64 %15, i64* %5
store i32 0, i32* %7
store i32 0, i32* %11
br label %19
19: ; preds = %27, %0
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %2
%24 = icmp sgt i32 %23, 999
br label %25
25: ; preds = %22, %19
%26 = phi i1 [ false, %19 ], [ %24, %22 ]
br i1 %26, label %27, label %30
27: ; preds = %25
%28 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %19
30: ; preds = %25
%31 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %32
32: ; preds = %54, %30
%33 = load i32, i32* %6
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %57
36: ; preds = %32
store i32 0, i32* %7
br label %37
37: ; preds = %50, %36
%38 = load i32, i32* %7
%39 = load i32, i32* %2
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %53
41: ; preds = %37
%42 = load i32, i32* %6
%43 = sext i32 %42 to i64
%44 = mul nsw i64 %43, %15
%45 = getelementptr inbounds i32, i32* %18, i64 %44
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %48)
br label %50
50: ; preds = %41
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %37
53: ; preds = %37
br label %54
54: ; preds = %53
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %32
57: ; preds = %32
store i32 0, i32* %8
store i32 0, i32* %6
br label %58
58: ; preds = %87, %57
%59 = load i32, i32* %6
%60 = load i32, i32* %2
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %90
62: ; preds = %58
store i32 0, i32* %7
br label %63
63: ; preds = %83, %62
%64 = load i32, i32* %7
%65 = load i32, i32* %2
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %86
67: ; preds = %63
%68 = load i32, i32* %6
%69 = load i32, i32* %7
%70 = icmp eq i32 %68, %69
br i1 %70, label %71, label %82
71: ; preds = %67
%72 = load i32, i32* %8
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = mul nsw i64 %74, %15
%76 = getelementptr inbounds i32, i32* %18, i64 %75
%77 = load i32, i32* %7
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds i32, i32* %76, i64 %78
%80 = load i32, i32* %79
%81 = add nsw i32 %72, %80
store i32 %81, i32* %8
br label %82
82: ; preds = %71, %67
br label %83
83: ; preds = %82
%84 = load i32, i32* %7
%85 = add nsw i32 %84, 1
store i32 %85, i32* %7
br label %63
86: ; preds = %63
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = add nsw i32 %88, 1
store i32 %89, i32* %6
br label %58
90: ; preds = %58
store i32 0, i32* %6
br label %91
91: ; preds = %121, %90
%92 = load i32, i32* %6
%93 = load i32, i32* %2
%94 = icmp slt i32 %92, %93
br i1 %94, label %95, label %124
95: ; preds = %91
store i32 0, i32* %9
store i32 0, i32* %7
br label %96
96: ; preds = %111, %95
%97 = load i32, i32* %7
%98 = load i32, i32* %2
%99 = icmp slt i32 %97, %98
br i1 %99, label %100, label %114
100: ; preds = %96
%101 = load i32, i32* %9
%102 = load i32, i32* %6
%103 = sext i32 %102 to i64
%104 = mul nsw i64 %103, %15
%105 = getelementptr inbounds i32, i32* %18, i64 %104
%106 = load i32, i32* %7
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i32, i32* %105, i64 %107
%109 = load i32, i32* %108
%110 = add nsw i32 %101, %109
store i32 %110, i32* %9
br label %111
111: ; preds = %100
%112 = load i32, i32* %7
%113 = add nsw i32 %112, 1
store i32 %113, i32* %7
br label %96
114: ; preds = %96
%115 = load i32, i32* %8
%116 = load i32, i32* %9
%117 = icmp eq i32 %115, %116
br i1 %117, label %118, label %119
118: ; preds = %114
store i32 1, i32* %11
br label %120
119: ; preds = %114
store i32 0, i32* %11
br label %120
120: ; preds = %119, %118
br label %121
121: ; preds = %120
%122 = load i32, i32* %6
%123 = add nsw i32 %122, 1
store i32 %123, i32* %6
br label %91
124: ; preds = %91
store i32 0, i32* %6
br label %125
125: ; preds = %155, %124
%126 = load i32, i32* %6
%127 = load i32, i32* %2
%128 = icmp slt i32 %126, %127
br i1 %128, label %129, label %158
129: ; preds = %125
store i32 0, i32* %10
store i32 0, i32* %7
br label %130
130: ; preds = %145, %129
%131 = load i32, i32* %7
%132 = load i32, i32* %2
%133 = icmp slt i32 %131, %132
br i1 %133, label %134, label %148
134: ; preds = %130
%135 = load i32, i32* %10
%136 = load i32, i32* %7
%137 = sext i32 %136 to i64
%138 = mul nsw i64 %137, %15
%139 = getelementptr inbounds i32, i32* %18, i64 %138
%140 = load i32, i32* %6
%141 = sext i32 %140 to i64
%142 = getelementptr inbounds i32, i32* %139, i64 %141
%143 = load i32, i32* %142
%144 = add nsw i32 %135, %143
store i32 %144, i32* %10
br label %145
145: ; preds = %134
%146 = load i32, i32* %7
%147 = add nsw i32 %146, 1
store i32 %147, i32* %7
br label %130
148: ; preds = %130
%149 = load i32, i32* %8
%150 = load i32, i32* %10
%151 = icmp eq i32 %149, %150
br i1 %151, label %152, label %153
152: ; preds = %148
store i32 1, i32* %11
br label %154
153: ; preds = %148
store i32 0, i32* %11
br label %154
154: ; preds = %153, %152
br label %155
155: ; preds = %154
%156 = load i32, i32* %6
%157 = add nsw i32 %156, 1
store i32 %157, i32* %6
br label %125
158: ; preds = %125
store i32 1, i32* %11
br i1 true, label %159, label %161
159: ; preds = %158
%160 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
br label %163
161: ; preds = %158
%162 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %163
163: ; preds = %161, %159
store i32 0, i32* %1
%164 = load i8*, i8** %3
%165 = load i32, i32* %1
ret i32 %165
}

LLVM IR (-O2):
@.str.2 = [16 x i8] c"Enter numbers: \00"
@.str.3 = [7 x i8] c"\0AMAGIC\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%2 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}