user: Translate the below assembly code into C programming language:

```asm
<cluster1d>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  movsd  %xmm0,-0x30(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8,-0x40(%rbp)
  mov    %r9,-0x48(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x48(%rbp),%rax
  movsd  %xmm0,(%rax)
  movl   $0x1,-0xc(%rbp)
  mov    -0x40(%rbp),%rax
  movl   $0x0,(%rax)
  movl   $0x1,-0x10(%rbp)
  jmp    L18
L40:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  comisd -0x30(%rbp),%xmm0
  jbe    L1
  cmpl   $0x1,-0xc(%rbp)
  jle    L34
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0xc(%rbp),%xmm1
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L34:
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  movl   $0x1,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x40(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L0
L1:
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x40(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0xc(%rbp)
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L0:
  addl   $0x1,-0x10(%rbp)
L18:
  mov    -0x10(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L40
  cmpl   $0x1,-0xc(%rbp)
  jle    L59
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0xc(%rbp),%xmm1
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  divsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
L59:
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  lea    0x1(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void cluster1d(double ar[], int n, int order[], double tol, int *nclusters, int ids[], double avgs[]) {
  int i, ncl;
  double dv;
  avgs[0] = ar[order[0]];
  ncl = 1;
  ids[0] = 0;
  for (i = 1; i < n; i++) {
    dv = ar[order[i]] - ar[order[i - 1]];
    if (dv > tol) {
      if (ncl > 1) {
        avgs[ids[i - 1]] = avgs[ids[i - 1]] / ncl;
      }
      ids[i] = ids[i - 1] + 1;
      ncl = 1;
      avgs[ids[i]] = ar[order[i]];
    } else {
      ids[i] = ids[i - 1];
      ncl = ncl + 1;
      avgs[ids[i]] = avgs[ids[i]] + ar[order[i]];
    }
  }
  if (ncl > 1) {
    avgs[ids[i - 1]] /= ncl;
  }
  *nclusters = ids[n - 1] + 1;
}
```