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

```asm
<lfr_filter_calculate_s16>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x78,%rsp
  mov    %rdi,0x68(%rsp)
  mov    %esi,%r15d
  mov    %edx,0x4c(%rsp)
  movsd  %xmm0,0x50(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm2,0x30(%rsp)
  lea    0x0(,%rsi,8),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L168
L23:
  movsd  D61(%rip),%xmm5
  movsd  %xmm5,0x60(%rsp)
  cmp    $0x8,%r15d
  jle    L87
  movsd  D72(%rip),%xmm5
  movsd  %xmm5,0x60(%rsp)
L87:
  movsd  0x30(%rsp),%xmm0
  call   <bessel_i0@plt>
  movsd  0x8(%rsp),%xmm4
  movapd %xmm4,%xmm1
  addsd  %xmm4,%xmm1
  divsd  %xmm0,%xmm1
  movsd  %xmm1,0x38(%rsp)
  mulsd  D36(%rip),%xmm4
  movsd  %xmm4,0x40(%rsp)
  cmpl   $0x0,0x4c(%rsp)
  jle    L147
  lea    -0x1(%r15),%r12d
  mov    %r12d,%eax
  shr    $0x1f,%eax
  add    %r12d,%eax
  sar    %eax
  pxor   %xmm5,%xmm5
  cvtsi2sd %eax,%xmm5
  movsd  %xmm5,0x58(%rsp)
  mov    %r12d,%r12d
  lea    0x8(%rbp,%r12,8),%r13
  movl   $0x0,0x48(%rsp)
  mov    $0x0,%r14d
  jmp    L79
L168:
  mov    $0x0,%eax
  call   <abort@plt>
  jmp    L23
L143:
  call   <sqrt@plt>
L46:
  mulsd  0x30(%rsp),%xmm0
  call   <bessel_i0@plt>
  mulsd  0x38(%rsp),%xmm0
  movsd  %xmm0,0x28(%rsp)
  movsd  0x10(%rsp),%xmm5
  mulsd  0x40(%rsp),%xmm5
  movapd %xmm5,%xmm0
  call   <sinc@plt>
  mulsd  0x28(%rsp),%xmm0
L112:
  movsd  %xmm0,0x0(%rbp,%rbx,8)
  addsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0x8(%rsp)
  lea    0x1(%rbx),%rax
  cmp    %rbx,%r12
  je     L134
  mov    %rax,%rbx
L124:
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  subsd  0x18(%rsp),%xmm0
  movsd  %xmm0,0x10(%rsp)
  movsd  0x20(%rsp),%xmm1
  mulsd  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  movsd  D27(%rip),%xmm6
  comisd %xmm1,%xmm6
  jae    L112
  comisd D99(%rip),%xmm1
  jae    L112
  mulsd  %xmm1,%xmm1
  movsd  D99(%rip),%xmm0
  subsd  %xmm1,%xmm0
  pxor   %xmm1,%xmm1
  ucomisd %xmm0,%xmm1
  ja     L143
  sqrtsd %xmm0,%xmm0
  jmp    L46
L43:
  movapd %xmm1,%xmm2
  subsd  %xmm0,%xmm2
  cvttsd2si %xmm1,%ecx
  mov    %cx,(%rdx)
  add    $0x8,%rax
  add    $0x2,%rdx
  cmp    %rax,%r13
  je     L78
L71:
  movapd %xmm7,%xmm0
  mulsd  (%rax),%xmm0
  addsd  %xmm2,%xmm0
  movapd %xmm0,%xmm3
  addsd  %xmm6,%xmm3
  movapd %xmm3,%xmm1
  movapd %xmm3,%xmm2
  andpd  %xmm4,%xmm2
  ucomisd %xmm2,%xmm5
  jbe    L43
  cvttsd2si %xmm3,%rcx
  pxor   %xmm2,%xmm2
  cvtsi2sd %rcx,%xmm2
  movapd %xmm2,%xmm1
  cmpnlesd %xmm3,%xmm1
  andpd  %xmm8,%xmm1
  subsd  %xmm1,%xmm2
  movapd %xmm4,%xmm1
  andnpd %xmm3,%xmm1
  orpd   %xmm2,%xmm1
  jmp    L43
L78:
  add    $0x1,%r14d
  add    %r15d,0x48(%rsp)
  cmp    %r14d,0x4c(%rsp)
  je     L147
L79:
  pxor   %xmm0,%xmm0
  cvtsi2sd %r14d,%xmm0
  mulsd  0x50(%rsp),%xmm0
  addsd  0x58(%rsp),%xmm0
  movsd  %xmm0,0x18(%rsp)
  test   %r15d,%r15d
  jle    L78
  lea    -0x2(%r15),%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D21(%rip),%xmm4
  divsd  %xmm0,%xmm4
  movsd  %xmm4,0x20(%rsp)
  mov    $0x0,%ebx
  pxor   %xmm4,%xmm4
  movsd  %xmm4,0x8(%rsp)
  jmp    L124
L147:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x78,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L134:
  movsd  0x60(%rsp),%xmm7
  divsd  0x8(%rsp),%xmm7
  movslq 0x48(%rsp),%rax
  mov    0x68(%rsp),%rsi
  lea    (%rsi,%rax,2),%rdx
  mov    %rbp,%rax
  pxor   %xmm2,%xmm2
  movsd  D54(%rip),%xmm6
  movsd  D47(%rip),%xmm5
  movsd  D15(%rip),%xmm4
  movsd  D99(%rip),%xmm8
  jmp    L71
```

