user: 请从给定的汇编指令推导出C源代码：

```asm
<trapfilter>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x20000(%rsp),%r11
L42:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L42
  sub    $0x10,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r10d
  mov    %edx,%r11d
  mov    %ecx,%edi
  mov    %r9d,%edx
  movapd %xmm0,%xmm5
  mov    0x20030(%rsp),%r9d
  mov    0x20038(%rsp),%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x20008(%rsp)
  xor    %eax,%eax
L35:
  movl   $0x0,(%rsp,%rax,1)
  movl   $0x0,0x10000(%rsp,%rax,1)
  add    $0x4,%rax
  cmp    $0x10000,%rax
  jne    L35
  add    %r10d,%r11d
  cmp    %r8d,%edx
  cmovg  %r8d,%edx
  test   %edx,%edx
  jle    L17
  mov    %rbp,%rsi
  lea    -0x1(%rdx),%eax
  lea    0x4(%rbp,%rax,4),%rbp
  pxor   %xmm2,%xmm2
  movapd %xmm2,%xmm3
  movapd %xmm2,%xmm0
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x0,%r8d
  pxor   %xmm7,%xmm7
  cvtsi2sd %edi,%xmm7
  pxor   %xmm6,%xmm6
  cvtsi2sd %r10d,%xmm6
L43:
  mov    (%rsi),%eax
  sub    %r9d,%eax
  imul   %ebx,%eax
  movslq %edx,%rdi
  movslq (%rsp,%rdi,4),%r12
  mov    %eax,(%rsp,%rdi,4)
  add    $0x1,%edx
  cmp    %edx,%r10d
  cmovle %r8d,%edx
  cltq
  sub    %r12,%rax
  movslq %ecx,%rdi
  movslq 0x10000(%rsp,%rdi,4),%r12
  mov    %eax,0x10000(%rsp,%rdi,4)
  add    $0x1,%ecx
  cmp    %ecx,%r11d
  cmovle %r8d,%ecx
  sub    %r12,%rax
  pxor   %xmm1,%xmm1
  cvtsi2sd %rax,%xmm1
  addsd  %xmm1,%xmm3
  mulsd  %xmm7,%xmm1
  movapd %xmm3,%xmm4
  mulsd  %xmm5,%xmm4
  addsd  %xmm4,%xmm1
  addsd  %xmm1,%xmm2
  movapd %xmm2,%xmm1
  divsd  %xmm6,%xmm1
  movapd %xmm1,%xmm4
  maxsd  %xmm0,%xmm4
  movapd %xmm4,%xmm0
  cvttsd2si %xmm1,%eax
  mov    %eax,(%rsi)
  add    $0x4,%rsi
  cmp    %rbp,%rsi
  jne    L43
L1:
  mov    0x20008(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  add    $0x20010,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L17:
  pxor   %xmm0,%xmm0
  jmp    L1
L50:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
double trapfilter(int *pulse, int peaking, int gap, int M, int len, int len_in, double N, int bl, int pol) {
  int delayk_buffer[16384];
  int delayk_index;
  int shiftk;
  long datak_out;
  int delaym_buffer[16384];
  int delaym_index;
  int shiftm;
  long datam_in;
  long datam_out;
  double slowshaperout;
  int i = 0;
  for (i = 0; i < 16384; i++) {
    delayk_buffer[i] = 0;
    delaym_buffer[i] = 0;
  }
  delayk_index = 0;
  shiftk = peaking;
  delaym_index = 0;
  shiftm = peaking + gap;
  if (len_in < len) {
    len = len_in;
  }
  int n = 0;
  i = 0;
  double max = 0;
  double accum1 = 0;
  double accum2 = 0;
  double adder2out;
  double adder3out;
  int input;
  while (i < len) {
    input = (pulse[i] - bl) * pol;
    datak_out = delayk_buffer[delayk_index];
    delayk_buffer[delayk_index] = input;
    delayk_index++;
    if (delayk_index >= shiftk)
      delayk_index = 0;
    datam_in = input - datak_out;
    datam_out = delaym_buffer[delaym_index];
    delaym_buffer[delaym_index] = datam_in;
    delaym_index++;
    if (delaym_index >= shiftm)
      delaym_index = 0;
    adder2out = datam_in - datam_out;
    accum1 += adder2out;
    adder3out = adder2out * M + accum1 * N;
    accum2 += adder3out;
    slowshaperout = accum2 / (double)peaking;
    if (slowshaperout > max) {
      max = slowshaperout;
    }
    pulse[i] = slowshaperout;
    i++;
  }
  return max;
}
```