#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 stdlib_strided_dapxsumpw(scalar_t__ const, double const, double const *,
                                scalar_t__ const);
double stdlib_strided_dmeanlipw(const int64_t N, const double *X,
                                const int64_t stride) {
  int64_t ix;
  if (N <= 0) {
    return 0.0 / 0.0;
  }
  if (N == 1 || stride == 0) {
    return X[0];
  }
  if (stride < 0) {
    ix = (1 - N) * stride;
  } else {
    ix = 0;
  }
  return X[ix] + (stdlib_strided_dapxsumpw(
                      N - 1, -X[ix], X + ((stride > 0) ? stride : 0), stride) /
                  (double)N);
}


x86 assembly (clang, -O0):
<stdlib_strided_dmeanlipw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     1141 <stdlib_strided_dmeanlipw+0x31>
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1241 <stdlib_strided_dmeanlipw+0x131>
cmpq   $0x1,-0x10(%rbp)
je     1157 <stdlib_strided_dmeanlipw+0x47>
cmpq   $0x0,-0x20(%rbp)
jne    1169 <stdlib_strided_dmeanlipw+0x59>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1241 <stdlib_strided_dmeanlipw+0x131>
cmpq   $0x0,-0x20(%rbp)
jge    118b <stdlib_strided_dmeanlipw+0x7b>
mov    $0x1,%eax
sub    -0x10(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    1193 <stdlib_strided_dmeanlipw+0x83>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x10(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
jle    11fa <stdlib_strided_dmeanlipw+0xea>
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
jmp    1205 <stdlib_strided_dmeanlipw+0xf5>
xor    %eax,%eax
mov    %rax,-0x50(%rbp)
jmp    1205 <stdlib_strided_dmeanlipw+0xf5>
movsd  -0x38(%rbp),%xmm0
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x50(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%rdx
call   1030 <stdlib_strided_dapxsumpw@plt>
movaps %xmm0,%xmm1
movsd  -0x48(%rbp),%xmm0
cvtsi2sdq -0x10(%rbp),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dmeanlipw>:
push   %rbx
sub    $0x10,%rsp
test   %rdi,%rdi
jle    117d <stdlib_strided_dmeanlipw+0x6d>
mov    %rdi,%rbx
cmp    $0x1,%rdi
je     1187 <stdlib_strided_dmeanlipw+0x77>
test   %rdx,%rdx
je     1187 <stdlib_strided_dmeanlipw+0x77>
mov    $0x1,%eax
sub    %rbx,%rax
imul   %rdx,%rax
mov    %rdx,%rcx
sar    $0x3f,%rcx
and    %rax,%rcx
movsd  (%rsi,%rcx,8),%xmm1
movapd %xmm1,(%rsp)
lea    -0x1(%rbx),%rdi
movapd 0xebc(%rip),%xmm0
xorpd  %xmm1,%xmm0
xor    %eax,%eax
test   %rdx,%rdx
cmovns %rdx,%rax
lea    (%rsi,%rax,8),%rsi
call   1030 <stdlib_strided_dapxsumpw@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %rbx,%xmm1
divsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
jmp    118b <stdlib_strided_dmeanlipw+0x7b>
movsd  0xe7b(%rip),%xmm0
jmp    118b <stdlib_strided_dmeanlipw+0x7b>
movsd  (%rsi),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @stdlib_strided_dmeanlipw(i64 %0, double* %1, i64 %2) {
%4 = alloca double
%5 = alloca i64
%6 = alloca double*
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store double* %1, double** %6
store i64 %2, i64* %7
%9 = load i64, i64* %5
%10 = icmp sle i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store double 0x7FF8000000000000, double* %4
br label %58
12: ; preds = %3
%13 = load i64, i64* %5
%14 = icmp eq i64 %13, 1
br i1 %14, label %18, label %15
15: ; preds = %12
%16 = load i64, i64* %7
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15, %12
%19 = load double*, double** %6
%20 = getelementptr inbounds double, double* %19, i64 0
%21 = load double, double* %20
store double %21, double* %4
br label %58
22: ; preds = %15
%23 = load i64, i64* %7
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i64, i64* %5
%27 = sub nsw i64 1, %26
%28 = load i64, i64* %7
%29 = mul nsw i64 %27, %28
store i64 %29, i64* %8
br label %31
30: ; preds = %22
store i64 0, i64* %8
br label %31
31: ; preds = %30, %25
%32 = load double*, double** %6
%33 = load i64, i64* %8
%34 = getelementptr inbounds double, double* %32, i64 %33
%35 = load double, double* %34
%36 = load i64, i64* %5
%37 = sub nsw i64 %36, 1
%38 = load double*, double** %6
%39 = load i64, i64* %8
%40 = getelementptr inbounds double, double* %38, i64 %39
%41 = load double, double* %40
%42 = fneg double %41
%43 = load double*, double** %6
%44 = load i64, i64* %7
%45 = icmp sgt i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %31
%47 = load i64, i64* %7
br label %49
48: ; preds = %31
br label %49
49: ; preds = %48, %46
%50 = phi i64 [ %47, %46 ], [ 0, %48 ]
%51 = getelementptr inbounds double, double* %43, i64 %50
%52 = load i64, i64* %7
%53 = call double @stdlib_strided_dapxsumpw(i64 %37, double %42, double* %51, i64 %52)
%54 = load i64, i64* %5
%55 = sitofp i64 %54 to double
%56 = fdiv double %53, %55
%57 = fadd double %35, %56
store double %57, double* %4
br label %58
58: ; preds = %49, %18, %11
%59 = load double, double* %4
ret double %59
}

LLVM IR (-O2):
define double @stdlib_strided_dmeanlipw(i64 %0, double* %1, i64 %2) {
%4 = icmp slt i64 %0, 1
br i1 %4, label %27, 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 %11
9: ; preds = %5
%10 = load double, double* %1
br label %27
11: ; preds = %5
%12 = icmp slt i64 %2, 0
%13 = sub nsw i64 1, %0
%14 = mul nsw i64 %13, %2
%15 = select i1 %12, i64 %14, i64 0
%16 = getelementptr inbounds double, double* %1, i64 %15
%17 = load double, double* %16
%18 = add nsw i64 %0, -1
%19 = fneg double %17
%20 = icmp sgt i64 %2, 0
%21 = select i1 %20, i64 %2, i64 0
%22 = getelementptr inbounds double, double* %1, i64 %21
%23 = tail call double @stdlib_strided_dapxsumpw(i64 %18, double %19, double* %22, i64 %2)
%24 = sitofp i64 %0 to double
%25 = fdiv double %23, %24
%26 = fadd double %17, %25
br label %27
27: ; preds = %3, %11, %9
%28 = phi double [ %10, %9 ], [ %26, %11 ], [ 0x7FF8000000000000, %3 ]
ret double %28
}