#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);
bool hasZeroDiagonal(const int patternSize, const double W[][1000]) {
  assert(patternSize < 1000);
  bool hasZD = true;
  for (int i = 0; i < patternSize; i++) {
    if (!equals(W[i][i], 0.0)) {
      hasZD = false;
      break;
    }
  }
  return hasZD;
}


x86 assembly (clang, -O0):
<hasZeroDiagonal>:
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   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a8 <hasZeroDiagonal+0x88>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   $0x1f40,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
xorps  %xmm1,%xmm1
call   1040 <equals@plt>
cmp    $0x0,%eax
jne    1195 <hasZeroDiagonal+0x75>
movl   $0x0,-0x14(%rbp)
jmp    11a8 <hasZeroDiagonal+0x88>
jmp    119a <hasZeroDiagonal+0x7a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1151 <hasZeroDiagonal+0x31>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hasZeroDiagonal>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x3e8,%ebp
setl   %dil
call   1030 <assert@plt>
mov    $0x1,%r14d
test   %ebp,%ebp
jle    1183 <hasZeroDiagonal+0x63>
mov    %ebp,%eax
imul   $0x1f48,%rax,%rbp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  (%r15,%rbx,1),%xmm0
xorps  %xmm1,%xmm1
call   1040 <equals@plt>
test   %eax,%eax
je     1180 <hasZeroDiagonal+0x60>
add    $0x1f48,%rbx
cmp    %rbx,%rbp
jne    1160 <hasZeroDiagonal+0x40>
jmp    1183 <hasZeroDiagonal+0x63>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @hasZeroDiagonal(i32 %0, [1000 x double]* %1) {
%3 = alloca i32
%4 = alloca [1000 x double]*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store [1000 x double]* %1, [1000 x double]** %4
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 1000
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
store i32 1, i32* %5
store i32 0, i32* %6
br label %11
11: ; preds = %28, %2
%12 = load i32, i32* %6
%13 = load i32, i32* %3
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %31
15: ; preds = %11
%16 = load [1000 x double]*, [1000 x double]** %4
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [1000 x double], [1000 x double]* %16, i64 %18
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [1000 x double], [1000 x double]* %19, i64 0, i64 %21
%23 = load double, double* %22
%24 = call i32 @equals(double %23, double 0.000000e+00)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %15
store i32 0, i32* %5
br label %31
27: ; preds = %15
br label %28
28: ; preds = %27
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %11
31: ; preds = %26, %11
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @hasZeroDiagonal(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, 0
br i1 %6, label %7, label %18
7: ; preds = %2
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %17, %8
br i1 %10, label %18, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %17, %9 ]
%13 = getelementptr inbounds [1000 x double], [1000 x double]* %1, i64 %12, i64 %12
%14 = load double, double* %13
%15 = tail call i32 @equals(double %14, double 0.000000e+00)
%16 = icmp eq i32 %15, 0
%17 = add nuw nsw i64 %12, 1
br i1 %16, label %18, label %9
18: ; preds = %9, %11, %2
%19 = phi i32 [ 1, %2 ], [ 0, %11 ], [ 1, %9 ]
ret i32 %19
}