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

```asm
<tw>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rsi,0x40(%rsp)
  mov    %rdx,0x48(%rsp)
  test   %r8d,%r8d
  jle    L16
  mov    %rdi,%r13
  mov    %rcx,%r12
  cmp    $0x1,%r8d
  je     L38
  mov    %r8d,%edx
  pxor   %xmm3,%xmm3
  mov    %rdi,%rax
  shr    %edx
  movapd %xmm3,%xmm2
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%rdi,%rdx,1),%rdx
  nopl   0x0(%rax)
L19:
  movupd (%rax),%xmm0
  add    $0x10,%rax
  movapd %xmm0,%xmm1
  movapd %xmm0,%xmm5
  mulpd  %xmm0,%xmm0
  addsd  %xmm2,%xmm1
  unpckhpd %xmm5,%xmm5
  movapd %xmm5,%xmm2
  addsd  %xmm1,%xmm2
  movapd %xmm0,%xmm1
  unpckhpd %xmm0,%xmm0
  addsd  %xmm3,%xmm1
  movapd %xmm0,%xmm3
  addsd  %xmm1,%xmm3
  cmp    %rdx,%rax
  jne    L19
  mov    %r8d,%eax
  and    $0xfffffffe,%eax
  test   $0x1,%r8b
  je     L6
L47:
  cltq
  movsd  0x0(%r13,%rax,8),%xmm0
  addsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm3
L6:
  lea    0x2(%r8),%ebp
  xor    %ebx,%ebx
  nopl   0x0(%rax)
L46:
  pxor   %xmm0,%xmm0
  lea    -0x2(%rbp),%r15d
  pxor   %xmm1,%xmm1
  movsd  %xmm3,0x38(%rsp)
  cvtsi2sd %ebp,%xmm0
  movapd %xmm2,%xmm5
  movsd  %xmm2,0x30(%rsp)
  sub    $0x1,%ebp
  cvtsi2sd %r15d,%xmm1
  mulsd  %xmm2,%xmm5
  mulsd  %xmm2,%xmm0
  movapd %xmm1,%xmm4
  mulsd  %xmm3,%xmm4
  mulsd  0x0(%r13,%rbx,1),%xmm1
  mulsd  %xmm2,%xmm0
  subsd  %xmm5,%xmm4
  movapd %xmm0,%xmm6
  divsd  %xmm4,%xmm6
  movapd %xmm1,%xmm4
  divsd  %xmm2,%xmm4
  movapd %xmm6,%xmm0
  subsd  D37(%rip),%xmm0
  movsd  %xmm6,0x8(%rsp)
  cvttsd2si %xmm0,%r14d
  mov    %r14d,%edi
  movsd  %xmm4,0x28(%rsp)
  call   <sqrt@plt>
  mov    %r15d,%edi
  movsd  %xmm0,0x10(%rsp)
  call   <sqrt@plt>
  movsd  0x10(%rsp),%xmm7
  mov    %r14d,%edi
  addsd  %xmm0,%xmm7
  movsd  %xmm7,0x10(%rsp)
  call   <sqrt@plt>
  mov    %r15d,%edi
  movsd  %xmm0,0x18(%rsp)
  call   <sqrt@plt>
  addsd  0x18(%rsp),%xmm0
  mov    %r14d,%edi
  mulsd  0x10(%rsp),%xmm0
  movapd %xmm0,%xmm7
  divsd  0x8(%rsp),%xmm7
  movsd  %xmm7,0x20(%rsp)
  call   <sqrt@plt>
  mov    %r15d,%edi
  movsd  %xmm0,0x10(%rsp)
  call   <sqrt@plt>
  mov    %r14d,%edi
  addsd  0x10(%rsp),%xmm0
  divsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x10(%rsp)
  call   <sqrt@plt>
  mov    %r15d,%edi
  movsd  %xmm0,0x18(%rsp)
  call   <sqrt@plt>
  movsd  D37(%rip),%xmm1
  movsd  D37(%rip),%xmm2
  divsd  0x18(%rsp),%xmm2
  movapd %xmm0,%xmm5
  movapd %xmm2,%xmm0
  mov    D3(%rip),%rax
  divsd  %xmm5,%xmm1
  addsd  %xmm1,%xmm0
  movq   %rax,%xmm1
  call   <pow@plt>
  mulsd  0x10(%rsp),%xmm0
  movsd  0x28(%rsp),%xmm4
  subsd  0x20(%rsp),%xmm4
  movapd %xmm4,%xmm1
  divsd  %xmm0,%xmm1
  movapd %xmm1,%xmm0
  movsd  %xmm1,0x10(%rsp)
  call   <twtest@plt>
  mov    0x40(%rsp),%rax
  movsd  0x10(%rsp),%xmm1
  movsd  0x8(%rsp),%xmm6
  movsd  0x30(%rsp),%xmm2
  movsd  %xmm0,(%rax,%rbx,1)
  mov    0x48(%rsp),%rax
  movsd  0x38(%rsp),%xmm3
  movsd  %xmm1,(%rax,%rbx,1)
  movsd  %xmm6,(%r12,%rbx,1)
  movsd  0x0(%r13,%rbx,1),%xmm0
  add    $0x8,%rbx
  subsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm0
  subsd  %xmm0,%xmm3
  cmp    $0x2,%ebp
  jne    L46
L16:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L38:
  pxor   %xmm3,%xmm3
  xor    %eax,%eax
  movapd %xmm3,%xmm2
  jmp    L47
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D37
type_guessed: f64
name: extract_symbolic_data
arguments: data_tag: D3
type_guessed: byte[8]

tool: D37: 1

tool: {"D3": [0x55,0x55,0x55,0x55,0x55,0x55,0xd5,0x3f]}

assistant: ```c
void tw(double *values, double *pvalues, double *twstat, double *effectn, int M) {
  int Mp, i;
  double nhat, lambda, mu, sigma, s, s2;
  s = 0;
  s2 = 0;
  for (i = 0; i < M; i++) {
    s += values[i];
    s2 += values[i] * values[i];
  }
  for (i = 0; i < M; i++) {
    Mp = M - i;
    nhat = (Mp + 2) * s * s / (Mp * s2 - s * s);
    lambda = values[i] * Mp / s;
    mu = (sqrt(nhat - 1) + sqrt(Mp)) * (sqrt(nhat - 1) + sqrt(Mp)) / nhat;
    sigma = (sqrt(nhat - 1) + sqrt(Mp)) / nhat * pow(1.0 / sqrt(nhat - 1) + 1.0 / sqrt(Mp), (double)(1.0 / 3.0));
    lambda = (lambda - mu) / sigma;
    pvalues[i] = twtest(lambda);
    twstat[i] = lambda;
    effectn[i] = nhat;
    s -= values[i];
    s2 -= values[i] * values[i];
  }
}
```