user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<ti_trima>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rsi,0x8(%rsp)
  cvttsd2si (%rdx),%r12d
  mov    $0x1,%eax
  test   %r12d,%r12d
  jle    L34
  mov    %edi,%ebp
  mov    %rdx,%r14
  mov    %rcx,%r15
  mov    (%rsi),%rbx
  mov    (%rcx),%r13
  mov    %rdx,%rdi
  call   <ti_trima_start@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  cmp    %ebp,%edx
  jge    L34
  cmp    $0x2,%r12d
  jle    L59
  test   $0x1,%r12b
  je     L57
  mov    %r12d,%eax
  shr    $0x1f,%eax
  add    %r12d,%eax
  sar    %eax
  mov    %eax,%ecx
  add    $0x1,%eax
  imul   %eax,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D15(%rip),%xmm5
  divsd  %xmm0,%xmm5
L88:
  lea    -0x1(%r12),%r9d
  lea    -0x1(%r12),%r8d
  mov    $0x0,%eax
  mov    $0x1,%edx
  pxor   %xmm1,%xmm1
  movapd %xmm1,%xmm2
  movapd %xmm1,%xmm0
  mov    %r12d,%edi
  sub    %ecx,%edi
  jmp    L15
L59:
  mov    %r15,%rcx
  mov    %r14,%rdx
  mov    0x8(%rsp),%rsi
  mov    %ebp,%edi
  call   <ti_sma@plt>
  jmp    L34
L57:
  mov    %r12d,%ecx
  shr    $0x1f,%ecx
  add    %r12d,%ecx
  sar    %ecx
  lea    0x1(%rcx),%eax
  imul   %ecx,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  D15(%rip),%xmm5
  divsd  %xmm0,%xmm5
  sub    $0x1,%ecx
  jmp    L88
L10:
  cmp    %esi,%ecx
  setg   %sil
  movzbl %sil,%esi
  add    %esi,%edx
  lea    0x1(%rax),%esi
  cmp    %esi,%edi
  setle  %sil
  movzbl %sil,%esi
  sub    %esi,%edx
  add    $0x1,%rax
  cmp    %rax,%r8
  je     L68
L15:
  movsd  (%rbx,%rax,8),%xmm4
  pxor   %xmm3,%xmm3
  cvtsi2sd %edx,%xmm3
  mulsd  %xmm4,%xmm3
  addsd  %xmm3,%xmm0
  mov    %eax,%esi
  cmp    %eax,%edi
  jg     L36
  addsd  %xmm4,%xmm2
L36:
  cmp    %esi,%ecx
  jl     L10
  addsd  %xmm4,%xmm1
  jmp    L10
L68:
  mov    %r9d,%eax
  sub    %ecx,%eax
  cmp    %r9d,%ebp
  jle    L113
  mov    %ebp,%edx
  sub    %r12d,%edx
  lea    0x1(%rdx),%rsi
  movslq %r12d,%r12
  lea    (%rbx,%r12,8),%rdi
  cltq
  lea    (%rbx,%rax,8),%r8
  movslq %ecx,%rcx
  lea    (%rbx,%rcx,8),%r9
  mov    $0x0,%eax
L6:
  addsd  -0x8(%rdi,%rax,8),%xmm0
  movapd %xmm5,%xmm3
  mulsd  %xmm0,%xmm3
  movsd  %xmm3,0x0(%r13,%rax,8)
  addsd  -0x8(%rdi,%rax,8),%xmm2
  addsd  %xmm2,%xmm0
  subsd  %xmm1,%xmm0
  subsd  0x8(%r8,%rax,8),%xmm2
  addsd  0x8(%r9,%rax,8),%xmm1
  subsd  (%rbx,%rax,8),%xmm1
  mov    %rax,%rcx
  add    $0x1,%rax
  cmp    %rcx,%rdx
  jne    L6
  lea    0x0(%r13,%rsi,8),%r13
L113:
  sub    (%r15),%r13
  sar    $0x3,%r13
  mov    %r14,%rdi
  call   <ti_trima_start@plt>
  sub    %eax,%ebp
  movslq %ebp,%rbp
  cmp    %r13,%rbp
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x0,%eax
L34:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D15
type_infered: f64

tool: D15: 1

assistant: ```c
int ti_trima(int size, double const *const *inputs, double const *options, double *const *outputs) {
  const double *input = inputs[0];
  const int period = (int)options[0];
  double *output = outputs[0];
  if (period < 1)
    return 1;
  if (size <= ti_trima_start(options))
    return 0;
  if (period <= 2)
    return ti_sma(size, inputs, options, outputs);
  double weights = 1 / (double)((period % 2) ? ((period / 2 + 1) * (period / 2 + 1)) : ((period / 2 + 1) * (period / 2)));
  double weight_sum = 0;
  double lead_sum = 0;
  double trail_sum = 0;
  const int lead_period = period % 2 ? period / 2 : period / 2 - 1;
  const int trail_period = lead_period + 1;
  int i, w = 1;
  for (i = 0; i < period - 1; ++i) {
    weight_sum += input[i] * w;
    if (i + 1 > period - lead_period)
      lead_sum += input[i];
    if (i + 1 <= trail_period)
      trail_sum += input[i];
    if (i + 1 < trail_period)
      ++w;
    if (i + 1 >= period - lead_period)
      --w;
  }
  int lsi = (period - 1) - lead_period + 1;
  int tsi1 = (period - 1) - period + 1 + trail_period;
  int tsi2 = (period - 1) - period + 1;
  for (i = period - 1; i < size; ++i) {
    weight_sum += input[i];
    *output++ = weight_sum * weights;
    lead_sum += input[i];
    weight_sum += lead_sum;
    weight_sum -= trail_sum;
    lead_sum -= input[lsi++];
    trail_sum += input[tsi1++];
    trail_sum -= input[tsi2++];
  }
  assert(output - outputs[0] == size - ti_trima_start(options));
  return 0;
}
```