user: What is the c source code of the assembly code below?

```asm
<ti_dema>:
  endbr64
  push   %r15
  mov    $0x1,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cvttsd2si (%rdx),%ebp
  test   %ebp,%ebp
  jle    L152
  mov    %edi,%ebx
  mov    %rdx,%rdi
  mov    (%rsi),%r14
  mov    (%rcx),%r12
  mov    %rdx,%r13
  mov    %rcx,%r15
  call   <ti_dema_start@plt>
  mov    %eax,%r8d
  xor    %eax,%eax
  cmp    %ebx,%r8d
  jge    L152
  pxor   %xmm0,%xmm0
  movsd  D10(%rip),%xmm3
  movsd  D16(%rip),%xmm2
  cvtsi2sd %ebp,%xmm0
  addsd  %xmm3,%xmm0
  divsd  %xmm0,%xmm2
  movsd  (%r14),%xmm0
  subsd  %xmm2,%xmm3
  test   %ebx,%ebx
  jle    L66
  lea    -0x1(%rbp),%ecx
  lea    (%rcx,%rcx,1),%esi
  test   %esi,%esi
  jle    L30
  cmp    %ebx,%esi
  mov    %r14,%rdx
  movapd %xmm0,%xmm1
  cmovg  %ebx,%esi
  jmp    L83
  nopl   0x0(%rax)
L125:
  jle    L44
  add    $0x1,%eax
  add    $0x8,%rdx
  cmp    %esi,%eax
  jge    L154
L83:
  movsd  (%rdx),%xmm4
  mulsd  %xmm3,%xmm0
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  cmp    %eax,%ecx
  jne    L125
  movapd %xmm0,%xmm1
L44:
  mulsd  %xmm3,%xmm1
  movapd %xmm2,%xmm4
  add    $0x1,%eax
  add    $0x8,%rdx
  mulsd  %xmm0,%xmm4
  addsd  %xmm4,%xmm1
  cmp    %esi,%eax
  jl     L83
L154:
  cmp    %eax,%ebx
  jle    L66
L61:
  cltq
  jmp    L12
L116:
  jle    L3
  add    $0x1,%rax
  cmp    %eax,%ebx
  jle    L66
L12:
  movsd  (%r14,%rax,8),%xmm4
  mulsd  %xmm3,%xmm0
  mulsd  %xmm2,%xmm4
  addsd  %xmm4,%xmm0
  cmp    %eax,%ecx
  jne    L116
  movapd %xmm0,%xmm1
L3:
  mulsd  %xmm3,%xmm1
  movapd %xmm2,%xmm4
  add    $0x1,%rax
  add    $0x8,%r12
  mulsd  %xmm0,%xmm4
  addsd  %xmm4,%xmm1
  movapd %xmm0,%xmm4
  addsd  %xmm0,%xmm4
  subsd  %xmm1,%xmm4
  movsd  %xmm4,-0x8(%r12)
  cmp    %eax,%ebx
  jg     L12
L66:
  mov    %r13,%rdi
  sub    (%r15),%r12
  call   <ti_dema_start@plt>
  sar    $0x3,%r12
  xor    %edi,%edi
  sub    %eax,%ebx
  movslq %ebx,%rbx
  cmp    %r12,%rbx
  sete   %dil
  call   <assert@plt>
  xor    %eax,%eax
L152:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L30:
  movapd %xmm0,%xmm1
  xor    %eax,%eax
  jmp    L61
```

tool_calls: name: retrieve_data
arguments: label: D10
type: f64
name: retrieve_data
arguments: label: D16
type: f32[2]

tool: D10: 1

tool: {"D16": [0.0,2.0]}

assistant: ```c
int ti_dema(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_dema_start(options))
    return 0;
  const double per = 2 / ((double)period + 1);
  const double per1 = 1.0 - per;
  double ema = input[0];
  double ema2 = ema;
  int i;
  for (i = 0; i < size; ++i) {
    ema = ema * per1 + input[i] * per;
    if (i == period - 1) {
      ema2 = ema;
    }
    if (i >= period - 1) {
      ema2 = ema2 * per1 + ema * per;
      if (i >= (period - 1) * 2) {
        *output = ema * 2 - ema2;
        ++output;
      }
    }
  }
  assert(output - outputs[0] == size - ti_dema_start(options));
  return 0;
}
```