#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__ MagicCube(int, int **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int input;
  printf("Input Lenght Of the multidimentional array");
  scanf("%d", &input);
  int multidimentionalArray[input][input];
  int arrayCounter = 0;
  for (arrayCounter = 0; arrayCounter < input; arrayCounter++) {
    int secondCounter = 0;
    for (secondCounter = 0; secondCounter < input; secondCounter++) {
      printf("Input Digits -->");
      scanf("%d", &multidimentionalArray[arrayCounter][secondCounter]);
      printf("\n");
    }
  }
  if (MagicCube(input, multidimentionalArray)) {
    printf("The Cube Is Magical\n");
  } else {
    printf("The Cube is Not Magical\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x38(%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,-0x30(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1231 <main+0x101>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    121e <main+0xee>
lea    0xe5d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%rsi
movslq -0x24(%rbp),%rax
imul   %rcx,%rax
shl    $0x2,%rax
add    %rax,%rsi
movslq -0x28(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe2c(%rip),%rdi
call   1050 <scanf@plt>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11be <main+0x8e>
jmp    1223 <main+0xf3>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11a4 <main+0x74>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%edi
call   1030 <MagicCube@plt>
cmp    $0x0,%rax
je     1258 <main+0x128>
lea    0xdf1(%rip),%rdi
call   1040 <printf@plt>
jmp    1264 <main+0x134>
lea    0xdf5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%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    0xe98(%rip),%rdi
call   1060 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1070 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%ecx
mov    %rcx,%rax
imul   %rcx,%rax
mov    %rsp,%r13
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    -0x2c(%rbp),%edi
test   %edi,%edi
mov    %r13,-0x38(%rbp)
jle    1228 <main+0xd8>
shl    $0x2,%rcx
xor    %edx,%edx
lea    0xe76(%rip),%r15
lea    0xe6c(%rip),%r12
mov    %rcx,-0x48(%rbp)
jmp    11df <main+0x8f>
cs nopw 0x0(%rax,%rax,1)
nop
movslq %edi,%rax
add    $0x1,%rdx
add    %rcx,%r13
cmp    %rax,%rdx
jge    1228 <main+0xd8>
test   %edi,%edi
jle    11d0 <main+0x80>
mov    %rdx,-0x50(%rbp)
mov    %r13,%rbx
xor    %r14d,%r14d
nopl   (%rax)
mov    %r15,%rdi
call   1060 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14
movslq -0x2c(%rbp),%rdi
add    $0x4,%rbx
cmp    %rdi,%r14
jl     11f0 <main+0xa0>
mov    -0x48(%rbp),%rcx
mov    -0x50(%rbp),%rdx
jmp    11d0 <main+0x80>
mov    -0x38(%rbp),%rsi
call   1040 <MagicCube@plt>
test   %rax,%rax
lea    0xe04(%rip),%rax
lea    0xe15(%rip),%rdi
cmove  %rax,%rdi
call   1050 <puts@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 = [43 x i8] c"Input Lenght Of the multidimentional array\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [17 x i8] c"Input Digits -->\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [21 x i8] c"The Cube Is Magical\0A\00"
@.str.5 = [25 x i8] c"The Cube is Not Magical\0A\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
store i32 0, i32* %1
%8 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = zext i32 %10 to i64
%12 = load i32, i32* %2
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %3
%15 = mul nuw i64 %11, %13
%16 = alloca i32, i64 %15
store i64 %11, i64* %4
store i64 %13, i64* %5
store i32 0, i32* %6
store i32 0, i32* %6
br label %17
17: ; preds = %41, %0
%18 = load i32, i32* %6
%19 = load i32, i32* %2
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %44
21: ; preds = %17
store i32 0, i32* %7
store i32 0, i32* %7
br label %22
22: ; preds = %37, %21
%23 = load i32, i32* %7
%24 = load i32, i32* %2
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %40
26: ; preds = %22
%27 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = mul nsw i64 %29, %13
%31 = getelementptr inbounds i32, i32* %16, i64 %30
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %34)
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %37
37: ; preds = %26
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %22
40: ; preds = %22
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %17
44: ; preds = %17
%45 = load i32, i32* %2
%46 = bitcast i32* %16 to i32**
%47 = call i64 @MagicCube(i32 %45, i32** %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %44
%50 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %53
51: ; preds = %44
%52 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
%54 = load i8*, i8** %3
%55 = load i32, i32* %1
ret i32 %55
}

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