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

```asm
<IextWextToSegAmp>:
  endbr64
  push   %r15
  movslq %ecx,%rax
  pxor   %xmm4,%xmm4
  pxor   %xmm2,%xmm2
  push   %r13
  mov    %rax,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x20,%rsp
  movsd  (%rsi),%xmm3
  cvtsi2sdl 0x4(%rdi,%rax,4),%xmm4
  movq   $0x0,(%rdx)
  test   %eax,%eax
  jle    L109
  lea    0x1(%rax),%r15d
  mov    $0x1,%ebx
  cs nopw 0x0(%rax,%rax,1)
L69:
  pxor   %xmm5,%xmm5
  movapd %xmm4,%xmm0
  movsd  (%rsi,%rbx,8),%xmm1
  cvtsi2sdl (%r12,%rbx,4),%xmm5
  subsd  %xmm5,%xmm0
  mulsd  %xmm5,%xmm0
  divsd  %xmm4,%xmm0
  ucomisd %xmm0,%xmm2
  ja     L127
  sqrtsd %xmm0,%xmm0
  divsd  %xmm0,%xmm1
  addsd  -0x8(%rbp,%rbx,8),%xmm1
  movsd  %xmm1,0x0(%rbp,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,%r15
  jne    L69
L73:
  movapd %xmm2,%xmm0
  xor    %eax,%eax
  cmp    $0x1,%r13d
  je     L25
  lea    -0x2(%r13),%eax
  mov    (%r12),%esi
  mov    $0x2,%edx
  shr    %eax
  lea    0x2(%rax),%ecx
  add    %rcx,%rcx
L22:
  mov    -0x4(%r12,%rdx,4),%eax
  pxor   %xmm1,%xmm1
  mov    %eax,%edi
  sub    %esi,%edi
  mov    (%r12,%rdx,4),%esi
  cvtsi2sd %edi,%xmm1
  mulsd  -0x10(%rbp,%rdx,8),%xmm1
  mov    %esi,%edi
  sub    %eax,%edi
  movslq %edx,%rax
  addsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sd %edi,%xmm1
  mulsd  -0x8(%rbp,%rdx,8),%xmm1
  add    $0x2,%rdx
  addsd  %xmm1,%xmm0
  cmp    %rdx,%rcx
  jne    L22
  nopl   0x0(%rax,%rax,1)
L25:
  mov    0x4(%r12,%rax,4),%edx
  pxor   %xmm1,%xmm1
  sub    (%r12,%rax,4),%edx
  cvtsi2sd %edx,%xmm1
  mulsd  0x0(%rbp,%rax,8),%xmm1
  add    $0x1,%rax
  addsd  %xmm1,%xmm0
  cmp    %eax,%r13d
  jge    L25
  divsd  %xmm4,%xmm0
  xor    %edx,%edx
  test   %r13d,%r13d
  cmovns %r13d,%edx
  add    $0x1,%edx
  test   %r13d,%r13d
  jle    L60
  mov    %edx,%ecx
  movapd %xmm0,%xmm4
  movapd %xmm3,%xmm2
  mov    %rbp,%rax
  shr    %ecx
  unpcklpd %xmm4,%xmm4
  unpcklpd %xmm2,%xmm2
  sub    $0x1,%ecx
  shl    $0x4,%rcx
  lea    0x10(%rbp,%rcx,1),%rcx
L76:
  movupd (%rax),%xmm1
  add    $0x10,%rax
  subpd  %xmm4,%xmm1
  addpd  %xmm2,%xmm1
  movups %xmm1,-0x10(%rax)
  cmp    %rcx,%rax
  jne    L76
  mov    %edx,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%edx
  je     L42
L126:
  cltq
  lea    0x0(%rbp,%rax,8),%rax
  movsd  (%rax),%xmm1
  subsd  %xmm0,%xmm1
  addsd  %xmm3,%xmm1
  movsd  %xmm1,(%rax)
L42:
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L109:
  jne    L42
  xor    %eax,%eax
  movapd %xmm2,%xmm0
  jmp    L25
  nopl   (%rax)
L60:
  xor    %eax,%eax
  jmp    L126
L127:
  mov    %rsi,0x18(%rsp)
  movsd  %xmm3,0x10(%rsp)
  movsd  %xmm4,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <sqrt@plt>
  movsd  (%rsp),%xmm1
  movsd  0x8(%rsp),%xmm4
  pxor   %xmm2,%xmm2
  movsd  0x10(%rsp),%xmm3
  mov    0x18(%rsp),%rsi
  divsd  %xmm0,%xmm1
  addsd  -0x8(%rbp,%rbx,8),%xmm1
  movsd  %xmm1,0x0(%rbp,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,%r15
  jne    L69
  jmp    L73
```

assistant: ```c
void IextWextToSegAmp(int *Iext, double *Wext, double *SegAmp, int K) {
  int k;
  double M, TotalMean, AuxMean;
  M = Iext[K + 1];
  TotalMean = Wext[0];
  SegAmp[0] = 0;
  for (k = 1; k <= K; k++)
    SegAmp[k] = Wext[k] / sqrt((double)(M - Iext[k]) * (double)Iext[k] / M) + SegAmp[k - 1];
  AuxMean = 0;
  for (k = 0; k <= K; k++)
    AuxMean = AuxMean + SegAmp[k] * (double)(Iext[k + 1] - Iext[k]);
  AuxMean = AuxMean / M;
  for (k = 0; k <= K; k++)
    SegAmp[k] = SegAmp[k] - AuxMean + TotalMean;
}
```