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

```asm
<fir_downsampling_kernel>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%r10
  mov    %rdx,-0x10(%rsp)
  mov    %rcx,%r13
  mov    %r9,%rcx
  mov    %r9,-0x18(%rsp)
  mov    0x40(%rsp),%r15
  mov    (%r15),%r9
  lea    -0x1(%r13),%rdi
  mov    %rdi,-0x20(%rsp)
  lea    -0x1(%rbx),%rax
  cmp    %rbx,%rdi
  cmovl  %rdi,%rax
  cmp    %r9,%rax
  jl     L159
  mov    %rax,%rsi
  mov    %rdx,%rbp
  mov    0x38(%rsp),%rax
  shl    $0x2,%rax
  mov    %rax,-0x28(%rsp)
  lea    -0x4(%r10,%r9,4),%r12
  lea    0x4(,%r9,4),%rax
  lea    (%r8,%rax,1),%r14
  lea    -0x8(%rcx,%rax,1),%rdi
  lea    -0x8(%rcx,%r13,4),%rax
  mov    $0x0,%r11d
  mov    %rbx,-0x8(%rsp)
  mov    %rsi,%rbx
  mov    %rax,%r15
  jmp    L40
L191:
  mov    %rax,%r9
L40:
  mov    %rbp,%rax
  movss  0x4(%r12),%xmm0
  mulss  (%r8),%xmm0
  movss  %xmm0,0x0(%rbp)
  test   %r9,%r9
  jle    L169
  lea    0x4(%r8),%rcx
  mov    %r12,%rdx
L168:
  movss  (%rdx),%xmm0
  mulss  (%rcx),%xmm0
  addss  (%rax),%xmm0
  movss  %xmm0,(%rax)
  mov    %rdx,%rsi
  sub    $0x4,%rdx
  add    $0x4,%rcx
  cmp    %r10,%rsi
  jne    L168
L169:
  lea    0x1(%r9),%rdx
  cmp    %rdx,%r13
  jle    L195
  mov    %r14,%rcx
  mov    %r15,%rdx
L51:
  movss  (%rdx),%xmm0
  mulss  (%rcx),%xmm0
  addss  (%rax),%xmm0
  movss  %xmm0,(%rax)
  sub    $0x4,%rdx
  add    $0x4,%rcx
  cmp    %rdi,%rdx
  jne    L51
L195:
  add    $0x1,%r11
  mov    %r9,%rax
  add    0x38(%rsp),%rax
  add    $0x4,%rbp
  mov    -0x28(%rsp),%rsi
  add    %rsi,%r12
  add    %rsi,%r14
  add    %rsi,%rdi
  cmp    %rax,%rbx
  jge    L191
  mov    -0x8(%rsp),%rbx
  mov    0x40(%rsp),%r15
L57:
  mov    %r9,(%r15)
  add    0x38(%rsp),%r9
  cmp    %r9,%rbx
  jle    L33
  mov    -0x10(%rsp),%rax
  lea    (%rax,%r11,4),%rdi
  mov    0x38(%rsp),%rax
  lea    0x0(,%rax,4),%r12
  lea    -0x4(%r10,%r9,4),%rbp
  lea    (%r8,%r13,4),%rsi
L149:
  mov    %rdi,%rcx
  movss  0x4(%rbp),%xmm0
  mulss  (%r8),%xmm0
  movss  %xmm0,(%rdi)
  cmp    $0x1,%r13
  jle    L48
  lea    0x4(%r8),%rax
  mov    %rbp,%rdx
L83:
  movss  (%rdx),%xmm0
  mulss  (%rax),%xmm0
  addss  (%rcx),%xmm0
  movss  %xmm0,(%rcx)
  sub    $0x4,%rdx
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L83
L48:
  add    $0x1,%r11
  mov    %r9,(%r15)
  add    0x38(%rsp),%r9
  add    $0x4,%rdi
  add    %r12,%rbp
  cmp    %r9,%rbx
  jg     L149
L33:
  mov    0x38(%rsp),%rax
  sub    %rbx,%rax
  add    %rax,(%r15)
  cmp    %rbx,-0x20(%rsp)
  jle    L38
  lea    -0x2(%r13),%rax
  sub    %rbx,%rax
  mov    %rax,%rdx
  js     L73
  mov    -0x18(%rsp),%rdi
  mov    %rdi,%rax
  lea    0x4(%rdi,%rdx,4),%rdx
L177:
  movss  (%rax,%rbx,4),%xmm0
  movss  %xmm0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L177
L73:
  mov    -0x20(%rsp),%rdi
  mov    %rdi,%rax
  sub    %rbx,%rax
  cmp    %rax,%rdi
  jle    L11
  lea    -0x1(%r13),%rcx
  sub    %r13,%rbx
  lea    (%r10,%rbx,4),%rdx
  mov    -0x18(%rsp),%rsi
L103:
  movss  0x4(%rdx,%rax,4),%xmm0
  movss  %xmm0,(%rsi,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L103
  jmp    L11
L159:
  mov    $0x0,%r11d
  jmp    L57
L38:
  cmpq   $0x0,-0x20(%rsp)
  jle    L11
  lea    -0x1(%r13),%rcx
  sub    %r13,%rbx
  lea    (%r10,%rbx,4),%rdx
  mov    $0x0,%eax
  mov    -0x18(%rsp),%rsi
L9:
  movss  0x4(%rdx,%rax,4),%xmm0
  movss  %xmm0,(%rsi,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L9
L11:
  mov    %r11,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

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;
}
```