#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 */
scalar_t__ fabs(double);
double stdlib_strided_dapxsumkbn2(const int64_t N, const double alpha,
                                  const double *X, const int64_t stride) {
  double sum;
  double ccs;
  int64_t ix;
  int64_t i;
  double cs;
  double cc;
  double v;
  double t;
  double c;
  if (N <= 0) {
    return 0.0;
  }
  if (N == 1 || stride == 0) {
    return alpha + X[0];
  }
  if (stride < 0) {
    ix = (1 - N) * stride;
  } else {
    ix = 0;
  }
  sum = 0.0;
  ccs = 0.0;
  cs = 0.0;
  for (i = 0; i < N; i++) {
    v = alpha + X[ix];
    t = sum + v;
    if (fabs(sum) >= fabs(v)) {
      c = (sum - t) + v;
    } else {
      c = (v - t) + sum;
    }
    sum = t;
    t = cs + c;
    if (fabs(cs) >= fabs(c)) {
      cc = (cs - t) + c;
    } else {
      cc = (c - t) + cs;
    }
    cs = t;
    ccs += cc;
    ix += stride;
  }
  return sum + cs + ccs;
}


x86 assembly (clang, -O0):
<stdlib_strided_dapxsumkbn2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jg     1144 <stdlib_strided_dapxsumkbn2+0x34>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <stdlib_strided_dapxsumkbn2+0x1ec>
cmpq   $0x1,-0x10(%rbp)
je     115a <stdlib_strided_dapxsumkbn2+0x4a>
cmpq   $0x0,-0x28(%rbp)
jne    1171 <stdlib_strided_dapxsumkbn2+0x61>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fc <stdlib_strided_dapxsumkbn2+0x1ec>
cmpq   $0x0,-0x28(%rbp)
jge    1193 <stdlib_strided_dapxsumkbn2+0x83>
mov    $0x1,%eax
sub    -0x10(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    119b <stdlib_strided_dapxsumkbn2+0x8b>
movq   $0x0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    12e8 <stdlib_strided_dapxsumkbn2+0x1d8>
movsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
addsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x30(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x78(%rbp)
movsd  -0x60(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
cmp    %rcx,%rax
jl     1230 <stdlib_strided_dapxsumkbn2+0x120>
movsd  -0x30(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
jmp    1244 <stdlib_strided_dapxsumkbn2+0x134>
movsd  -0x60(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x50(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x80(%rbp)
movsd  -0x70(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x80(%rbp),%rax
cmp    %rcx,%rax
jl     129e <stdlib_strided_dapxsumkbn2+0x18e>
movsd  -0x50(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    12b2 <stdlib_strided_dapxsumkbn2+0x1a2>
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x28(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11bb <stdlib_strided_dapxsumkbn2+0xab>
movsd  -0x30(%rbp),%xmm0
addsd  -0x50(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dapxsumkbn2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %rdi,%rdi
jle    128b <stdlib_strided_dapxsumkbn2+0x17b>
mov    %rdi,%r15
cmp    $0x1,%rdi
je     1291 <stdlib_strided_dapxsumkbn2+0x181>
mov    %rdx,%r14
test   %rdx,%rdx
je     1291 <stdlib_strided_dapxsumkbn2+0x181>
mov    $0x1,%eax
sub    %r15,%rax
imul   %r14,%rax
mov    %r14,%rcx
sar    $0x3f,%rcx
and    %rax,%rcx
lea    (%rsi,%rcx,8),%r12
shl    $0x3,%r14
xorpd  %xmm3,%xmm3
xorpd  %xmm1,%xmm1
xorpd  %xmm4,%xmm4
xorpd  %xmm2,%xmm2
movsd  %xmm0,0x28(%rsp)
jmp    11c1 <stdlib_strided_dapxsumkbn2+0xb1>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x8(%rsp),%xmm5
movsd  0x18(%rsp),%xmm3
subsd  %xmm5,%xmm3
addsd  0x10(%rsp),%xmm3
movsd  0x28(%rsp),%xmm0
movsd  0x30(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
addsd  %xmm3,%xmm1
add    %r14,%r12
movapd %xmm5,%xmm3
movapd %xmm2,%xmm4
add    $0xffffffffffffffff,%r15
je     1297 <stdlib_strided_dapxsumkbn2+0x187>
movsd  %xmm3,0x18(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  (%r12),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  %xmm4,0x10(%rsp)
movapd %xmm4,%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jl     1220 <stdlib_strided_dapxsumkbn2+0x110>
movsd  0x10(%rsp),%xmm1
subsd  0x20(%rsp),%xmm1
addsd  0x8(%rsp),%xmm1
jmp    1236 <stdlib_strided_dapxsumkbn2+0x126>
nopl   (%rax)
movsd  0x8(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x18(%rsp),%xmm0
movsd  %xmm1,0x10(%rsp)
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x10(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    1180 <stdlib_strided_dapxsumkbn2+0x70>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm5
subsd  %xmm5,%xmm0
movsd  0x18(%rsp),%xmm3
addsd  %xmm0,%xmm3
jmp    1196 <stdlib_strided_dapxsumkbn2+0x86>
xorpd  %xmm0,%xmm0
jmp    12a3 <stdlib_strided_dapxsumkbn2+0x193>
addsd  (%rsi),%xmm0
jmp    12a3 <stdlib_strided_dapxsumkbn2+0x193>
addsd  %xmm5,%xmm2
addsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @stdlib_strided_dapxsumkbn2(i64 %0, double %1, double* %2, i64 %3) {
%5 = alloca double
%6 = alloca i64
%7 = alloca double
%8 = alloca double*
%9 = alloca i64
%10 = alloca double
%11 = alloca double
%12 = alloca i64
%13 = alloca i64
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
store i64 %0, i64* %6
store double %1, double* %7
store double* %2, double** %8
store i64 %3, i64* %9
%19 = load i64, i64* %6
%20 = icmp sle i64 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %4
store double 0.000000e+00, double* %5
br label %114
22: ; preds = %4
%23 = load i64, i64* %6
%24 = icmp eq i64 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i64, i64* %9
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25, %22
%29 = load double, double* %7
%30 = load double*, double** %8
%31 = getelementptr inbounds double, double* %30, i64 0
%32 = load double, double* %31
%33 = fadd double %29, %32
store double %33, double* %5
br label %114
34: ; preds = %25
%35 = load i64, i64* %9
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load i64, i64* %6
%39 = sub nsw i64 1, %38
%40 = load i64, i64* %9
%41 = mul nsw i64 %39, %40
store i64 %41, i64* %12
br label %43
42: ; preds = %34
store i64 0, i64* %12
br label %43
43: ; preds = %42, %37
store double 0.000000e+00, double* %10
store double 0.000000e+00, double* %11
store double 0.000000e+00, double* %14
store i64 0, i64* %13
br label %44
44: ; preds = %105, %43
%45 = load i64, i64* %13
%46 = load i64, i64* %6
%47 = icmp slt i64 %45, %46
br i1 %47, label %48, label %108
48: ; preds = %44
%49 = load double, double* %7
%50 = load double*, double** %8
%51 = load i64, i64* %12
%52 = getelementptr inbounds double, double* %50, i64 %51
%53 = load double, double* %52
%54 = fadd double %49, %53
store double %54, double* %16
%55 = load double, double* %10
%56 = load double, double* %16
%57 = fadd double %55, %56
store double %57, double* %17
%58 = load double, double* %10
%59 = call i64 @fabs(double %58)
%60 = load double, double* %16
%61 = call i64 @fabs(double %60)
%62 = icmp sge i64 %59, %61
br i1 %62, label %63, label %69
63: ; preds = %48
%64 = load double, double* %10
%65 = load double, double* %17
%66 = fsub double %64, %65
%67 = load double, double* %16
%68 = fadd double %66, %67
store double %68, double* %18
br label %75
69: ; preds = %48
%70 = load double, double* %16
%71 = load double, double* %17
%72 = fsub double %70, %71
%73 = load double, double* %10
%74 = fadd double %72, %73
store double %74, double* %18
br label %75
75: ; preds = %69, %63
%76 = load double, double* %17
store double %76, double* %10
%77 = load double, double* %14
%78 = load double, double* %18
%79 = fadd double %77, %78
store double %79, double* %17
%80 = load double, double* %14
%81 = call i64 @fabs(double %80)
%82 = load double, double* %18
%83 = call i64 @fabs(double %82)
%84 = icmp sge i64 %81, %83
br i1 %84, label %85, label %91
85: ; preds = %75
%86 = load double, double* %14
%87 = load double, double* %17
%88 = fsub double %86, %87
%89 = load double, double* %18
%90 = fadd double %88, %89
store double %90, double* %15
br label %97
91: ; preds = %75
%92 = load double, double* %18
%93 = load double, double* %17
%94 = fsub double %92, %93
%95 = load double, double* %14
%96 = fadd double %94, %95
store double %96, double* %15
br label %97
97: ; preds = %91, %85
%98 = load double, double* %17
store double %98, double* %14
%99 = load double, double* %15
%100 = load double, double* %11
%101 = fadd double %100, %99
store double %101, double* %11
%102 = load i64, i64* %9
%103 = load i64, i64* %12
%104 = add nsw i64 %103, %102
store i64 %104, i64* %12
br label %105
105: ; preds = %97
%106 = load i64, i64* %13
%107 = add nsw i64 %106, 1
store i64 %107, i64* %13
br label %44
108: ; preds = %44
%109 = load double, double* %10
%110 = load double, double* %14
%111 = fadd double %109, %110
%112 = load double, double* %11
%113 = fadd double %111, %112
store double %113, double* %5
br label %114
114: ; preds = %108, %28, %21
%115 = load double, double* %5
ret double %115
}

LLVM IR (-O2):
define double @stdlib_strided_dapxsumkbn2(i64 %0, double %1, double* nocapture %2, i64 %3) {
%5 = icmp slt i64 %0, 1
br i1 %5, label %52, label %6
6: ; preds = %4
%7 = icmp eq i64 %0, 1
%8 = icmp eq i64 %3, 0
%9 = or i1 %7, %8
br i1 %9, label %10, label %13
10: ; preds = %6
%11 = load double, double* %2
%12 = fadd double %11, %1
br label %52
13: ; preds = %6
%14 = icmp slt i64 %3, 0
%15 = sub nsw i64 1, %0
%16 = mul nsw i64 %15, %3
%17 = select i1 %14, i64 %16, i64 0
br label %18
18: ; preds = %13, %18
%19 = phi double [ %36, %18 ], [ 0.000000e+00, %13 ]
%20 = phi i64 [ %47, %18 ], [ 0, %13 ]
%21 = phi i64 [ %46, %18 ], [ %17, %13 ]
%22 = phi double [ %45, %18 ], [ 0.000000e+00, %13 ]
%23 = phi double [ %27, %18 ], [ 0.000000e+00, %13 ]
%24 = getelementptr inbounds double, double* %2, i64 %21
%25 = load double, double* %24
%26 = fadd double %25, %1
%27 = fadd double %23, %26
%28 = tail call i64 @fabs(double %23)
%29 = tail call i64 @fabs(double %26)
%30 = icmp slt i64 %28, %29
%31 = fsub double %23, %27
%32 = fadd double %26, %31
%33 = fsub double %26, %27
%34 = fadd double %23, %33
%35 = select i1 %30, double %34, double %32
%36 = fadd double %19, %35
%37 = tail call i64 @fabs(double %19)
%38 = tail call i64 @fabs(double %35)
%39 = icmp slt i64 %37, %38
%40 = fsub double %19, %36
%41 = fadd double %35, %40
%42 = fsub double %35, %36
%43 = fadd double %19, %42
%44 = select i1 %39, double %43, double %41
%45 = fadd double %22, %44
%46 = add nsw i64 %21, %3
%47 = add nuw nsw i64 %20, 1
%48 = icmp eq i64 %47, %0
br i1 %48, label %49, label %18
49: ; preds = %18
%50 = fadd double %27, %36
%51 = fadd double %45, %50
br label %52
52: ; preds = %4, %49, %10
%53 = phi double [ %12, %10 ], [ %51, %49 ], [ 0.000000e+00, %4 ]
ret double %53
}