#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 int int64_t;

/* Variables and functions */
double stdlib_strided_dapxsumpw(int const, double, double const *, int const);
double stdlib_strided_dsumpw(int const, double const *, int const);
double stdlib_strided_dmeanpn(const int64_t N, const double *X,
                              const int64_t stride) {
  double dN;
  double mu;
  double c;
  if (N <= 0) {
    return 0.0 / 0.0;
  }
  if (N == 1 || stride == 0) {
    return X[0];
  }
  dN = (double)N;
  mu = stdlib_strided_dsumpw(N, X, stride);
  mu /= dN;
  c = stdlib_strided_dapxsumpw(N, -mu, X, stride);
  c /= dN;
  return mu + c;
}


x86 assembly (clang, -O0):
<stdlib_strided_dmeanpn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     114e <stdlib_strided_dmeanpn+0x2e>
movsd  0xebc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f7 <stdlib_strided_dmeanpn+0xd7>
cmpl   $0x1,-0xc(%rbp)
je     1162 <stdlib_strided_dmeanpn+0x42>
cmpl   $0x0,-0x1c(%rbp)
jne    1174 <stdlib_strided_dmeanpn+0x54>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11f7 <stdlib_strided_dmeanpn+0xd7>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <stdlib_strided_dsumpw@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0xc(%rbp),%edi
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <stdlib_strided_dapxsumpw@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dmeanpn>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    1188 <stdlib_strided_dmeanpn+0x68>
mov    %rsi,%r14
mov    %edi,%ebp
cmp    $0x1,%edi
je     1192 <stdlib_strided_dmeanpn+0x72>
mov    %edx,%ebx
test   %edx,%edx
je     1192 <stdlib_strided_dmeanpn+0x72>
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <stdlib_strided_dsumpw@plt>
movapd %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
movapd %xmm1,0x10(%rsp)
movapd 0xea6(%rip),%xmm0
xorpd  %xmm1,%xmm0
mov    %ebp,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1030 <stdlib_strided_dapxsumpw@plt>
divsd  0x8(%rsp),%xmm0
addsd  0x10(%rsp),%xmm0
jmp    1197 <stdlib_strided_dmeanpn+0x77>
movsd  0xe70(%rip),%xmm0
jmp    1197 <stdlib_strided_dmeanpn+0x77>
movsd  (%r14),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define double @stdlib_strided_dmeanpn(i32 %0, double* %1, i32 %2) {
%4 = alloca double
%5 = alloca i32
%6 = alloca double*
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
store i32 %0, i32* %5
store double* %1, double** %6
store i32 %2, i32* %7
%11 = load i32, i32* %5
%12 = icmp sle i32 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store double 0x7FF8000000000000, double* %4
br label %46
14: ; preds = %3
%15 = load i32, i32* %5
%16 = icmp eq i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = load i32, i32* %7
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %17, %14
%21 = load double*, double** %6
%22 = getelementptr inbounds double, double* %21, i64 0
%23 = load double, double* %22
store double %23, double* %4
br label %46
24: ; preds = %17
%25 = load i32, i32* %5
%26 = sitofp i32 %25 to double
store double %26, double* %8
%27 = load i32, i32* %5
%28 = load double*, double** %6
%29 = load i32, i32* %7
%30 = call double @stdlib_strided_dsumpw(i32 %27, double* %28, i32 %29)
store double %30, double* %9
%31 = load double, double* %8
%32 = load double, double* %9
%33 = fdiv double %32, %31
store double %33, double* %9
%34 = load i32, i32* %5
%35 = load double, double* %9
%36 = fneg double %35
%37 = load double*, double** %6
%38 = load i32, i32* %7
%39 = call double @stdlib_strided_dapxsumpw(i32 %34, double %36, double* %37, i32 %38)
store double %39, double* %10
%40 = load double, double* %8
%41 = load double, double* %10
%42 = fdiv double %41, %40
store double %42, double* %10
%43 = load double, double* %9
%44 = load double, double* %10
%45 = fadd double %43, %44
store double %45, double* %4
br label %46
46: ; preds = %24, %20, %13
%47 = load double, double* %4
ret double %47
}

LLVM IR (-O2):
define double @stdlib_strided_dmeanpn(i32 %0, double* %1, i32 %2) {
%4 = icmp slt i32 %0, 1
br i1 %4, label %19, label %5
5: ; preds = %3
%6 = icmp eq i32 %0, 1
%7 = icmp eq i32 %2, 0
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = load double, double* %1
br label %19
11: ; preds = %5
%12 = sitofp i32 %0 to double
%13 = tail call double @stdlib_strided_dsumpw(i32 %0, double* %1, i32 %2)
%14 = fdiv double %13, %12
%15 = fneg double %14
%16 = tail call double @stdlib_strided_dapxsumpw(i32 %0, double %15, double* %1, i32 %2)
%17 = fdiv double %16, %12
%18 = fadd double %14, %17
br label %19
19: ; preds = %3, %11, %9
%20 = phi double [ %10, %9 ], [ %18, %11 ], [ 0x7FF8000000000000, %3 ]
ret double %20
}