tool_calls: name: parse_data
arguments: tag: D61
type: f32[2]
name: parse_data
arguments: tag: D72
type: f32[2]
name: parse_data
arguments: tag: D36
type: byte[8]
name: parse_data
arguments: tag: D27
type: f32[2]
name: parse_data
arguments: tag: D99
type: f64[2]
name: parse_data
arguments: tag: D21
type: f64
name: parse_data
arguments: tag: D54
type: f64
name: parse_data
arguments: tag: D47
type: f32[2]
name: parse_data
arguments: tag: D15
type: byte[8]

tool: {"D61": [0.0,6.9613037109375]}

tool: {"D72": [0.0,6.999969482421875]}

tool: {"D36": [0x18,0x2d,0x44,0x54,0xfb,0x21,0x19,0x40]}

tool: {"D27": [0.0,-1.875]}

tool: {"D99": [1.0,0.5]}

tool: D21: 2

tool: D54: 0.5

tool: {"D47": [0.0,176.0]}

tool: {"D15": [0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f]}

assistant: ```c
void lfr_filter_calculate_s16(short *data, int nsamp, int nfilt, double offset, double cutoff, double beta) {
  double x, x0, t, y, z, xscale, yscale, err;
  int i, j;
  double *a, sum, fac, scale;
  a = malloc(nsamp * sizeof(double));
  if (!a)
    abort();
  if (nsamp <= 8)
    scale = 31500;
  else
    scale = 32767;
  yscale = 2.0 * cutoff / bessel_i0(beta);
  xscale = (8.0 * atan(1.0)) * cutoff;
  for (i = 0; i < nfilt; ++i) {
    x0 = (nsamp - 1) / 2 + offset * i;
    sum = 0.0;
    for (j = 0; j < nsamp; ++j) {
      x = j - x0;
      t = x * (2.0 / (nsamp - 2));
      if (t <= -1.0 || t >= 1.0) {
        y = 0.0;
      } else {
        y = yscale * bessel_i0(beta * sqrt(1.0 - t * t)) * sinc(xscale * x);
      }
      a[j] = y;
      sum += y;
    }
    fac = scale / sum;
    err = 0.0;
    for (j = 0; j < nsamp; ++j) {
      y = a[j] * fac + err;
      z = floor(y + 0.5);
      err = z - y;
      data[i * nsamp + j] = (short)z;
    }
  }
  free(a);
}
```