#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 mag(int ***, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, i, j, b, x[100][100];
  printf("\nVavedi dalzina na stranata na kvadrata:");
  scanf("%d", &a);
  for (i = 1; i <= a; i++) {
    printf("\nRed %d:\n", i);
    for (j = 1; j <= a; j++) {
      printf("    Chislo %d: ", j);
      scanf("%d", &x[i - 1][j - 1]);
    }
  }
  b = mag(&x, a);
  if (b == 1)
    printf("\nTozi kvadrat e magicheski!\n");
  else
    printf("\nNikakva magia, opitai pak.\n");
  return b;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11fd <main+0xcd>
mov    -0xc(%rbp),%esi
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11ea <main+0xba>
mov    -0x10(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x9c60(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe52(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118b <main+0x5b>
jmp    11ef <main+0xbf>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1167 <main+0x37>
lea    -0x9c60(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <mag@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    122c <main+0xfc>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123a <main+0x10a>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x9c60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    120b <main+0xcb>
mov    $0x1,%r15d
lea    0x10(%rsp),%r14
lea    0xea8(%rip),%r12
lea    0xe94(%rip),%r13
jmp    11b6 <main+0x76>
nopw   0x0(%rax,%rax,1)
movslq %esi,%rax
lea    0x1(%r15),%rcx
add    $0x190,%r14
cmp    %rax,%r15
mov    %rcx,%r15
jge    120b <main+0xcb>
lea    0xe6f(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x60>
mov    %r14,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbp
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     11e0 <main+0xa0>
jmp    11a0 <main+0x60>
lea    0x10(%rsp),%rdi
call   1060 <mag@plt>
mov    %eax,%ebx
cmp    $0x1,%eax
lea    0xe41(%rip),%rax
lea    0xe1e(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\0AVavedi dalzina na stranata na kvadrata:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"\0ARed %d:\0A\00"
@.str.3 = [16 x i8] c" Chislo %d: \00"
@.str.4 = [29 x i8] c"\0ATozi kvadrat e magicheski!\0A\00"
@.str.5 = [29 x i8] c"\0ANikakva magia, opitai pak.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x [100 x i32]]
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %39
13: ; preds = %9
%14 = load i32, i32* %3
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 1, i32* %4
br label %16
16: ; preds = %32, %13
%17 = load i32, i32* %4
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %35
20: ; preds = %16
%21 = load i32, i32* %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %6, i64 0, i64 %25
%27 = load i32, i32* %4
%28 = sub nsw i32 %27, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %26, i64 0, i64 %29
%31 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %30)
br label %32
32: ; preds = %20
%33 = load i32, i32* %4
%34 = add nsw i32 %33, 1
store i32 %34, i32* %4
br label %16
35: ; preds = %16
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %3
br label %9
39: ; preds = %9
%40 = bitcast [100 x [100 x i32]]* %6 to i32***
%41 = load i32, i32* %2
%42 = call i32 @mag(i32*** %40, i32 %41)
store i32 %42, i32* %5
%43 = load i32, i32* %5
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %47
45: ; preds = %39
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %49
47: ; preds = %39
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
%50 = load i32, i32* %5
ret i32 %50
}

LLVM IR (-O2):
@.str = [41 x i8] c"\0AVavedi dalzina na stranata na kvadrata:\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"\0ARed %d:\0A\00"
@.str.3 = [16 x i8] c" Chislo %d: \00"
@str = [28 x i8] c"\0ANikakva magia, opitai pak.\00"
@str.6 = [28 x i8] c"\0ATozi kvadrat e magicheski!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x [100 x i32]]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 x [100 x i32]]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 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* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %33, label %9
9: ; preds = %0, %28
%10 = phi i64 [ %31, %28 ], [ 1, %0 ]
%11 = trunc i64 %10 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %1
%14 = icmp slt i32 %13, 1
br i1 %14, label %28, label %15
15: ; preds = %9
%16 = add nsw i64 %10, -1
br label %17
17: ; preds = %15, %17
%18 = phi i64 [ 1, %15 ], [ %24, %17 ]
%19 = trunc i64 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = add nsw i64 %18, -1
%22 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %2, i64 0, i64 %16, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %22)
%24 = add nuw nsw i64 %18, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %18, %26
br i1 %27, label %17, label %28
28: ; preds = %17, %9
%29 = phi i32 [ %13, %9 ], [ %25, %17 ]
%30 = sext i32 %29 to i64
%31 = add nuw nsw i64 %10, 1
%32 = icmp slt i64 %10, %30
br i1 %32, label %9, label %33
33: ; preds = %28, %0
%34 = phi i32 [ %7, %0 ], [ %29, %28 ]
%35 = bitcast [100 x [100 x i32]]* %2 to i32***
%36 = call i32 @mag(i32*** %35, i32 %34)
%37 = icmp eq i32 %36, 1
%38 = select i1 %37, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str.6, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0)
%39 = call i32 @puts(i8* dereferenceable(1) %38)
ret i32 %36
}