user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<ff_dm_quad>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    0xe0(%rsp),%rax
  mov    %edi,0x6c(%rsp)
  mov    %rsi,0x20(%rsp)
  mov    %rax,0x50(%rsp)
  mov    0xe8(%rsp),%rax
  mov    %rdx,0x70(%rsp)
  mov    %rcx,0x78(%rsp)
  mov    %r8,0x40(%rsp)
  mov    %r9,0x48(%rsp)
  mov    %rax,0x58(%rsp)
  movsd  %xmm0,0x38(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  jle    L2
  mov    $0x1,%r14d
  movslq %edi,%rax
  mov    %edi,0x68(%rsp)
  lea    0x80(%rsp),%r13
  mov    %r14,%r15
  mov    %rax,0x60(%rsp)
  movq   $0x0,0x10(%rsp)
  mov    %r15d,0x34(%rsp)
  cmp    0x60(%rsp),%r15
  je     L46
  nopl   0x0(%rax,%rax,1)
L120:
  test   %r15d,%r15d
  jle    L31
  mov    0x34(%rsp),%eax
  mov    0x20(%rsp),%rdi
  xor    %ebx,%ebx
  lea    (%rax,%rax,2),%eax
  cltq
  lea    (%rdi,%rax,8),%r14
  movslq 0x68(%rsp),%rax
  mov    0x70(%rsp),%rdi
  shl    $0x3,%rax
  lea    (%rdi,%rax,1),%rbp
  add    0x78(%rsp),%rax
  mov    %rax,0x28(%rsp)
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L45:
  add    $0x1,%rbx
  cmp    %r15,%rbx
  je     L31
L79:
  movsd  0x0(%rbp,%rbx,8),%xmm2
  pxor   %xmm5,%xmm5
  mov    %ebx,%r12d
  comisd %xmm5,%xmm2
  movsd  %xmm2,0x8(%rsp)
  jbe    L45
  mov    0x28(%rsp),%rax
  mov    0x20(%rsp),%rdx
  mov    %r14,%rdi
  mov    0x50(%rsp),%r9
  mov    0x48(%rsp),%r8
  movsd  (%rax,%rbx,8),%xmm3
  lea    (%rbx,%rbx,2),%eax
  mov    0x40(%rsp),%rcx
  cltq
  lea    (%rdx,%rax,8),%rsi
  mov    %r13,%rdx
  movsd  %xmm3,0x18(%rsp)
  call   <calc_delta@plt>
  pxor   %xmm7,%xmm7
  movsd  0x80(%rsp),%xmm0
  movsd  0x18(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm2
  mulsd  %xmm0,%xmm0
  movapd %xmm0,%xmm1
  movsd  0x88(%rsp),%xmm0
  mulsd  %xmm0,%xmm0
  addsd  %xmm0,%xmm1
  movsd  0x90(%rsp),%xmm0
  mulsd  %xmm0,%xmm0
  addsd  %xmm1,%xmm0
  ucomisd %xmm0,%xmm7
  ja     L17
  sqrtsd %xmm0,%xmm0
L97:
  movsd  0x38(%rsp),%xmm6
  movapd %xmm0,%xmm4
  mov    0x58(%rsp),%rcx
  subsd  %xmm2,%xmm4
  movapd %xmm6,%xmm1
  mulsd  %xmm3,%xmm1
  mulsd  %xmm4,%xmm1
  mulsd  %xmm4,%xmm1
  addsd  0x10(%rsp),%xmm1
  movsd  %xmm1,0x10(%rsp)
  test   %rcx,%rcx
  je     L45
  movapd %xmm6,%xmm1
  mov    0x34(%rsp),%edi
  mov    %r13,%rdx
  mov    %r12d,%esi
  addsd  %xmm6,%xmm1
  add    $0x1,%rbx
  mulsd  %xmm3,%xmm1
  mulsd  %xmm4,%xmm1
  divsd  %xmm0,%xmm1
  movapd %xmm1,%xmm0
  call   <add_grad@plt>
  cmp    %r15,%rbx
  jne    L79
L31:
  add    $0x1,%r15
  mov    0x6c(%rsp),%edi
  add    %edi,0x68(%rsp)
  mov    %r15d,0x34(%rsp)
  cmp    0x60(%rsp),%r15
  jne    L120
L46:
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L82
  movsd  0x10(%rsp),%xmm0
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L2:
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x10(%rsp)
  jmp    L46
L17:
  movsd  %xmm3,0x18(%rsp)
  movsd  %xmm2,0x8(%rsp)
  call   <sqrt@plt>
  movsd  0x18(%rsp),%xmm3
  movsd  0x8(%rsp),%xmm2
  jmp    L97
L82:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
double ff_dm_quad(int n, double *cor, double *dm0, double *dmk, double amp, double *unitcell, double *unitcell_reciproke, int *unitcell_active, double *gradient) {
  int i, j;
  double d, d0, k, tmp, result;
  double delta[3];
  result = 0.0;
  for (i = 0; i < n; i++) {
    for (j = 0; j < i; j++) {
      d0 = dm0[i * n + j];
      k = dmk[i * n + j];
      if (d0 > 0) {
        calc_delta(cor + 3 * i, cor + 3 * j, delta, unitcell, unitcell_reciproke, unitcell_active);
        tmp = delta[0];
        d = tmp * tmp;
        tmp = delta[1];
        d += tmp * tmp;
        tmp = delta[2];
        d += tmp * tmp;
        d = sqrt(d);
        tmp = (d - d0);
        result += amp * k * tmp * tmp;
        if (gradient != NULL) {
          tmp = 2 * amp * k * tmp / d;
          add_grad(i, j, tmp, delta, gradient);
        }
      }
    }
  }
  return result;
}
```