user: Please show me the C implementation that matches the assembly code listed below:

```asm
<SHOKcumulative>:
  endbr64
  push   %r14
  movapd %xmm0,%xmm3
  push   %r13
  lea    (%rsi,%rsi,1),%r13d
  push   %r12
  sub    %edx,%r13d
  push   %rbp
  mov    %rdi,%rbp
  mov    %r13d,%edi
  push   %rbx
  mov    %esi,%ebx
  mov    $0x8,%esi
  sub    $0x10,%rsp
  movsd  D17(%rip),%xmm1
  movsd  D1(%rip),%xmm2
  addsd  %xmm0,%xmm1
  mulsd  %xmm0,%xmm1
  addsd  %xmm2,%xmm0
  mulsd  D38(%rip),%xmm0
  mulsd  D21(%rip),%xmm1
  divsd  %xmm3,%xmm0
  movsd  %xmm1,0x8(%rsp)
  addsd  D59(%rip),%xmm0
  cvttsd2si %xmm0,%r14
  cmp    %r14d,%r13d
  cmovbe %r13d,%r14d
  call   <chk_calloc@plt>
  mov    $0x8,%esi
  mov    %r13d,%edi
  mov    %rax,%r12
  call   <chk_calloc@plt>
  movsd  0x8(%rsp),%xmm1
  lea    -0x1(%r14),%esi
  lea    0x8(%r12),%rdx
  mov    %rax,%r13
  mov    D1(%rip),%rax
  movapd %xmm1,%xmm3
  movq   %rax,%xmm2
  mov    $0x1,%eax
  addsd  %xmm2,%xmm3
  divsd  %xmm3,%xmm1
  movsd  %xmm1,(%r12)
  cmp    $0x1,%esi
  jbe    L14
  nopl   0x0(%rax)
L71:
  mov    %eax,%ecx
  pxor   %xmm1,%xmm1
  add    $0x1,%eax
  add    $0x8,%rdx
  cvtsi2sd %rcx,%xmm1
  movapd %xmm1,%xmm0
  addsd  %xmm2,%xmm0
  mulsd  %xmm1,%xmm0
  movapd %xmm2,%xmm1
  mulsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm1
  movsd  %xmm1,-0x8(%rdx)
  cmp    %esi,%eax
  jne    L71
L14:
  mov    %r14d,%r14d
  pxor   %xmm0,%xmm0
  cvtsi2sd %r14,%xmm0
  mulsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm2
  movsd  %xmm2,(%r12,%r14,8)
  test   %ebx,%ebx
  je     L23
  mov    %ebx,%eax
  pxor   %xmm2,%xmm2
  lea    (%r12,%rax,8),%rdx
  mov    %r12,%rax
  nopw   0x0(%rax,%rax,1)
L34:
  addsd  (%rax),%xmm2
  add    $0x8,%rax
  cmp    %rax,%rdx
  jne    L34
  mov    %r13,%rsi
  mov    %r12,%rax
  pxor   %xmm3,%xmm3
  xor    %edx,%edx
  sub    %r12,%rsi
  nopl   0x0(%rax)
L55:
  movsd  (%rax),%xmm0
  lea    0x1(%rdx),%ecx
  pxor   %xmm1,%xmm1
  cvtsi2sd %rcx,%xmm1
  mov    %rcx,%rdx
  divsd  %xmm2,%xmm0
  movsd  %xmm0,(%rsi,%rax,1)
  mulsd  %xmm1,%xmm0
  add    $0x8,%rax
  addsd  %xmm0,%xmm3
  cmp    %ebx,%ecx
  jne    L55
  movsd  0x0(%r13),%xmm0
  movsd  %xmm0,0x0(%rbp)
  cmp    $0x1,%ecx
  je     L65
  sub    $0x2,%edx
  lea    0x8(%rbp),%rax
  lea    (%rax,%rdx,8),%rcx
  mov    %r13,%rdx
  sub    %rbp,%rdx
  jmp    L4
  nop
L20:
  add    $0x8,%rax
L4:
  addsd  (%rdx,%rax,1),%xmm0
  movsd  %xmm0,(%rax)
  cmp    %rcx,%rax
  jne    L20
L65:
  mov    %r12,%rdi
  movsd  %xmm3,0x8(%rsp)
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  movsd  0x8(%rsp),%xmm3
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  movapd %xmm3,%xmm0
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L23:
  movsd  0x0(%r13),%xmm0
  pxor   %xmm3,%xmm3
  movsd  %xmm0,0x0(%rbp)
  jmp    L65
```

tool_calls: name: read_data
arguments: data_tag: D17
type_guessed: f64
name: read_data
arguments: data_tag: D1
type_guessed: f64
name: read_data
arguments: data_tag: D38
type_guessed: f64
name: read_data
arguments: data_tag: D21
type_guessed: f32[2]
name: read_data
arguments: data_tag: D59
type_guessed: f64

tool: D17: 2

tool: D1: 1

tool: D38: 4

tool: {"D21": [0.0,1.625]}

tool: D59: 0.5

assistant: ```c
double SHOKcumulative(double *cumulative, unsigned int w, unsigned int s, double epsShok) {
  double m = 0;
  double *omega_shok = NULL;
  double *omega_shok_norm = NULL;
  double avgDeg = 0.0;
  unsigned int i = 0;
  unsigned int ref = 0;
  unsigned int wvirt = (2 * w - s);
  unsigned int D = (unsigned int)(4.0 * (1.0 + epsShok) / epsShok + 0.5);
  m = epsShok * (2.0 + epsShok) / 4.0;
  if (wvirt > D) {
    ref = D;
  } else {
    ref = (double)wvirt;
  }
  omega_shok = (double *)chk_calloc(wvirt, sizeof(double));
  omega_shok_norm = (double *)chk_calloc(wvirt, sizeof(double));
  omega_shok[0] = ((double)m / (m + 1.0));
  for (i = 1; i < (ref - 1); i++) {
    omega_shok[i] = 1.0 / (((i + 1.0) * i) * (m + 1.0));
  }
  omega_shok[ref] = 1.0 / (ref * (m + 1.0));
  double normfact = 0.0;
  for (i = 0; i < w; i++) {
    normfact += omega_shok[i];
  }
  for (i = 0; i < w; i++) {
    omega_shok_norm[i] = omega_shok[i] / normfact;
    avgDeg += omega_shok_norm[i] * (i + 1);
  }
  cumulative[0] = omega_shok_norm[0];
  for (i = 1; i < w; i++) {
    cumulative[i] = (double)(cumulative[i - 1] + omega_shok_norm[i]);
  }
  free(omega_shok);
  free(omega_shok_norm);
  return avgDeg;
}
```