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

```asm
<simplexproj>:
  endbr64
  push   %r12
  mov    %rsi,%r9
  mov    %edx,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x10,%rsp
  cmp    %rdi,%rsi
  je     L108
L209:
  movsd  (%rbx),%xmm1
  movsd  %xmm1,(%r9)
  subsd  %xmm0,%xmm1
  cmp    $0x1,%r12d
  jbe    L112
  lea    -0x2(%r12),%edx
  lea    0x8(%rbx),%rax
  mov    $0xffffffff,%ecx
  lea    0x10(%rbx,%rdx,8),%rsi
  mov    $0x1,%edx
L28:
  movsd  (%rax),%xmm2
  comisd %xmm1,%xmm2
  jbe    L24
  movslq %edx,%rdi
  pxor   %xmm4,%xmm4
  movapd %xmm2,%xmm3
  movsd  %xmm2,(%r9,%rdi,8)
  mov    %edx,%edi
  subsd  %xmm1,%xmm3
  subsd  %xmm0,%xmm2
  sub    %ecx,%edi
  cvtsi2sd %edi,%xmm4
  divsd  %xmm4,%xmm3
  addsd  %xmm3,%xmm1
  comisd %xmm1,%xmm2
  jb     L41
  lea    -0x1(%rdx),%ecx
  movapd %xmm2,%xmm1
L41:
  add    $0x1,%edx
L24:
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L28
  mov    %r9,%rsi
  cmp    $0xffffffff,%ecx
  je     L89
  lea    0x1(%rcx),%eax
  movslq %ecx,%rcx
  movslq %eax,%rdi
  sub    %eax,%edx
  shl    $0x3,%rcx
  shl    $0x3,%rdi
  lea    (%r9,%rdi,1),%rsi
  sub    $0x8,%rdi
  lea    (%r9,%rdi,1),%rax
  lea    -0x8(%r9,%rdi,1),%rdi
  sub    %rcx,%rdi
  nopl   0x0(%rax,%rax,1)
L30:
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jbe    L199
  add    $0x1,%edx
  pxor   %xmm2,%xmm2
  movsd  %xmm0,-0x8(%rsi)
  subsd  %xmm1,%xmm0
  cvtsi2sd %edx,%xmm2
  sub    $0x8,%rsi
  divsd  %xmm2,%xmm0
  addsd  %xmm0,%xmm1
L199:
  sub    $0x8,%rax
  cmp    %rax,%rdi
  jne    L30
  nopl   0x0(%rax,%rax,1)
L89:
  mov    %edx,%r10d
  sub    $0x1,%r10d
  js     L153
  mov    %r10d,%edi
  mov    %edx,%r8d
  mov    $0x1,%eax
  xor    %edx,%edx
  add    $0x2,%rdi
  jmp    L193
  nopl   0x0(%rax)
L90:
  movslq %edx,%rcx
  add    $0x1,%rax
  add    $0x1,%edx
  movsd  %xmm0,(%rsi,%rcx,8)
  cmp    %rax,%rdi
  je     L173
L193:
  movsd  -0x8(%rsi,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  ja     L90
  mov    %r8d,%ecx
  pxor   %xmm3,%xmm3
  movapd %xmm1,%xmm2
  sub    %eax,%ecx
  subsd  %xmm0,%xmm2
  add    $0x1,%rax
  add    %edx,%ecx
  cvtsi2sd %ecx,%xmm3
  divsd  %xmm3,%xmm2
  addsd  %xmm2,%xmm1
  cmp    %rax,%rdi
  jne    L193
L173:
  cmp    %r10d,%edx
  jle    L89
  nopl   (%rax)
L153:
  test   %r12d,%r12d
  je     L84
  xor    %eax,%eax
  jmp    L127
  nopl   0x0(%rax)
L55:
  subsd  %xmm1,%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r12
  je     L84
L127:
  movsd  (%rbx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  ja     L55
  pxor   %xmm0,%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r12
  jne    L127
L84:
  cmp    %rbx,%rbp
  je     L208
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L108:
  lea    0x0(,%r12,8),%edi
  movsd  %xmm0,0x8(%rsp)
  call   <malloc@plt>
  movsd  0x8(%rsp),%xmm0
  mov    %rax,%r9
  jmp    L209
L208:
  add    $0x10,%rsp
  mov    %r9,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  jmp    1060 <free@plt>
L112:
  mov    %r9,%rsi
  mov    $0x1,%edx
  jmp    L89
```

assistant: ```c
void simplexproj(double *y, double *x, const unsigned int length, const double a) {
  double *aux = (x == y ? (double *)malloc(length * sizeof(double)) : x);
  double *aux0 = aux;
  int auxlength = 1;
  int auxlengthold = -1;
  double tau = (*aux = *y) - a;
  int i = 1;
  for (; i < length; i++)
    if (y[i] > tau) {
      if ((tau += ((aux[auxlength] = y[i]) - tau) / (auxlength - auxlengthold)) <= y[i] - a) {
        tau = y[i] - a;
        auxlengthold = auxlength - 1;
      }
      auxlength++;
    }
  if (auxlengthold >= 0) {
    auxlength -= ++auxlengthold;
    aux += auxlengthold;
    while (--auxlengthold >= 0)
      if (aux0[auxlengthold] > tau)
        tau += ((*(--aux) = aux0[auxlengthold]) - tau) / (++auxlength);
  }
  do {
    auxlengthold = auxlength - 1;
    for (i = auxlength = 0; i <= auxlengthold; i++)
      if (aux[i] > tau)
        aux[auxlength++] = aux[i];
      else
        tau += (tau - aux[i]) / (auxlengthold - i + auxlength);
  } while (auxlength <= auxlengthold);
  for (i = 0; i < length; i++)
    x[i] = (y[i] > tau ? y[i] - tau : 0.0);
  if (x == y)
    free(aux0);
}
```