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

```asm
<fir_downsampling_kernel>:
  endbr64
  push   %r15
  push   %r14
  lea    -0x1(%rcx),%r14
  push   %r13
  cmp    %rdi,%r14
  push   %r12
  mov    %r9,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    0x40(%rsp),%rax
  mov    %rdi,%rbx
  mov    0x38(%rsp),%r13
  mov    (%rax),%r9
  lea    -0x1(%rdi),%rax
  cmovl  %r14,%rax
  mov    %rdx,-0x18(%rsp)
  mov    %rax,-0x20(%rsp)
  cmp    %r9,%rax
  jl     L73
  mov    %rdx,%rcx
  lea    0x4(%r8),%rdx
  mov    %r14,-0x10(%rsp)
  lea    (%r8,%rbp,4),%rdi
  mov    %rbx,-0x8(%rsp)
  xor    %r11d,%r11d
  lea    -0x4(%rsi),%r15
  mov    %rdx,%r14
  lea    -0x8(,%rbp,4),%rax
  mov    %rax,%rbx
L14:
  movss  (%rsi,%r9,4),%xmm1
  mulss  (%r8),%xmm1
  lea    (%r15,%r9,4),%rax
  lea    0x4(%r8),%rdx
  movss  %xmm1,(%rcx)
  test   %r9,%r9
  jle    L81
  nopl   0x0(%rax)
L88:
  movss  (%rax),%xmm0
  mulss  (%rdx),%xmm0
  mov    %rax,%r10
  add    $0x4,%rdx
  sub    $0x4,%rax
  addss  %xmm0,%xmm1
  movss  %xmm1,(%rcx)
  cmp    %rsi,%r10
  jne    L88
L81:
  lea    0x1(%r9),%rax
  cmp    %rbp,%rax
  jge    L34
  movss  (%rcx),%xmm1
  lea    (%r12,%rbx,1),%rdx
  lea    (%r14,%r9,4),%rax
  nopl   (%rax)
L10:
  movss  (%rdx),%xmm0
  mulss  (%rax),%xmm0
  add    $0x4,%rax
  sub    $0x4,%rdx
  addss  %xmm0,%xmm1
  movss  %xmm1,(%rcx)
  cmp    %rax,%rdi
  jne    L10
L34:
  add    $0x1,%r11
  lea    0x0(%r13,%r9,1),%r10
  add    $0x4,%rcx
  cmp    %r10,-0x20(%rsp)
  jl     L53
  mov    %r10,%r9
  jmp    L14
  nopl   0x0(%rax)
L53:
  mov    -0x10(%rsp),%r14
  mov    -0x8(%rsp),%rbx
L4:
  mov    0x40(%rsp),%rax
  mov    %r9,(%rax)
  cmp    %r10,%rbx
  jle    L173
  mov    -0x18(%rsp),%rax
  mov    %r14,-0x20(%rsp)
  lea    -0x4(%rsi,%r10,4),%r9
  lea    0x0(,%r13,4),%r15
  mov    0x40(%rsp),%r14
  lea    (%r8,%rbp,4),%rdi
  lea    (%rax,%r11,4),%rcx
  nopw   0x0(%rax,%rax,1)
L40:
  movss  0x4(%r9),%xmm1
  mulss  (%r8),%xmm1
  lea    0x4(%r8),%rax
  mov    %r9,%rdx
  movss  %xmm1,(%rcx)
  cmp    $0x1,%rbp
  jle    L97
  nopl   0x0(%rax)
L87:
  movss  (%rdx),%xmm0
  mulss  (%rax),%xmm0
  add    $0x4,%rax
  sub    $0x4,%rdx
  addss  %xmm0,%xmm1
  movss  %xmm1,(%rcx)
  cmp    %rax,%rdi
  jne    L87
L97:
  mov    %r10,(%r14)
  add    %r13,%r10
  add    $0x1,%r11
  add    $0x4,%rcx
  add    %r15,%r9
  cmp    %r10,%rbx
  jg     L40
  mov    -0x20(%rsp),%r14
L173:
  mov    0x40(%rsp),%rax
  sub    %rbx,%r10
  mov    %r10,(%rax)
  cmp    %rbx,%r14
  jle    L127
  lea    -0x2(%rbp),%rax
  sub    %rbx,%rax
  mov    %rax,%rdx
  js     L145
  mov    %r12,%rax
  lea    0x4(%r12,%rdx,4),%rdx
  nopl   0x0(%rax)
L39:
  movss  (%rax,%rbx,4),%xmm0
  add    $0x4,%rax
  movss  %xmm0,-0x4(%rax)
  cmp    %rax,%rdx
  jne    L39
L145:
  mov    %r14,%rax
  sub    %rbx,%rax
  sub    %rbp,%rbx
  lea    (%rsi,%rbx,4),%rdx
  cmp    %rax,%r14
  jle    L128
  nopl   (%rax)
L60:
  movss  0x4(%rdx,%rax,4),%xmm0
  movss  %xmm0,(%r12,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%r14
  jne    L60
L128:
  pop    %rbx
  mov    %r11,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L127:
  test   %r14,%r14
  jle    L128
  sub    %rbp,%rbx
  xor    %eax,%eax
  lea    0x4(%rsi,%rbx,4),%rdx
  nopw   0x0(%rax,%rax,1)
L85:
  movss  (%rdx,%rax,4),%xmm0
  movss  %xmm0,(%r12,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%r14
  jne    L85
  pop    %rbx
  mov    %r11,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L73:
  lea    (%r9,%r13,1),%r10
  xor    %r11d,%r11d
  jmp    L4
```

assistant: ```c
long fir_downsampling_kernel(lenx, x, y, lenh0, h0, T, downfac, k0)
long lenx;
float *x;
float *y;
long lenh0;
float *h0;
float *T;
long downfac;
long *k0;
{
  long ktrans, kx, kStart, ky, kappa;
  kStart = *k0;
  ky = 0;
  ktrans = lenh0 - 1;
  if (ktrans > lenx - 1)
    ktrans = lenx - 1;
  for (kx = *k0; kx <= ktrans; kx += downfac) {
    y[ky] = x[kx] * h0[0];
    for (kappa = 1; kappa <= kx; kappa++) {
      y[ky] += x[kx - kappa] * h0[kappa];
    }
    for (kappa = kx + 1; kappa < lenh0; kappa++) {
      y[ky] += T[lenh0 - 2 + kx + 1 - kappa] * h0[kappa];
    }
    ky++;
    kStart = kx;
  }
  *k0 = kStart;
  for (kx = kStart + downfac; kx <= lenx - 1; kx += downfac) {
    y[ky] = x[kx] * h0[0];
    for (kappa = 1; kappa <= lenh0 - 1; kappa++) {
      y[ky] += x[kx - kappa] * h0[kappa];
    }
    ky++;
    *k0 = kx;
  }
  *k0 = *k0 + downfac;
  *k0 = *k0 - lenx;
  if (lenx >= lenh0 - 1) {
    for (kappa = 0; kappa <= lenh0 - 2; kappa++) {
      T[kappa] = x[lenx + 1 - lenh0 + kappa];
    }
  } else {
    for (kappa = 0; kappa <= lenh0 - 2 - lenx; kappa++) {
      T[kappa] = T[kappa + lenx];
    }
    for (kappa = lenh0 - 1 - lenx; kappa <= lenh0 - 2; kappa++) {
      T[kappa] = x[lenx - 1 + kappa - (lenh0 - 2)];
    }
  }
  return ky;
}
```