user: Converte this assembly snippet into its equivalent C code:

```asm
<ti_linregslope>:
  endbr64
  push   %r15
  mov    $0x1,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cvttsd2si (%rdx),%r15d
  test   %r15d,%r15d
  jle    L67
  mov    %edi,%r12d
  xor    %eax,%eax
  mov    %rdx,%rdi
  mov    (%rsi),%rbx
  mov    (%rcx),%rbp
  mov    %rdx,%r13
  mov    %rcx,%r14
  call   <ti_linregslope_start@plt>
  mov    %eax,%r8d
  xor    %eax,%eax
  cmp    %r12d,%r8d
  jge    L67
  mov    %r15d,%esi
  sub    $0x1,%esi
  je     L24
  pxor   %xmm1,%xmm1
  lea    -0x2(%r15),%ecx
  mov    $0x1,%eax
  movapd %xmm1,%xmm3
  movapd %xmm1,%xmm4
  movapd %xmm1,%xmm5
  add    $0x2,%rcx
  nopl   (%rax)
L10:
  mov    %eax,%edx
  pxor   %xmm2,%xmm2
  pxor   %xmm0,%xmm0
  imul   %eax,%edx
  cvtsi2sd %eax,%xmm0
  cvtsi2sd %edx,%xmm2
  addsd  %xmm0,%xmm5
  addsd  %xmm2,%xmm4
  movsd  -0x8(%rbx,%rax,8),%xmm2
  add    $0x1,%rax
  mulsd  %xmm2,%xmm0
  addsd  %xmm2,%xmm3
  addsd  %xmm0,%xmm1
  cmp    %rax,%rcx
  jne    L10
L58:
  mov    %r15d,%eax
  pxor   %xmm6,%xmm6
  pxor   %xmm0,%xmm0
  imul   %r15d,%eax
  cvtsi2sd %r15d,%xmm6
  cvtsi2sd %eax,%xmm0
  addsd  %xmm6,%xmm5
  addsd  %xmm4,%xmm0
  movsd  D2(%rip),%xmm4
  movapd %xmm5,%xmm2
  mulsd  %xmm5,%xmm2
  mulsd  %xmm6,%xmm0
  subsd  %xmm2,%xmm0
  divsd  %xmm0,%xmm4
  cmp    %esi,%r12d
  jle    L64
  mov    %r12d,%ecx
  xor    %eax,%eax
  sub    %r15d,%ecx
  movslq %r15d,%r15
  lea    0x1(%rcx),%rdi
  lea    (%rbx,%r15,8),%rsi
  nopl   0x0(%rax)
L31:
  movsd  -0x8(%rsi,%rax,8),%xmm0
  movapd %xmm6,%xmm2
  mov    %rax,%rdx
  mulsd  %xmm0,%xmm2
  addsd  %xmm3,%xmm0
  movapd %xmm5,%xmm3
  mulsd  %xmm0,%xmm3
  addsd  %xmm1,%xmm2
  movapd %xmm6,%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm3,%xmm1
  movapd %xmm0,%xmm3
  mulsd  %xmm4,%xmm1
  movsd  %xmm1,0x0(%rbp,%rax,8)
  movapd %xmm2,%xmm1
  subsd  (%rbx,%rax,8),%xmm3
  add    $0x1,%rax
  subsd  %xmm0,%xmm1
  cmp    %rdx,%rcx
  jne    L31
  lea    0x0(%rbp,%rdi,8),%rbp
L64:
  mov    %r13,%rdi
  xor    %eax,%eax
  sub    (%r14),%rbp
  call   <ti_linregslope_start@plt>
  sar    $0x3,%rbp
  xor    %edi,%edi
  sub    %eax,%r12d
  movslq %r12d,%r12
  cmp    %rbp,%r12
  sete   %dil
  xor    %eax,%eax
  call   <assert@plt>
  xor    %eax,%eax
L67:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L24:
  pxor   %xmm1,%xmm1
  movapd %xmm1,%xmm3
  movapd %xmm1,%xmm4
  movapd %xmm1,%xmm5
  jmp    L58
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D2
type: f64

tool: D2: 1

assistant: ```c
int ti_linregslope(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_linregslope_start(options))
    return 0;
  do {
    double x = 0;
    double x2 = 0;
    double y = 0;
    double xy = 0;
    do {
    } while (0);
    int i;
    for (i = 0; i < (period)-1; ++i) {
      x += i + 1;
      x2 += (i + 1) * (i + 1);
      xy += (input)[i] * (i + 1);
      y += (input)[i];
    }
    x += (period);
    x2 += (period) * (period);
    const double bd = 1.0 / ((period)*x2 - x * x);
    for (i = (period)-1; i < (size); ++i) {
      xy += (input)[i] * (period);
      y += (input)[i];
      const double b = ((period)*xy - x * y) * bd;
      do {
        *output++ = b;
      } while (0);
      xy -= y;
      y -= (input)[i - (period) + 1];
    }
  } while (0);
  assert(output - outputs[0] == size - ti_linregslope_start(options));
  return 0;
}
```