#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*/ AreColumnsMagical(int **, int);
int /*<<< orphan*/ AreDiagonalsMagical(int **, int);
int /*<<< orphan*/ AreRowsMagical(int **, int);
int IsSquareMagical(int square[1000][1000], int size) {
  if (!AreRowsMagical(square, size) || !AreColumnsMagical(square, size) ||
      !AreDiagonalsMagical(square, size)) {
    return 0;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<IsSquareMagical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <AreRowsMagical@plt>
cmp    $0x0,%eax
je     117e <IsSquareMagical+0x4e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <AreColumnsMagical@plt>
cmp    $0x0,%eax
je     117e <IsSquareMagical+0x4e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <AreDiagonalsMagical@plt>
cmp    $0x0,%eax
jne    118a <IsSquareMagical+0x5a>
movl   $0x0,-0x4(%rbp)
jmp    1191 <IsSquareMagical+0x61>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<IsSquareMagical>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
call   1030 <AreRowsMagical@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     1167 <IsSquareMagical+0x37>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <AreColumnsMagical@plt>
test   %eax,%eax
je     1167 <IsSquareMagical+0x37>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1050 <AreDiagonalsMagical@plt>
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @IsSquareMagical([1000 x i32]* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [1000 x i32]*
%5 = alloca i32
store [1000 x i32]* %0, [1000 x i32]** %4
store i32 %1, i32* %5
%6 = load [1000 x i32]*, [1000 x i32]** %4
%7 = bitcast [1000 x i32]* %6 to i32**
%8 = load i32, i32* %5
%9 = call i32 @AreRowsMagical(i32** %7, i32 %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %2
%12 = load [1000 x i32]*, [1000 x i32]** %4
%13 = bitcast [1000 x i32]* %12 to i32**
%14 = load i32, i32* %5
%15 = call i32 @AreColumnsMagical(i32** %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %23
17: ; preds = %11
%18 = load [1000 x i32]*, [1000 x i32]** %4
%19 = bitcast [1000 x i32]* %18 to i32**
%20 = load i32, i32* %5
%21 = call i32 @AreDiagonalsMagical(i32** %19, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %17, %11, %2
store i32 0, i32* %3
br label %25
24: ; preds = %17
store i32 1, i32* %3
br label %25
25: ; preds = %24, %23
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @IsSquareMagical([1000 x i32]* %0, i32 %1) {
%3 = bitcast [1000 x i32]* %0 to i32**
%4 = tail call i32 @AreRowsMagical(i32** %3, i32 %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = tail call i32 @AreColumnsMagical(i32** %3, i32 %1)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6
%10 = tail call i32 @AreDiagonalsMagical(i32** %3, i32 %1)
%11 = icmp ne i32 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %9, %2, %6
%14 = phi i32 [ 0, %6 ], [ 0, %2 ], [ %12, %9 ]
ret i32 %14
}