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

```asm
<sd_to_llr>:
  endbr64
  test   %edx,%edx
  jle    L111
  push   %r15
  lea    -0x1(%rdx),%eax
  lea    0x8(%rsi),%rcx
  pxor   %xmm3,%xmm3
  push   %r14
  mov    %rsi,%r15
  mov    %rsi,%r14
  movapd %xmm3,%xmm1
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  lea    (%rcx,%rax,8),%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x28,%rsp
  mov    %eax,0x1c(%rsp)
  mov    %rcx,0x10(%rsp)
  nopl   (%rax)
L4:
  movsd  (%r14),%xmm0
  movsd  %xmm1,0x8(%rsp)
  add    $0x8,%r14
  call   <fabs@plt>
  pxor   %xmm0,%xmm0
  cmp    %rbp,%r14
  pxor   %xmm3,%xmm3
  cvtsi2sd %rax,%xmm0
  movsd  0x8(%rsp),%xmm1
  addsd  %xmm0,%xmm1
  jne    L4
  pxor   %xmm5,%xmm5
  cvtsi2sd %r13d,%xmm5
  divsd  %xmm5,%xmm1
  cmp    $0x1,%r13d
  je     L40
  mov    %r13d,%eax
  movapd %xmm1,%xmm2
  shr    %eax
  unpcklpd %xmm2,%xmm2
  sub    $0x1,%eax
  shl    $0x4,%rax
  lea    0x10(%r15,%rax,1),%rdx
  mov    %r15,%rax
  nopl   0x0(%rax,%rax,1)
L86:
  movupd (%rax),%xmm0
  add    $0x10,%rax
  divpd  %xmm2,%xmm0
  movups %xmm0,-0x10(%rax)
  cmp    %rax,%rdx
  jne    L86
  mov    %r13d,%eax
  and    $0xfffffffe,%eax
  test   $0x1,%r13b
  je     L73
L52:
  cltq
  lea    (%r15,%rax,8),%rax
  movsd  (%rax),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L73:
  movapd %xmm3,%xmm1
  movapd %xmm3,%xmm2
  nopl   0x0(%rax,%rax,1)
L23:
  movsd  (%rbx),%xmm0
  xor    %eax,%eax
  pxor   %xmm4,%xmm4
  comisd %xmm3,%xmm0
  seta   %al
  xor    %edx,%edx
  comisd %xmm0,%xmm3
  seta   %dl
  add    $0x8,%rbx
  sub    %edx,%eax
  cvtsi2sd %eax,%xmm4
  subsd  %xmm4,%xmm0
  addsd  %xmm0,%xmm2
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  cmp    %rbp,%rbx
  jne    L23
  divsd  %xmm5,%xmm2
  movsd  D3(%rip),%xmm0
  divsd  %xmm5,%xmm1
  mulsd  %xmm2,%xmm2
  subsd  %xmm2,%xmm1
  addsd  %xmm1,%xmm1
  addsd  D20(%rip),%xmm1
  divsd  %xmm1,%xmm0
  mulsd  D1(%rip),%xmm0
  cmp    0x10(%rsp),%r12
  je     L115
  cmpl   $0x1,0x1c(%rsp)
  jbe    L115
  mov    %r13d,%edx
  movapd %xmm0,%xmm2
  xor    %eax,%eax
  shr    %edx
  unpcklpd %xmm2,%xmm2
  shl    $0x4,%rdx
  nopw   0x0(%rax,%rax,1)
L27:
  movupd (%r15,%rax,1),%xmm1
  mulpd  %xmm2,%xmm1
  movups %xmm1,(%r12,%rax,1)
  add    $0x10,%rax
  cmp    %rdx,%rax
  jne    L27
  mov    %r13d,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%r13d
  je     L50
  mulsd  (%r15,%rax,8),%xmm0
  movsd  %xmm0,(%r12,%rax,8)
L50:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L115:
  mov    %r13d,%r13d
  xor    %eax,%eax
  nopl   (%rax)
L34:
  movsd  (%r15,%rax,8),%xmm1
  mulsd  %xmm0,%xmm1
  movsd  %xmm1,(%r12,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%r13
  jne    L34
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L111:
  ret
L40:
  xor    %eax,%eax
  jmp    L52
```

tool_calls: name: parse_data
arguments: tag: D3
type_infered: f64
name: parse_data
arguments: tag: D20
type_infered: byte[8]
name: parse_data
arguments: tag: D1
type_infered: f64

tool: D3: 1

tool: {"D20": [0xfc,0xa9,0xf1,0xd2,0x4d,0x62,0x50,0x3f]}

tool: D1: 4

assistant: ```c
void sd_to_llr(double llr[], double sd[], int n) {
  double sum, mean, sign, sumsq, estvar, estEsN0, x;
  int i;
  sum = 0.0;
  for (i = 0; i < n; i++)
    sum += fabs(sd[i]);
  mean = sum / n;
  for (i = 0; i < n; i++) {
    sd[i] /= mean;
  }
  sum = sumsq = 0.0;
  for (i = 0; i < n; i++) {
    sign = (sd[i] > 0.0) - (sd[i] < 0.0);
    x = (sd[i] - sign);
    sum += x;
    sumsq += x * x;
  }
  mean = sum / n;
  estvar = sumsq / n - mean * mean;
  estEsN0 = 1.0 / (2.0 * estvar + 1E-3);
  for (i = 0; i < n; i++)
    llr[i] = 4.0 * estEsN0 * sd[i];
}
```