#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 */
scalar_t__ isnan(double);
int any_NaN(double *A, int n, int L) {
  int i;
  for (i = 0; i < n * L; i++) {
    if (isnan(A[i]))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<any_NaN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
imul   -0x18(%rbp),%ecx
cmp    %ecx,%eax
jge    1176 <any_NaN+0x66>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1163 <any_NaN+0x53>
movl   $0x1,-0x4(%rbp)
jmp    117d <any_NaN+0x6d>
jmp    1168 <any_NaN+0x58>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1129 <any_NaN+0x19>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<any_NaN>:
push   %r15
push   %r14
push   %rbx
imul   %edx,%esi
test   %esi,%esi
jle    1149 <any_NaN+0x39>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r14,%rbx,8),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
jne    114d <any_NaN+0x3d>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <any_NaN+0x20>
xor    %eax,%eax
jmp    1152 <any_NaN+0x42>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @any_NaN(double* nocapture %0, i32 %1, i32 %2) {
%4 = mul i32 %2, %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %3
%7 = zext i32 %4 to i64
br label %10
8: ; preds = %10
%9 = icmp eq i64 %16, %7
br i1 %9, label %17, label %10
10: ; preds = %6, %8
%11 = phi i64 [ 0, %6 ], [ %16, %8 ]
%12 = getelementptr inbounds double, double* %0, i64 %11
%13 = load double, double* %12
%14 = tail call i64 @isnan(double %13)
%15 = icmp eq i64 %14, 0
%16 = add nuw nsw i64 %11, 1
br i1 %15, label %8, label %17
17: ; preds = %10, %8, %3
%18 = phi i32 [ 0, %3 ], [ 0, %8 ], [ 1, %10 ]
ret i32 %18
}