#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char const *);
scalar_t__ isinf(double);
scalar_t__ isnan(double);
int /*<<< orphan*/ stderr;
void checkNoNans(size_t n, double *buff, const char *err_msg) {
  size_t i;
  for (i = 0; i < n; i++)
    if (isnan(buff[i]) || isinf(buff[i])) {
      fprintf(stderr, err_msg);
      exit(EXIT_FAILURE);
    }
}


x86 assembly (clang, -O0):
<checkNoNans>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x8(%rbp),%rax
jae    11d8 <checkNoNans+0x98>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1040 <isnan@plt>
cmp    $0x0,%rax
jne    11a2 <checkNoNans+0x62>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1060 <isinf@plt>
cmp    $0x0,%rax
je     11c2 <checkNoNans+0x82>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
call   1030 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>
jmp    11c7 <checkNoNans+0x87>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <checkNoNans+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkNoNans>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %rdi,%rdi
je     1189 <checkNoNans+0x49>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  (%r12,%rbx,8),%xmm0
call   1040 <isnan@plt>
test   %rax,%rax
jne    1195 <checkNoNans+0x55>
movsd  (%r12,%rbx,8),%xmm0
call   1060 <isinf@plt>
test   %rax,%rax
jne    1195 <checkNoNans+0x55>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1160 <checkNoNans+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1030 <fprintf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
define void @checkNoNans(i64 %0, double* %1, i8* %2) {
%4 = alloca i64
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i64
store i64 %0, i64* %4
store double* %1, double** %5
store i8* %2, i8** %6
store i64 0, i64* %7
br label %8
8: ; preds = %33, %3
%9 = load i64, i64* %7
%10 = load i64, i64* %4
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %36
12: ; preds = %8
%13 = load double*, double** %5
%14 = load i64, i64* %7
%15 = getelementptr inbounds double, double* %13, i64 %14
%16 = load double, double* %15
%17 = call i64 @isnan(double %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %12
%20 = load double*, double** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds double, double* %20, i64 %21
%23 = load double, double* %22
%24 = call i64 @isinf(double %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %19, %12
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %6
%29 = call i32 @fprintf(i32 %27, i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %19
br label %33
33: ; preds = %32
%34 = load i64, i64* %7
%35 = add i64 %34, 1
store i64 %35, i64* %7
br label %8
36: ; preds = %8
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
define void @checkNoNans(i64 %0, double* nocapture %1, i8* %2) {
%4 = icmp eq i64 %0, 0
br i1 %4, label %23, label %7
5: ; preds = %13
%6 = icmp eq i64 %17, %0
br i1 %6, label %23, label %7
7: ; preds = %3, %5
%8 = phi i64 [ %17, %5 ], [ 0, %3 ]
%9 = getelementptr inbounds double, double* %1, i64 %8
%10 = load double, double* %9
%11 = tail call i64 @isnan(double %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = load double, double* %9
%15 = tail call i64 @isinf(double %14)
%16 = icmp eq i64 %15, 0
%17 = add nuw i64 %8, 1
br i1 %16, label %5, label %18
18: ; preds = %13, %7
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* %2)
%21 = load i32, i32* @EXIT_FAILURE
%22 = tail call i32 @exit(i32 %21)
unreachable
23: ; preds = %5, %3
ret void
}