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


x86 assembly (clang, -O0):
<check_mat>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    117c <check_mat+0x6c>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
add    -0x18(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1169 <check_mat+0x59>
movl   $0x1,-0x4(%rbp)
jmp    1183 <check_mat+0x73>
jmp    116e <check_mat+0x5e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112c <check_mat+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_mat>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
test   %esi,%esi
jle    114f <check_mat+0x3f>
movslq %ecx,%r15
movslq %edx,%rax
mov    %esi,%ebp
lea    (%rdi,%rax,8),%rbx
shl    $0x3,%r15
xchg   %ax,%ax
movsd  (%rbx),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
jne    1149 <check_mat+0x39>
add    %r15,%rbx
add    $0xffffffffffffffff,%rbp
jne    1130 <check_mat+0x20>
jmp    114f <check_mat+0x3f>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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