#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 */
typedef scalar_t__ int64_t;

/* Variables and functions */
double fabs(double const);
scalar_t__ stdlib_base_is_nan(double const);
double stdlib_strided_dnanasumors(const int64_t N, const double *X,
                                  const int64_t stride) {
  double sum;
  int64_t ix;
  int64_t i;
  double v;
  if (N <= 0) {
    return 0.0;
  }
  if (N == 1 || stride == 0) {
    if (stdlib_base_is_nan(X[0])) {
      return 0.0;
    }
    return fabs(X[0]);
  }
  if (stride < 0) {
    ix = (1 - N) * stride;
  } else {
    ix = 0;
  }
  sum = 0.0;
  for (i = 0; i < N; i++) {
    v = X[ix];
    if (!stdlib_base_is_nan(v)) {
      sum += fabs(v);
    }
    ix += stride;
  }
  return sum;
}


x86 assembly (clang, -O0):
<stdlib_strided_dnanasumors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     113c <stdlib_strided_dnanasumors+0x2c>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1242 <stdlib_strided_dnanasumors+0x132>
cmpq   $0x1,-0x10(%rbp)
je     1152 <stdlib_strided_dnanasumors+0x42>
cmpq   $0x0,-0x20(%rbp)
jne    1193 <stdlib_strided_dnanasumors+0x83>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
call   1030 <stdlib_base_is_nan@plt>
cmp    $0x0,%rax
je     1176 <stdlib_strided_dnanasumors+0x66>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1242 <stdlib_strided_dnanasumors+0x132>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe7b(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1242 <stdlib_strided_dnanasumors+0x132>
cmpq   $0x0,-0x20(%rbp)
jge    11b5 <stdlib_strided_dnanasumors+0xa5>
mov    $0x1,%eax
sub    -0x10(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
jmp    11bd <stdlib_strided_dnanasumors+0xad>
movq   $0x0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    1238 <stdlib_strided_dnanasumors+0x128>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1030 <stdlib_base_is_nan@plt>
cmp    $0x0,%rax
jne    121b <stdlib_strided_dnanasumors+0x10b>
movsd  -0x40(%rbp),%xmm0
movaps 0xdf3(%rip),%xmm1
pand   %xmm1,%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11cd <stdlib_strided_dnanasumors+0xbd>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dnanasumors>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
xorpd  %xmm0,%xmm0
test   %rdi,%rdi
jle    11c4 <stdlib_strided_dnanasumors+0xb4>
mov    %rsi,%r15
mov    %rdi,%r12
cmp    $0x1,%rdi
je     11a4 <stdlib_strided_dnanasumors+0x94>
mov    %rdx,%r14
test   %rdx,%rdx
je     11a4 <stdlib_strided_dnanasumors+0x94>
mov    $0x1,%eax
sub    %r12,%rax
imul   %r14,%rax
mov    %r14,%rcx
sar    $0x3f,%rcx
and    %rax,%rcx
lea    (%r15,%rcx,8),%rbx
shl    $0x3,%r14
xorpd  %xmm0,%xmm0
jmp    117b <stdlib_strided_dnanasumors+0x6b>
movsd  0xea8(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
addsd  %xmm1,%xmm0
add    %r14,%rbx
add    $0xffffffffffffffff,%r12
je     11c4 <stdlib_strided_dnanasumors+0xb4>
movsd  %xmm0,0x8(%rsp)
movsd  (%rbx),%xmm0
movaps %xmm0,0x10(%rsp)
call   1030 <stdlib_base_is_nan@plt>
test   %rax,%rax
jne    1160 <stdlib_strided_dnanasumors+0x50>
movapd 0x10(%rsp),%xmm1
andpd  0xe5e(%rip),%xmm1
jmp    1168 <stdlib_strided_dnanasumors+0x58>
movsd  (%r15),%xmm0
call   1030 <stdlib_base_is_nan@plt>
xorpd  %xmm0,%xmm0
test   %rax,%rax
jne    11c4 <stdlib_strided_dnanasumors+0xb4>
movsd  (%r15),%xmm0
andpd  0xe3c(%rip),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @stdlib_strided_dnanasumors(i64 %0, double* %1, i64 %2) {
%4 = alloca double
%5 = alloca i64
%6 = alloca double*
%7 = alloca i64
%8 = alloca double
%9 = alloca i64
%10 = alloca i64
%11 = alloca double
store i64 %0, i64* %5
store double* %1, double** %6
store i64 %2, i64* %7
%12 = load i64, i64* %5
%13 = icmp sle i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %3
store double 0.000000e+00, double* %4
br label %69
15: ; preds = %3
%16 = load i64, i64* %5
%17 = icmp eq i64 %16, 1
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i64, i64* %7
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %33
21: ; preds = %18, %15
%22 = load double*, double** %6
%23 = getelementptr inbounds double, double* %22, i64 0
%24 = load double, double* %23
%25 = call i64 @stdlib_base_is_nan(double %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store double 0.000000e+00, double* %4
br label %69
28: ; preds = %21
%29 = load double*, double** %6
%30 = getelementptr inbounds double, double* %29, i64 0
%31 = load double, double* %30
%32 = call double @llvm.fabs.f64(double %31)
store double %32, double* %4
br label %69
33: ; preds = %18
%34 = load i64, i64* %7
%35 = icmp slt i64 %34, 0
br i1 %35, label %36, label %41
36: ; preds = %33
%37 = load i64, i64* %5
%38 = sub nsw i64 1, %37
%39 = load i64, i64* %7
%40 = mul nsw i64 %38, %39
store i64 %40, i64* %9
br label %42
41: ; preds = %33
store i64 0, i64* %9
br label %42
42: ; preds = %41, %36
store double 0.000000e+00, double* %8
store i64 0, i64* %10
br label %43
43: ; preds = %64, %42
%44 = load i64, i64* %10
%45 = load i64, i64* %5
%46 = icmp slt i64 %44, %45
br i1 %46, label %47, label %67
47: ; preds = %43
%48 = load double*, double** %6
%49 = load i64, i64* %9
%50 = getelementptr inbounds double, double* %48, i64 %49
%51 = load double, double* %50
store double %51, double* %11
%52 = load double, double* %11
%53 = call i64 @stdlib_base_is_nan(double %52)
%54 = icmp ne i64 %53, 0
br i1 %54, label %60, label %55
55: ; preds = %47
%56 = load double, double* %11
%57 = call double @llvm.fabs.f64(double %56)
%58 = load double, double* %8
%59 = fadd double %58, %57
store double %59, double* %8
br label %60
60: ; preds = %55, %47
%61 = load i64, i64* %7
%62 = load i64, i64* %9
%63 = add nsw i64 %62, %61
store i64 %63, i64* %9
br label %64
64: ; preds = %60
%65 = load i64, i64* %10
%66 = add nsw i64 %65, 1
store i64 %66, i64* %10
br label %43
67: ; preds = %43
%68 = load double, double* %8
store double %68, double* %4
br label %69
69: ; preds = %67, %28, %27, %14
%70 = load double, double* %4
ret double %70
}

LLVM IR (-O2):
define double @stdlib_strided_dnanasumors(i64 %0, double* nocapture %1, i64 %2) {
%4 = icmp slt i64 %0, 1
br i1 %4, label %35, label %5
5: ; preds = %3
%6 = icmp eq i64 %0, 1
%7 = icmp eq i64 %2, 0
%8 = or i1 %6, %7
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load double, double* %1
%11 = tail call i64 @stdlib_base_is_nan(double %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %35
13: ; preds = %9
%14 = load double, double* %1
%15 = tail call double @llvm.fabs.f64(double %14)
br label %35
16: ; preds = %5
%17 = icmp slt i64 %2, 0
%18 = sub nsw i64 1, %0
%19 = mul nsw i64 %18, %2
%20 = select i1 %17, i64 %19, i64 0
br label %21
21: ; preds = %16, %21
%22 = phi i64 [ %33, %21 ], [ 0, %16 ]
%23 = phi i64 [ %32, %21 ], [ %20, %16 ]
%24 = phi double [ %31, %21 ], [ 0.000000e+00, %16 ]
%25 = getelementptr inbounds double, double* %1, i64 %23
%26 = load double, double* %25
%27 = tail call i64 @stdlib_base_is_nan(double %26)
%28 = icmp eq i64 %27, 0
%29 = tail call double @llvm.fabs.f64(double %26)
%30 = select i1 %28, double %29, double -0.000000e+00
%31 = fadd double %24, %30
%32 = add nsw i64 %23, %2
%33 = add nuw nsw i64 %22, 1
%34 = icmp eq i64 %33, %0
br i1 %34, label %35, label %21
35: ; preds = %21, %9, %3, %13
%36 = phi double [ %15, %13 ], [ 0.000000e+00, %3 ], [ 0.000000e+00, %9 ], [ %31, %21 ]
ret double %36
}