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

```asm
<dtrd>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  sub    $0x38,%rsp
  test   %esi,%esi
  jle    L60
  lea    -0x1(%rsi),%eax
  pxor   %xmm2,%xmm2
  mov    %rdi,%r12
  mov    %rdi,%rbx
  mov    %rax,%r13
  lea    0x8(%rdi,%rax,8),%rdx
  movapd %xmm2,%xmm1
  mov    %rdi,%rax
  nopl   0x0(%rax)
L58:
  addsd  (%rax),%xmm1
  add    $0x8,%rax
  addsd  %xmm1,%xmm2
  cmp    %rdx,%rax
  jne    L58
  pxor   %xmm3,%xmm3
  movapd %xmm1,%xmm8
  mov    $0x2,%esi
  mov    %ebp,%edi
  cvtsi2sd %ebp,%xmm3
  movsd  D30(%rip),%xmm7
  movsd  %xmm2,0x28(%rsp)
  movsd  %xmm1,0x18(%rsp)
  divsd  %xmm3,%xmm8
  addsd  %xmm3,%xmm7
  movsd  %xmm3,0x10(%rsp)
  mulsd  D22(%rip),%xmm7
  movsd  %xmm7,0x20(%rsp)
  movsd  %xmm8,0x8(%rsp)
  call   <pow@plt>
  movsd  0x18(%rsp),%xmm1
  cmp    $0x2,%r13d
  movsd  0x20(%rsp),%xmm7
  subsd  D30(%rip),%xmm0
  movsd  0x28(%rsp),%xmm2
  mulsd  %xmm7,%xmm1
  movsd  0x10(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm8
  mulsd  %xmm3,%xmm0
  subsd  %xmm1,%xmm2
  mulsd  D23(%rip),%xmm2
  divsd  %xmm0,%xmm2
  jbe    L12
  movapd %xmm8,%xmm6
  movapd %xmm7,%xmm5
  movapd %xmm2,%xmm4
  mov    %ebp,%eax
  unpcklpd %xmm6,%xmm6
  shr    $0x2,%eax
  unpcklpd %xmm5,%xmm5
  unpcklpd %xmm4,%xmm4
  sub    $0x1,%eax
  movdqa D31(%rip),%xmm3
  movdqa D21(%rip),%xmm9
  shl    $0x5,%rax
  lea    0x20(%r12,%rax,1),%rax
  xchg   %ax,%ax
L67:
  movdqa %xmm3,%xmm0
  movupd 0x10(%rbx),%xmm10
  add    $0x20,%rbx
  paddd  %xmm9,%xmm3
  pshufd $0xee,%xmm0,%xmm1
  cvtdq2pd %xmm0,%xmm0
  subpd  %xmm5,%xmm0
  cvtdq2pd %xmm1,%xmm1
  subpd  %xmm5,%xmm1
  subpd  %xmm6,%xmm10
  mulpd  %xmm4,%xmm0
  mulpd  %xmm4,%xmm1
  subpd  %xmm1,%xmm10
  movupd -0x20(%rbx),%xmm1
  subpd  %xmm6,%xmm1
  movups %xmm10,-0x10(%rbx)
  subpd  %xmm0,%xmm1
  movups %xmm1,-0x20(%rbx)
  cmp    %rax,%rbx
  jne    L67
  mov    %ebp,%eax
  and    $0xfffffffc,%eax
  test   $0x3,%bpl
  je     L70
L54:
  pxor   %xmm1,%xmm1
  movslq %eax,%rdx
  cvtsi2sd %eax,%xmm1
  shl    $0x3,%rdx
  lea    (%r12,%rdx,1),%rcx
  movsd  (%rcx),%xmm0
  subsd  %xmm7,%xmm1
  subsd  %xmm8,%xmm0
  mulsd  %xmm2,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rcx)
  lea    0x1(%rax),%ecx
  cmp    %ecx,%ebp
  jle    L70
  pxor   %xmm1,%xmm1
  lea    0x8(%r12,%rdx,1),%rsi
  add    $0x2,%eax
  cvtsi2sd %ecx,%xmm1
  movsd  (%rsi),%xmm0
  subsd  %xmm8,%xmm0
  subsd  %xmm7,%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rsi)
  cmp    %eax,%ebp
  jle    L70
  pxor   %xmm1,%xmm1
  lea    0x10(%r12,%rdx,1),%rdx
  cvtsi2sd %eax,%xmm1
  movsd  (%rdx),%xmm0
  subsd  %xmm8,%xmm0
  subsd  %xmm7,%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rdx)
L70:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L60:
  add    $0x38,%rsp
  mov    %ebp,%edi
  mov    $0x2,%esi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1050 <pow@plt>
L12:
  xor    %eax,%eax
  jmp    L54
```

tool_calls: name: disassemble_data
arguments: data_label: D30
type: f64
name: disassemble_data
arguments: data_label: D22
type: f64
name: disassemble_data
arguments: data_label: D23
type: f32[2]
name: disassemble_data
arguments: data_label: D31
type: f32[4]
name: disassemble_data
arguments: data_label: D21
type: byte[16]

tool: D30: 1

tool: D22: 0.5

tool: {"D23": [0.0,-2.625]}

tool: {"D31": [0.0,1.401298464324817e-45,2.802596928649634e-45,4.203895392974451e-45]}

tool: {"D21": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

assistant: ```c
void dtrd(double *x, int npts) {
  double s1, s2, slope, avei, avex;
  int i;
  s1 = 0.0;
  s2 = 0.0;
  for (i = 0; i < npts; i++) {
    s1 = s1 + x[i];
    s2 = s2 + s1;
  }
  avei = 0.5 * ((double)npts + 1.0);
  avex = s1 / ((double)npts);
  slope = -12.0 * (s2 - avei * s1) / (npts * (pow(npts, 2) - 1.0));
  for (i = 0; i < npts; i++)
    x[i] = x[i] - avex - slope * ((double)i - avei);
}
```