#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);
void stdlib_strided_dcusumkbn2(const int64_t N, const double sum,
                               const double *X, const int64_t strideX,
                               double *Y, const int64_t strideY) {
  double ccs;
  int64_t ix;
  int64_t iy;
  int64_t i;
  double cs;
  double cc;
  double v;
  double t;
  double c;
  double s;
  if (N <= 0) {
    return;
  }
  if (strideX < 0) {
    ix = (1 - N) * strideX;
  } else {
    ix = 0;
  }
  if (strideY < 0) {
    iy = (1 - N) * strideY;
  } else {
    iy = 0;
  }
  s = sum;
  ccs = 0.0;
  cs = 0.0;
  for (i = 0; i < N; i++) {
    v = X[ix];
    t = s + v;
    if (fabs(s) >= fabs(v)) {
      c = (s - t) + v;
    } else {
      c = (v - t) + s;
    }
    s = t;
    t = cs + c;
    if (fabs(cs) >= fabs(c)) {
      cc = (cs - t) + c;
    } else {
      cc = (c - t) + cs;
    }
    cs = t;
    ccs += cc;
    Y[iy] = s + cs + ccs;
    ix += strideX;
    iy += strideY;
  }
  return;
}


x86 assembly (clang, -O0):
<stdlib_strided_dcusumkbn2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
cmpq   $0x0,-0x8(%rbp)
jg     1144 <stdlib_strided_dcusumkbn2+0x34>
jmp    131b <stdlib_strided_dcusumkbn2+0x20b>
cmpq   $0x0,-0x20(%rbp)
jge    1166 <stdlib_strided_dcusumkbn2+0x56>
mov    $0x1,%eax
sub    -0x8(%rbp),%rax
imul   -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
jmp    116e <stdlib_strided_dcusumkbn2+0x5e>
movq   $0x0,-0x40(%rbp)
cmpq   $0x0,-0x30(%rbp)
jge    1190 <stdlib_strided_dcusumkbn2+0x80>
mov    $0x1,%eax
sub    -0x8(%rbp),%rax
imul   -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1198 <stdlib_strided_dcusumkbn2+0x88>
movq   $0x0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movq   $0x0,-0x50(%rbp)
mov    -0x50(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    1316 <stdlib_strided_dcusumkbn2+0x206>
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x80(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x80(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x88(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
cmp    %rcx,%rax
jl     1230 <stdlib_strided_dcusumkbn2+0x120>
movsd  -0x80(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
jmp    1244 <stdlib_strided_dcusumkbn2+0x134>
movsd  -0x68(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
addsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x90(%rbp)
movsd  -0x78(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x90(%rbp),%rax
cmp    %rcx,%rax
jl     12a4 <stdlib_strided_dcusumkbn2+0x194>
movsd  -0x58(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
addsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    12b8 <stdlib_strided_dcusumkbn2+0x1a8>
movsd  -0x78(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x60(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x80(%rbp),%xmm0
addsd  -0x58(%rbp),%xmm0
addsd  -0x38(%rbp),%xmm0
mov    -0x28(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x20(%rbp),%rax
add    -0x40(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    11ba <stdlib_strided_dcusumkbn2+0xaa>
jmp    131b <stdlib_strided_dcusumkbn2+0x20b>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dcusumkbn2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
jle    1298 <stdlib_strided_dcusumkbn2+0x188>
mov    %r8,%r14
mov    %rdx,%r15
mov    %rdi,%r12
mov    $0x1,%eax
sub    %rdi,%rax
mov    %rax,%rdx
imul   %r8,%rdx
mov    %r8,%rdi
sar    $0x3f,%rdi
and    %rdx,%rdi
imul   %r15,%rax
mov    %r15,%rdx
sar    $0x3f,%rdx
and    %rax,%rdx
lea    (%rcx,%rdi,8),%r13
shl    $0x3,%r14
lea    (%rsi,%rdx,8),%rbp
shl    $0x3,%r15
xorpd  %xmm1,%xmm1
xorpd  %xmm3,%xmm3
movapd %xmm0,%xmm2
jmp    11cb <stdlib_strided_dcusumkbn2+0xbb>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  (%rsp),%xmm3
movsd  0x10(%rsp),%xmm0
subsd  %xmm3,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm0,%xmm1
movapd %xmm2,%xmm0
addsd  %xmm3,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%r13)
add    %r14,%r13
add    %r15,%rbp
movapd %xmm2,%xmm0
add    $0xffffffffffffffff,%r12
je     1298 <stdlib_strided_dcusumkbn2+0x188>
movsd  %xmm3,0x10(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  0x0(%rbp),%xmm1
movsd  %xmm1,(%rsp)
addsd  %xmm1,%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  (%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jl     1220 <stdlib_strided_dcusumkbn2+0x110>
movsd  0x8(%rsp),%xmm1
subsd  0x18(%rsp),%xmm1
addsd  (%rsp),%xmm1
jmp    1235 <stdlib_strided_dcusumkbn2+0x125>
nopl   0x0(%rax,%rax,1)
movsd  (%rsp),%xmm0
subsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
movsd  %xmm1,0x8(%rsp)
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jge    1180 <stdlib_strided_dcusumkbn2+0x70>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm3
subsd  %xmm3,%xmm0
movsd  0x10(%rsp),%xmm4
addsd  %xmm0,%xmm4
movsd  0x20(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movapd %xmm4,%xmm0
jmp    11a1 <stdlib_strided_dcusumkbn2+0x91>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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