#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*/ assert(int);
int /*<<< orphan*/ equals(double const, double const);
bool isSymmetric(const int patternSize, const double W[][1000]) {
  assert(patternSize < 1000);
  bool isSymmetric = true;
  for (int i = 1; i < patternSize; i++) {
    for (int j = i; j < patternSize; j++) {
      if (!equals(W[i][j], W[j][i])) {
        isSymmetric = false;
        break;
      }
    }
    if (!isSymmetric) {
      break;
    }
  }
  return isSymmetric;
}


x86 assembly (clang, -O0):
<isSymmetric>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3e8,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x1,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11f4 <isSymmetric+0xd4>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11d2 <isSymmetric+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
call   1040 <equals@plt>
cmp    $0x0,%eax
jne    11bf <isSymmetric+0x9f>
movl   $0x0,-0x14(%rbp)
jmp    11d2 <isSymmetric+0xb2>
jmp    11c4 <isSymmetric+0xa4>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <isSymmetric+0x43>
cmpl   $0x0,-0x14(%rbp)
jne    11e1 <isSymmetric+0xc1>
jmp    11f4 <isSymmetric+0xd4>
jmp    11e6 <isSymmetric+0xc6>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <isSymmetric+0x31>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isSymmetric>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x3e8,%ebp
setl   %dil
call   1030 <assert@plt>
mov    $0x1,%r14d
cmp    $0x2,%ebp
jl     11ae <isSymmetric+0x8e>
mov    %ebp,%eax
add    $0x1f48,%rbx
mov    %rax,(%rsp)
lea    -0x1(%rax),%r13
mov    $0x1,%r12d
xor    %ebp,%ebp
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsd  (%rbx,%r15,8),%xmm0
movsd  (%rbx,%rbp,8),%xmm1
call   1040 <equals@plt>
test   %eax,%eax
je     11ab <isSymmetric+0x8b>
add    $0x1,%r15
add    $0x3e8,%rbp
cmp    %r15,%r13
jne    1170 <isSymmetric+0x50>
add    $0x1,%r12
add    $0x1f48,%rbx
add    $0xffffffffffffffff,%r13
cmp    (%rsp),%r12
jne    1163 <isSymmetric+0x43>
jmp    11ae <isSymmetric+0x8e>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @isSymmetric(i32 %0, [1000 x double]* %1) {
%3 = alloca i32
%4 = alloca [1000 x double]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store [1000 x double]* %1, [1000 x double]** %4
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 1000
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i32 1, i32* %5
store i32 1, i32* %6
br label %12
12: ; preds = %51, %2
%13 = load i32, i32* %6
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %54
16: ; preds = %12
%17 = load i32, i32* %6
store i32 %17, i32* %7
br label %18
18: ; preds = %43, %16
%19 = load i32, i32* %7
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %46
22: ; preds = %18
%23 = load [1000 x double]*, [1000 x double]** %4
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [1000 x double], [1000 x double]* %23, i64 %25
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1000 x double], [1000 x double]* %26, i64 0, i64 %28
%30 = load double, double* %29
%31 = load [1000 x double]*, [1000 x double]** %4
%32 = load i32, i32* %7
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1000 x double], [1000 x double]* %31, i64 %33
%35 = load i32, i32* %6
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [1000 x double], [1000 x double]* %34, i64 0, i64 %36
%38 = load double, double* %37
%39 = call i32 @equals(double %30, double %38)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %22
store i32 0, i32* %5
br label %46
42: ; preds = %22
br label %43
43: ; preds = %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %18
46: ; preds = %41, %18
%47 = load i32, i32* %5
%48 = icmp ne i32 %47, 0
br i1 %48, label %50, label %49
49: ; preds = %46
br label %54
50: ; preds = %46
br label %51
51: ; preds = %50
%52 = load i32, i32* %6
%53 = add nsw i32 %52, 1
store i32 %53, i32* %6
br label %12
54: ; preds = %49, %12
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
define i32 @isSymmetric(i32 %0, [1000 x double]* nocapture %1) {
%3 = icmp slt i32 %0, 1000
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %25
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %9
9: ; preds = %22, %7
%10 = phi i64 [ 1, %7 ], [ %23, %22 ]
br label %13
11: ; preds = %13
%12 = icmp eq i64 %21, %8
br i1 %12, label %22, label %13
13: ; preds = %9, %11
%14 = phi i64 [ %10, %9 ], [ %21, %11 ]
%15 = getelementptr inbounds [1000 x double], [1000 x double]* %1, i64 %10, i64 %14
%16 = load double, double* %15
%17 = getelementptr inbounds [1000 x double], [1000 x double]* %1, i64 %14, i64 %10
%18 = load double, double* %17
%19 = tail call i32 @equals(double %16, double %18)
%20 = icmp eq i32 %19, 0
%21 = add nuw nsw i64 %14, 1
br i1 %20, label %25, label %11
22: ; preds = %11
%23 = add nuw nsw i64 %10, 1
%24 = icmp eq i64 %23, %8
br i1 %24, label %25, label %9
25: ; preds = %22, %13, %2
%26 = phi i32 [ 1, %2 ], [ 0, %13 ], [ 1, %22 ]
ret i32 %26
}