#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 *);
void 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");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c50,%rsp
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11f6 <main+0xc6>
mov    -0x8(%rbp),%esi
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11e3 <main+0xb3>
mov    -0xc(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
lea    -0x9c50(%rbp),%rsi
imul   $0x190,%rax,%rax
add    %rax,%rsi
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe59(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1184 <main+0x54>
jmp    11e8 <main+0xb8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1160 <main+0x30>
lea    -0x9c50(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <mag@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jne    1225 <main+0xf5>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x103>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x9c50,%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>
cmp    $0x1,%eax
lea    0xe43(%rip),%rax
lea    0xe20(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
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 void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [100 x [100 x i32]]
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 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* %1)
store i32 1, i32* %2
br label %8
8: ; preds = %35, %0
%9 = load i32, i32* %2
%10 = load i32, i32* %1
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %38
12: ; preds = %8
%13 = load i32, i32* %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %13)
store i32 1, i32* %3
br label %15
15: ; preds = %31, %12
%16 = load i32, i32* %3
%17 = load i32, i32* %1
%18 = icmp sle i32 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %15
%20 = load i32, i32* %3
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100 x [100 x i32]], [100 x [100 x i32]]* %5, i64 0, i64 %24
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 1
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %25, i64 0, i64 %28
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %29)
br label %31
31: ; preds = %19
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %15
34: ; preds = %15
br label %35
35: ; preds = %34
%36 = load i32, i32* %2
%37 = add nsw i32 %36, 1
store i32 %37, i32* %2
br label %8
38: ; preds = %8
%39 = bitcast [100 x [100 x i32]]* %5 to i32***
%40 = load i32, i32* %1
%41 = call i32 @mag(i32*** %39, i32 %40)
store i32 %41, i32* %4
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 1
br i1 %43, label %44, label %46
44: ; preds = %38
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
br label %48
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
ret void
}

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 void @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 void
}