#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*/ isMagic(int **, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, i = 0, j;
  do
    scanf("%d", ({
            printf("Enter how much rows by colons do you want(1 number rows = "
                   "colons):");
            &n;
          }));
  while (n <= 2 || n >= 10);
  int square[n][n];
  printf("Farewell!Now enter the values of you own %d by %d square:\n", n, n);
  for (; i < n; i++) {
    for (j = 0; j < n; j++) {
      scanf("%d%*c", &square[i][j]);
    }
    printf("\n");
  }
  printf("Your \"magic square\" should look like this:\n");
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++)
      printf("\t%d ", square[i][j]);
    printf("\n");
  }
  if (!isMagic((int **)square, n))
    printf("Your square indeed is magic!\n");
  else
    printf("Sorry but your square isn't magic!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe99(%rip),%rdi
call   1050 <scanf@plt>
mov    $0x1,%al
cmpl   $0x2,-0x8(%rbp)
mov    %al,-0x31(%rbp)
jle    1185 <main+0x55>
cmpl   $0xa,-0x8(%rbp)
setge  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    1146 <main+0x16>
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)
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1256 <main+0x126>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    123a <main+0x10a>
mov    -0x40(%rbp),%rsi
mov    -0x48(%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    0xe5a(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f2 <main+0xc2>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11df <main+0xaf>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12e0 <main+0x1b0>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c4 <main+0x194>
mov    -0x40(%rbp),%rax
mov    -0x48(%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    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    127e <main+0x14e>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    126b <main+0x13b>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <isMagic@plt>
cmp    $0x0,%eax
jne    1308 <main+0x1d8>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1316 <main+0x1e6>
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
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    0xe9b(%rip),%r14
lea    0xe91(%rip),%r15
lea    -0x2c(%rbp),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    -0x2c(%rbp),%ecx
lea    -0xa(%rcx),%eax
cmp    $0xfffffff9,%eax
jb     1180 <main+0x30>
mov    %rsp,-0x48(%rbp)
mov    %rcx,%rax
mov    %rcx,-0x40(%rbp)
imul   %rcx,%rax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    -0x2c(%rbp),%edx
lea    0xe74(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x2c(%rbp),%eax
test   %eax,%eax
jle    125e <main+0x10e>
mov    -0x40(%rbp),%rcx
lea    0x0(,%rcx,4),%rcx
mov    %rcx,-0x50(%rbp)
xor    %r14d,%r14d
lea    0xe85(%rip),%r15
mov    -0x38(%rbp),%r12
jmp    122b <main+0xdb>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rax
add    -0x50(%rbp),%r12
cmp    %rax,%r14
jge    125e <main+0x10e>
test   %eax,%eax
jle    1210 <main+0xc0>
mov    %r12,%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%r13
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r13
jl     1240 <main+0xf0>
jmp    1210 <main+0xc0>
lea    0xe27(%rip),%rdi
call   1040 <puts@plt>
mov    -0x2c(%rbp),%esi
test   %esi,%esi
jle    12cd <main+0x17d>
mov    -0x40(%rbp),%r13
shl    $0x2,%r13
lea    0xe07(%rip),%r14
mov    -0x38(%rbp),%r12
xor    %r15d,%r15d
jmp    12aa <main+0x15a>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r15
movslq -0x2c(%rbp),%rsi
add    %r13,%r12
cmp    %rsi,%r15
jge    12cd <main+0x17d>
test   %esi,%esi
jle    1290 <main+0x140>
xor    %ebx,%ebx
mov    (%r12,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq -0x2c(%rbp),%rax
cmp    %rax,%rbx
jl     12b0 <main+0x160>
jmp    1290 <main+0x140>
mov    -0x38(%rbp),%rdi
call   1060 <isMagic@plt>
test   %eax,%eax
lea    0xdd8(%rip),%rax
lea    0xdee(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
mov    -0x48(%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 = [67 x i8] c"Enter how much rows by colons do you want(1 number rows = colons):\00"
@.str.2 = [59 x i8] c"Farewell!Now enter the values of you own %d by %d square:\0A\00"
@.str.3 = [6 x i8] c"%d%*c\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [44 x i8] c"Your \22magic square\22 should look like this:\0A\00"
@.str.6 = [5 x i8] c"\09%d \00"
@.str.7 = [30 x i8] c"Your square indeed is magic!\0A\00"
@.str.8 = [36 x i8] c"Sorry but your square isn't magic!\0A\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
store i32 0, i32* %1
store i32 0, i32* %3
br label %9
9: ; preds = %19, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
store i32* %2, i32** %5
%11 = load i32*, i32** %5
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
br label %13
13: ; preds = %9
%14 = load i32, i32* %2
%15 = icmp sle i32 %14, 2
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i32, i32* %2
%18 = icmp sge i32 %17, 10
br label %19
19: ; preds = %16, %13
%20 = phi i1 [ true, %13 ], [ %18, %16 ]
br i1 %20, label %9, label %21
21: ; preds = %19
%22 = load i32, i32* %2
%23 = zext i32 %22 to i64
%24 = load i32, i32* %2
%25 = zext i32 %24 to i64
%26 = call i8* @llvm.stacksave()
store i8* %26, i8** %6
%27 = mul nuw i64 %23, %25
%28 = alloca i32, i64 %27
store i64 %23, i64* %7
store i64 %25, i64* %8
%29 = load i32, i32* %2
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %30)
br label %32
32: ; preds = %55, %21
%33 = load i32, i32* %3
%34 = load i32, i32* %2
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %58
36: ; preds = %32
store i32 0, i32* %4
br label %37
37: ; preds = %50, %36
%38 = load i32, i32* %4
%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* %3
%43 = sext i32 %42 to i64
%44 = mul nsw i64 %43, %25
%45 = getelementptr inbounds i32, i32* %28, i64 %44
%46 = load i32, i32* %4
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* %45, i64 %47
%49 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %48)
br label %50
50: ; preds = %41
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 1
store i32 %52, i32* %4
br label %37
53: ; preds = %37
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %53
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %32
58: ; preds = %32
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %60
60: ; preds = %84, %58
%61 = load i32, i32* %3
%62 = load i32, i32* %2
%63 = icmp slt i32 %61, %62
br i1 %63, label %64, label %87
64: ; preds = %60
store i32 0, i32* %4
br label %65
65: ; preds = %79, %64
%66 = load i32, i32* %4
%67 = load i32, i32* %2
%68 = icmp slt i32 %66, %67
br i1 %68, label %69, label %82
69: ; preds = %65
%70 = load i32, i32* %3
%71 = sext i32 %70 to i64
%72 = mul nsw i64 %71, %25
%73 = getelementptr inbounds i32, i32* %28, i64 %72
%74 = load i32, i32* %4
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %73, i64 %75
%77 = load i32, i32* %76
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %69
%80 = load i32, i32* %4
%81 = add nsw i32 %80, 1
store i32 %81, i32* %4
br label %65
82: ; preds = %65
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %84
84: ; preds = %82
%85 = load i32, i32* %3
%86 = add nsw i32 %85, 1
store i32 %86, i32* %3
br label %60
87: ; preds = %60
%88 = bitcast i32* %28 to i32**
%89 = load i32, i32* %2
%90 = call i32 @isMagic(i32** %88, i32 %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %94, label %92
92: ; preds = %87
%93 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %96
94: ; preds = %87
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.8, i64 0, i64 0))
br label %96
96: ; preds = %94, %92
store i32 0, i32* %1
%97 = load i8*, i8** %6
%98 = load i32, i32* %1
ret i32 %98
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [67 x i8] c"Enter how much rows by colons do you want(1 number rows = colons):\00"
@.str.2 = [59 x i8] c"Farewell!Now enter the values of you own %d by %d square:\0A\00"
@.str.3 = [6 x i8] c"%d%*c\00"
@.str.6 = [5 x i8] c"\09%d \00"
@str = [43 x i8] c"Your \22magic square\22 should look like this:\00"
@str.9 = [29 x i8] c"Your square indeed is magic!\00"
@str.10 = [35 x i8] c"Sorry but your square isn't magic!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%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 = add i32 %6, -10
%8 = icmp ult i32 %7, -7
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = zext i32 %6 to i64
%11 = call i8* @llvm.stacksave()
%12 = mul nuw nsw i64 %10, %10
%13 = alloca i32, i64 %12
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %14)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %39
18: ; preds = %9, %33
%19 = phi i32 [ %36, %33 ], [ %16, %9 ]
%20 = phi i64 [ %35, %33 ], [ 0, %9 ]
%21 = icmp sgt i32 %19, 0
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = mul nuw nsw i64 %20, %10
%24 = getelementptr inbounds i32, i32* %13, i64 %23
br label %25
25: ; preds = %22, %25
%26 = phi i64 [ 0, %22 ], [ %29, %25 ]
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32* %27)
%29 = add nuw nsw i64 %26, 1
%30 = load i32, i32* %1
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %25, label %33
33: ; preds = %25, %18
%34 = call i32 @putchar(i32 10)
%35 = add nuw nsw i64 %20, 1
%36 = load i32, i32* %1
%37 = sext i32 %36 to i64
%38 = icmp slt i64 %35, %37
br i1 %38, label %18, label %39
39: ; preds = %33, %9
%40 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%41 = load i32, i32* %1
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %65
43: ; preds = %39, %59
%44 = phi i32 [ %62, %59 ], [ %41, %39 ]
%45 = phi i64 [ %61, %59 ], [ 0, %39 ]
%46 = icmp sgt i32 %44, 0
br i1 %46, label %47, label %59
47: ; preds = %43
%48 = mul nuw nsw i64 %45, %10
%49 = getelementptr inbounds i32, i32* %13, i64 %48
br label %50
50: ; preds = %47, %50
%51 = phi i64 [ 0, %47 ], [ %55, %50 ]
%52 = getelementptr inbounds i32, i32* %49, i64 %51
%53 = load i32, i32* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i32 %53)
%55 = add nuw nsw i64 %51, 1
%56 = load i32, i32* %1
%57 = sext i32 %56 to i64
%58 = icmp slt i64 %55, %57
br i1 %58, label %50, label %59
59: ; preds = %50, %43
%60 = call i32 @putchar(i32 10)
%61 = add nuw nsw i64 %45, 1
%62 = load i32, i32* %1
%63 = sext i32 %62 to i64
%64 = icmp slt i64 %61, %63
br i1 %64, label %43, label %65
65: ; preds = %59, %39
%66 = phi i32 [ %41, %39 ], [ %62, %59 ]
%67 = bitcast i32* %13 to i32**
%68 = call i32 @isMagic(i32** %67, i32 %66)
%69 = icmp eq i32 %68, 0
%70 = select i1 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str.9, i64 0, i64 0), i8* getelementptr inbounds ([35 x i8], [35 x i8]* @str.10, i64 0, i64 0)
%71 = call i32 @puts(i8* dereferenceable(1) %70)
ret i32 0
}