user: Converte this assembly snippet into its equivalent C code:

```asm
<stage_two>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,0x38(%rsp)
  mov    %edx,0x4c(%rsp)
  mov    %r8,0x50(%rsp)
  mov    %r9,0x58(%rsp)
  lea    -0x1(%rdx),%eax
  test   %eax,%eax
  jle    L11
  mov    %rsi,%r13
  mov    %rcx,%r12
  mov    %edx,%esi
  movslq %eax,%rcx
  mov    %rcx,0x20(%rsp)
  movslq %edx,%r15
  mov    $0x1,%edx
  sub    %r15,%rdx
  shl    $0x3,%rdx
  mov    %rdx,0x60(%rsp)
  imul   %esi,%eax
  movslq %eax,%rdx
  sub    %rcx,%rdx
  lea    (%rdi,%rdx,8),%rdx
  mov    %rdx,0x30(%rsp)
  mov    $0x1,%edx
  sub    %esi,%edx
  mov    %edx,0x68(%rsp)
  add    $0x1,%eax
  mov    %eax,0x44(%rsp)
  lea    0x0(,%r15,8),%rax
  mov    %rax,0x18(%rsp)
  mov    %esi,%eax
  imul   %esi,%eax
  mov    %eax,0x6c(%rsp)
  movq   $0x0,0x28(%rsp)
  mov    %r15,%r14
  jmp    L41
L33:
  movslq 0x44(%rsp),%rax
  sub    %r14,%rax
  mov    0x38(%rsp),%rsi
  lea    (%rsi,%rax,8),%rbp
  mov    0x20(%rsp),%rax
  lea    -0x8(,%rax,8),%rbx
  mov    0x28(%rsp),%r15d
  add    %rax,%r15
  shl    $0x3,%r15
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x8(%rsp)
L27:
  movsd  0x0(%rbp),%xmm0
  mulsd  0x0(%r13,%rbx,1),%xmm0
  movsd  %xmm0,0x0(%rbp,%r14,8)
  movsd  (%r12,%rbx,1),%xmm3
  movsd  %xmm3,0x10(%rsp)
  movsd  0x0(%r13,%rbx,1),%xmm0
  mov    $0x2,%edi
  call   <pow@plt>
  movapd %xmm0,%xmm2
  movsd  D4(%rip),%xmm0
  divsd  0x0(%rbp),%xmm0
  mov    0xb0(%rsp),%rax
  movsd  D4(%rip),%xmm4
  divsd  (%rax,%rbx,1),%xmm4
  addsd  %xmm4,%xmm0
  movsd  0x10(%rsp),%xmm1
  divsd  %xmm2,%xmm1
  mulsd  %xmm1,%xmm0
  addsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x8(%rsp)
  add    0x18(%rsp),%rbp
  add    $0x8,%rbx
  cmp    %r15,%rbx
  jne    L27
  mov    0x6c(%rsp),%ebp
  sub    0x48(%rsp),%ebp
L32:
  movslq %ebp,%rax
  mov    0x38(%rsp),%rsi
  lea    (%rsi,%rax,8),%rbx
  mov    $0x2,%edi
  movsd  (%rbx),%xmm0
  call   <pow@plt>
  mulsd  0x8(%rsp),%xmm0
  mov    0x50(%rsp),%rdx
  mov    0x28(%rsp),%rax
  movsd  %xmm0,0x8(%rdx,%rax,8)
  movsd  (%rbx),%xmm0
  mov    0x30(%rsp),%rcx
  subsd  (%rcx),%xmm0
  mov    0x58(%rsp),%rsi
  movsd  %xmm0,0x8(%rsi,%rax,8)
  add    $0x1,%rax
  mov    %rax,0x28(%rsp)
  subq   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%rax
  mov    0x60(%rsp),%rdx
  add    %rdx,%rcx
  mov    %rcx,0x30(%rsp)
  mov    0x68(%rsp),%ecx
  add    %ecx,0x44(%rsp)
  test   %eax,%eax
  jle    L11
L41:
  mov    0x20(%rsp),%rdx
  mov    %edx,0x48(%rsp)
  mov    0x4c(%rsp),%eax
  sub    %edx,%eax
  test   %eax,%eax
  jg     L33
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x8(%rsp)
  jmp    L32
L11:
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: read_data
arguments: data_label: D4
type_guessed: f32[2]

tool: {"D4": [0.0,1.875]}

assistant: ```c
void stage_two(double *vec, double *fact, int p, double *sigmas, double *mseR, double *res, double *ECik) {
  int i, j, k;
  double mse_cum;
  for (i = p - 1; i > 0; --i) {
    mse_cum = 0.;
    for (j = 0; j < p - i; ++j) {
      k = p * i + (p - i) + j * p;
      vec[k] = vec[k - p] * fact[i + j - 1];
      mse_cum += (sigmas[i + j - 1] / pow(fact[i + j - 1], 2)) * ((1 / vec[k - p]) + (1 / ECik[i + j - 1]));
    }
    mseR[p - i] = pow(vec[k], 2) * mse_cum;
    res[p - i] = vec[k] - vec[p * i - i];
  }
}
```