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

```asm
<ti_linregintercept>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %edi,-0x74(%rbp)
  mov    %rsi,-0x80(%rbp)
  mov    %rdx,-0x88(%rbp)
  mov    %rcx,-0x90(%rbp)
  mov    -0x80(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x88(%rbp),%rax
  movsd  (%rax),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x64(%rbp)
  mov    -0x90(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x60(%rbp)
  cmpl   $0x0,-0x64(%rbp)
  jg     L20
  mov    $0x1,%eax
  jmp    L76
L20:
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <ti_linregintercept_start@plt>
  cmp    %eax,-0x74(%rbp)
  jg     L77
  mov    $0x0,%eax
  jmp    L76
L77:
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x50(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  pxor   %xmm0,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x64(%rbp),%xmm1
  movsd  D8(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x30(%rbp)
  movl   $0x0,-0x68(%rbp)
  jmp    L49
L0:
  mov    -0x68(%rbp),%eax
  add    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  -0x58(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  mov    -0x68(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x68(%rbp),%eax
  add    $0x1,%eax
  imul   %edx,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  -0x50(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x50(%rbp)
  mov    -0x68(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x68(%rbp),%eax
  add    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  %xmm1,%xmm0
  movsd  -0x40(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  mov    -0x68(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x48(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  addl   $0x1,-0x68(%rbp)
L49:
  mov    -0x64(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x68(%rbp)
  jl     L0
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x64(%rbp),%xmm0
  movsd  -0x58(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x58(%rbp)
  mov    -0x64(%rbp),%eax
  imul   %eax,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movsd  -0x50(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x50(%rbp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x64(%rbp),%xmm0
  movapd %xmm0,%xmm1
  mulsd  -0x50(%rbp),%xmm1
  movsd  -0x58(%rbp),%xmm0
  mulsd  %xmm0,%xmm0
  subsd  %xmm0,%xmm1
  movsd  D8(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,-0x28(%rbp)
  mov    -0x64(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x68(%rbp)
  jmp    L2
L45:
  mov    -0x68(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x64(%rbp),%xmm0
  mulsd  %xmm1,%xmm0
  movsd  -0x40(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x40(%rbp)
  mov    -0x68(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  -0x48(%rbp),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x64(%rbp),%xmm0
  mulsd  -0x40(%rbp),%xmm0
  movsd  -0x58(%rbp),%xmm1
  mulsd  -0x48(%rbp),%xmm1
  subsd  %xmm1,%xmm0
  movsd  -0x28(%rbp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x20(%rbp)
  movsd  -0x20(%rbp),%xmm0
  movapd %xmm0,%xmm1
  mulsd  -0x58(%rbp),%xmm1
  movsd  -0x48(%rbp),%xmm0
  subsd  %xmm1,%xmm0
  movsd  -0x30(%rbp),%xmm1
  mulsd  %xmm1,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x60(%rbp),%rax
  lea    0x8(%rax),%rdx
  mov    %rdx,-0x60(%rbp)
  movsd  -0x18(%rbp),%xmm0
  addsd  -0x20(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  movsd  -0x40(%rbp),%xmm0
  subsd  -0x48(%rbp),%xmm0
  movsd  %xmm0,-0x40(%rbp)
  mov    -0x68(%rbp),%eax
  sub    -0x64(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x48(%rbp),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x48(%rbp)
  addl   $0x1,-0x68(%rbp)
L2:
  mov    -0x68(%rbp),%eax
  cmp    -0x74(%rbp),%eax
  jl     L45
  mov    -0x90(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x60(%rbp),%rax
  sub    %rdx,%rax
  sar    $0x3,%rax
  mov    %rax,%rbx
  mov    -0x88(%rbp),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <ti_linregintercept_start@plt>
  mov    %eax,%edx
  mov    -0x74(%rbp),%eax
  sub    %edx,%eax
  cltq
  cmp    %rax,%rbx
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  mov    $0x0,%eax
  call   <assert@plt>
  mov    $0x0,%eax
L76:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D8
type: f64

tool: D8: 1

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