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

```asm
<normalize>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,0x1c(%rsp)
  mov    %r9,0x8(%rsp)
  test   %edi,%edi
  jle    L59
  mov    %rdx,%rbx
  mov    %rcx,%r14
  mov    %r8,%r12
  mov    %rdx,%rax
  xor    %r15d,%r15d
  nopw   0x0(%rax,%rax,1)
L113:
  movsd  (%rax),%xmm0
  mov    %rax,%r13
  add    $0x1,%r15d
  call   <isnan@plt>
  mov    %rax,%r8
  lea    0x8(%r13),%rax
  test   %r8,%r8
  jne    L113
  movsd  0x0(%r13),%xmm0
  mov    0x1c(%rsp),%eax
  movsd  %xmm0,(%r12)
  cmp    %r15d,%eax
  jle    L10
  sub    %r15d,%eax
  movslq %r15d,%rcx
  movl   $0x1,0x10(%rsp)
  sub    $0x1,%eax
  lea    (%rbx,%rcx,8),%rbp
  add    %rcx,%rax
  mov    %rbp,%r15
  lea    0x8(%rbx,%rax,8),%rax
  mov    %rax,(%rsp)
  nopl   0x0(%rax)
L35:
  movsd  (%r15),%xmm0
  call   <isnan@plt>
  test   %rax,%rax
  jne    L122
  movsd  (%r12),%xmm0
  addl   $0x1,0x10(%rsp)
  addsd  (%r15),%xmm0
  movsd  %xmm0,(%r12)
L122:
  add    $0x8,%r15
  cmp    (%rsp),%r15
  jne    L35
  pxor   %xmm3,%xmm3
  movsd  (%r12),%xmm1
  mov    0x8(%rsp),%rax
  cvtsi2sdl 0x10(%rsp),%xmm3
  divsd  %xmm3,%xmm1
  movsd  %xmm3,0x10(%rsp)
  movsd  %xmm1,(%r12)
  movsd  0x0(%r13),%xmm0
  subsd  %xmm1,%xmm0
  mulsd  %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  xchg   %ax,%ax
L133:
  movsd  0x0(%rbp),%xmm0
  call   <isnan@plt>
  test   %rax,%rax
  jne    L102
  movsd  0x0(%rbp),%xmm0
  subsd  (%r12),%xmm0
  mov    0x8(%rsp),%rax
  mulsd  %xmm0,%xmm0
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
L102:
  add    $0x8,%rbp
  cmp    (%rsp),%rbp
  jne    L133
  mov    0x8(%rsp),%rax
  movsd  (%rax),%xmm0
  divsd  0x10(%rsp),%xmm0
L88:
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L128
  sqrtsd %xmm0,%xmm0
L154:
  mov    0x8(%rsp),%r10
  mov    0x1c(%rsp),%r11d
  movsd  %xmm0,(%r10)
  movsd  (%rbx),%xmm1
  subsd  (%r12),%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,(%rbx)
  movsd  (%r14),%xmm0
  divsd  (%r10),%xmm0
  movsd  %xmm0,(%r14)
  cmp    $0x1,%r11d
  je     L59
  mov    %r11d,%eax
  lea    0x8(%r14),%rsi
  lea    0x18(%r14),%r8
  shl    $0x3,%rax
  lea    -0x1(%r11),%ecx
  lea    (%rbx,%rax,1),%rdi
  lea    (%r14,%rax,1),%rdx
  lea    0x18(%rbx),%rax
  cmp    %rax,%rsi
  lea    0x8(%rbx),%rsi
  setae  %al
  cmp    %rsi,%r8
  setbe  %sil
  or     %esi,%eax
  cmp    $0x2,%r11d
  setne  %sil
  and    %esi,%eax
  cmp    %rdi,%r12
  setae  %sil
  cmp    %r12,%rbx
  setae  %r8b
  or     %r8d,%esi
  and    %esi,%eax
  cmp    %r10,%rbx
  setae  %sil
  cmp    %rdi,%r10
  setae  %dil
  or     %edi,%esi
  and    %esi,%eax
  cmp    %r14,%r12
  setbe  %sil
  cmp    %rdx,%r12
  setae  %dil
  or     %edi,%esi
  test   %sil,%al
  je     L146
  cmp    %r14,%r10
  setbe  %al
  cmp    %rdx,%r10
  setae  %dl
  or     %dl,%al
  je     L146
  mov    %ecx,%eax
  movsd  (%r10),%xmm1
  movsd  (%r12),%xmm2
  shr    %eax
  lea    -0x1(%rax),%edx
  unpcklpd %xmm1,%xmm1
  unpcklpd %xmm2,%xmm2
  mov    $0x8,%eax
  shl    $0x4,%rdx
  add    $0x18,%rdx
  nopl   (%rax)
L97:
  movupd (%rbx,%rax,1),%xmm0
  subpd  %xmm2,%xmm0
  divpd  %xmm1,%xmm0
  movups %xmm0,(%rbx,%rax,1)
  movupd (%r14,%rax,1),%xmm0
  divpd  %xmm1,%xmm0
  movups %xmm0,(%r14,%rax,1)
  add    $0x10,%rax
  cmp    %rdx,%rax
  jne    L97
  mov    %ecx,%eax
  or     $0x1,%eax
  and    $0x1,%ecx
  je     L59
  cltq
  mov    0x8(%rsp),%rcx
  shl    $0x3,%rax
  add    %rax,%rbx
  add    %r14,%rax
  movsd  (%rbx),%xmm0
  subsd  (%r12),%xmm0
  divsd  (%rcx),%xmm0
  movsd  %xmm0,(%rbx)
  movsd  (%rax),%xmm0
  divsd  (%rcx),%xmm0
  movsd  %xmm0,(%rax)
L59:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L146:
  movslq 0x1c(%rsp),%rdx
  mov    $0x1,%eax
  nopw   0x0(%rax,%rax,1)
L49:
  mov    0x8(%rsp),%rsi
  movsd  (%rbx,%rax,8),%xmm0
  subsd  (%r12),%xmm0
  divsd  (%rsi),%xmm0
  movsd  %xmm0,(%rbx,%rax,8)
  movsd  (%r14,%rax,8),%xmm0
  divsd  (%rsi),%xmm0
  movsd  %xmm0,(%r14,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L49
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L10:
  subsd  %xmm0,%xmm0
  mulsd  %xmm0,%xmm0
  jmp    L88
L128:
  call   <sqrt@plt>
  jmp    L154
```

assistant: ```c
void normalize(int size, double *t, double *mag, double *sig, double *ave, double *stddev) {
  int i, i1, n;
  if (size > 0) {
    i = 0;
    while (isnan(mag[i]))
      i++;
    *ave = mag[i];
    n = 1;
    i1 = i;
    for (i = i + 1; i < size; i++)
      if (!isnan(mag[i])) {
        *ave += mag[i];
        n++;
      }
    *ave /= (double)n;
    *stddev = ((mag[i1] - *ave) * (mag[i1] - *ave));
    for (i = i1 + 1; i < size; i++)
      if (!isnan(mag[i]))
        *stddev += ((mag[i] - *ave) * (mag[i] - *ave));
    *stddev = sqrt((*stddev) / (double)n);
    for (i = 0; i < size; i++) {
      mag[i] = (mag[i] - *ave) / (*stddev);
      sig[i] = sig[i] / (*stddev);
    }
  }
}
```