#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*/ is_the_square_magic(int **, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int square[999][999];
  int size, counter_rows, counter_colums;
  printf("Square size:\n");
  scanf("%d", &size);
  for (counter_rows = 0; counter_rows < size; counter_rows++) {
    for (counter_colums = 0; counter_colums < size; counter_colums++) {
      printf("Input for %d row %d colum:\n", counter_rows + 1,
             counter_colums + 1);
      scanf("%d", &square[counter_rows][counter_colums]);
    }
  }
  for (counter_rows = 0; counter_rows < size; counter_rows++) {
    for (counter_colums = 0; counter_colums < size; counter_colums++) {
      printf("%d", square[counter_rows][counter_colums]);
    }
    printf("\n");
  }
  printf("\n");
  is_the_square_magic(square, size);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3ce9e0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x3ce9d4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x3ce9d8(%rbp)
mov    -0x3ce9d8(%rbp),%eax
cmp    -0x3ce9d4(%rbp),%eax
jge    121a <main+0xea>
movl   $0x0,-0x3ce9dc(%rbp)
mov    -0x3ce9dc(%rbp),%eax
cmp    -0x3ce9d4(%rbp),%eax
jge    1201 <main+0xd1>
mov    -0x3ce9d8(%rbp),%esi
add    $0x1,%esi
mov    -0x3ce9dc(%rbp),%edx
add    $0x1,%edx
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0x3ce9d8(%rbp),%rax
lea    -0x3ce9d0(%rbp),%rsi
imul   $0xf9c,%rax,%rax
add    %rax,%rsi
movslq -0x3ce9dc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe26(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x3ce9dc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ce9dc(%rbp)
jmp    1189 <main+0x59>
jmp    1206 <main+0xd6>
mov    -0x3ce9d8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ce9d8(%rbp)
jmp    116d <main+0x3d>
movl   $0x0,-0x3ce9d8(%rbp)
mov    -0x3ce9d8(%rbp),%eax
cmp    -0x3ce9d4(%rbp),%eax
jge    12b8 <main+0x188>
movl   $0x0,-0x3ce9dc(%rbp)
mov    -0x3ce9dc(%rbp),%eax
cmp    -0x3ce9d4(%rbp),%eax
jge    1296 <main+0x166>
movslq -0x3ce9d8(%rbp),%rcx
lea    -0x3ce9d0(%rbp),%rax
imul   $0xf9c,%rcx,%rcx
add    %rcx,%rax
movslq -0x3ce9dc(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3ce9dc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ce9dc(%rbp)
jmp    1240 <main+0x110>
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3ce9d8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3ce9d8(%rbp)
jmp    1224 <main+0xf4>
lea    0xd4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x3ce9d0(%rbp),%rdi
mov    -0x3ce9d4(%rbp),%esi
call   1050 <is_the_square_magic@plt>
xor    %eax,%eax
add    $0x3ce9e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x3ce9d8,%rsp
lea    0xeb7(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8c(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    126e <main+0x11e>
lea    0x10(%rsp),%rbp
lea    0xe6d(%rip),%r14
lea    0xe63(%rip),%r15
xor    %r12d,%r12d
jmp    11bf <main+0x6f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %eax,%rcx
add    $0xf9c,%rbp
cmp    %rcx,%r12
jge    11fe <main+0xae>
add    $0x1,%r12
test   %eax,%eax
jle    11b0 <main+0x60>
mov    %rbp,%r13
xor    %ebx,%ebx
nopl   0x0(%rax)
add    $0x1,%rbx
mov    %r14,%rdi
mov    %r12d,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
movslq 0xc(%rsp),%rax
add    $0x4,%r13
cmp    %rax,%rbx
jl     11d0 <main+0x80>
jmp    11b0 <main+0x60>
test   %eax,%eax
jle    126e <main+0x11e>
lea    0x10(%rsp),%rbp
lea    0xdf2(%rip),%r15
xor    %r14d,%r14d
jmp    123f <main+0xef>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
movslq 0xc(%rsp),%rax
add    $0xf9c,%rbp
cmp    %rax,%r14
jge    126e <main+0x11e>
test   %eax,%eax
jle    1220 <main+0xd0>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x0(%rbp,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1250 <main+0x100>
jmp    1220 <main+0xd0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1070 <is_the_square_magic@plt>
xor    %eax,%eax
add    $0x3ce9d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Square size:\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Input for %d row %d colum:\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [999 x [999 x i32]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %4
%10 = load i32, i32* %3
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %37
12: ; preds = %8
store i32 0, i32* %5
br label %13
13: ; preds = %30, %12
%14 = load i32, i32* %5
%15 = load i32, i32* %3
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %33
17: ; preds = %13
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %21)
%23 = load i32, i32* %4
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [999 x [999 x i32]], [999 x [999 x i32]]* %2, i64 0, i64 %24
%26 = load i32, i32* %5
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [999 x i32], [999 x i32]* %25, i64 0, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %17
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %13
33: ; preds = %13
br label %34
34: ; preds = %33
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %8
37: ; preds = %8
store i32 0, i32* %4
br label %38
38: ; preds = %61, %37
%39 = load i32, i32* %4
%40 = load i32, i32* %3
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %64
42: ; preds = %38
store i32 0, i32* %5
br label %43
43: ; preds = %56, %42
%44 = load i32, i32* %5
%45 = load i32, i32* %3
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %59
47: ; preds = %43
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [999 x [999 x i32]], [999 x [999 x i32]]* %2, i64 0, i64 %49
%51 = load i32, i32* %5
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [999 x i32], [999 x i32]* %50, i64 0, i64 %52
%54 = load i32, i32* %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %47
%57 = load i32, i32* %5
%58 = add nsw i32 %57, 1
store i32 %58, i32* %5
br label %43
59: ; preds = %43
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %61
61: ; preds = %59
%62 = load i32, i32* %4
%63 = add nsw i32 %62, 1
store i32 %63, i32* %4
br label %38
64: ; preds = %38
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%66 = getelementptr inbounds [999 x [999 x i32]], [999 x [999 x i32]]* %2, i64 0, i64 0
%67 = bitcast [999 x i32]* %66 to i32**
%68 = load i32, i32* %3
%69 = call i32 @is_the_square_magic(i32** %67, i32 %68)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Input for %d row %d colum:\0A\00"
@str = [13 x i8] c"Square size:\00"
define i32 @main() {
%1 = alloca [999 x [999 x i32]]
%2 = alloca i32
%3 = bitcast [999 x [999 x i32]]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %0, %28
%10 = phi i32 [ %29, %28 ], [ %7, %0 ]
%11 = phi i64 [ %13, %28 ], [ 0, %0 ]
%12 = icmp sgt i32 %10, 0
%13 = add nuw nsw i64 %11, 1
br i1 %12, label %14, label %28
14: ; preds = %9
%15 = trunc i64 %13 to i32
br label %18
16: ; preds = %28
%17 = icmp sgt i32 %29, 0
br i1 %17, label %32, label %51
18: ; preds = %14, %18
%19 = phi i64 [ 0, %14 ], [ %20, %18 ]
%20 = add nuw nsw i64 %19, 1
%21 = trunc i64 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %21)
%23 = getelementptr inbounds [999 x [999 x i32]], [999 x [999 x i32]]* %1, i64 0, i64 %11, i64 %19
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
%25 = load i32, i32* %2
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %20, %26
br i1 %27, label %18, label %28
28: ; preds = %18, %9
%29 = phi i32 [ %10, %9 ], [ %25, %18 ]
%30 = sext i32 %29 to i64
%31 = icmp slt i64 %13, %30
br i1 %31, label %9, label %16
32: ; preds = %16, %45
%33 = phi i32 [ %48, %45 ], [ %29, %16 ]
%34 = phi i64 [ %47, %45 ], [ 0, %16 ]
%35 = icmp sgt i32 %33, 0
br i1 %35, label %36, label %45
36: ; preds = %32, %36
%37 = phi i64 [ %41, %36 ], [ 0, %32 ]
%38 = getelementptr inbounds [999 x [999 x i32]], [999 x [999 x i32]]* %1, i64 0, i64 %34, i64 %37
%39 = load i32, i32* %38
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = add nuw nsw i64 %37, 1
%42 = load i32, i32* %2
%43 = sext i32 %42 to i64
%44 = icmp slt i64 %41, %43
br i1 %44, label %36, label %45
45: ; preds = %36, %32
%46 = call i32 @putchar(i32 10)
%47 = add nuw nsw i64 %34, 1
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = icmp slt i64 %47, %49
br i1 %50, label %32, label %51
51: ; preds = %45, %0, %16
%52 = call i32 @putchar(i32 10)
%53 = bitcast [999 x [999 x i32]]* %1 to i32**
%54 = load i32, i32* %2
%55 = call i32 @is_the_square_magic(i32** %53, i32 %54)
ret i32 0
}