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

```asm
<calculate_weights>:
  endbr64
  push   %r15
  mov    %edi,%eax
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %edi,0x3c(%rsp)
  mov    0x80(%rsp),%edi
  mov    %r8,0x10(%rsp)
  mov    %r9d,0x38(%rsp)
  movsd  %xmm0,0x8(%rsp)
  movsd  %xmm1,0x28(%rsp)
  test   %r9d,%r9d
  je     L35
  mov    %esi,0x3c(%rsp)
  mov    %eax,%r13d
L35:
  movsbl %dil,%edi
  call   <setmetric@plt>
  cltq
  mov    %rax,0x18(%rsp)
  movslq 0x3c(%rsp),%rax
  lea    0x0(,%rax,8),%ebx
  mov    %rax,0x30(%rsp)
  mov    %rax,%r15
  mov    %ebx,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L14
  xor    %esi,%esi
  mov    %ebx,%edx
  mov    %rax,%rdi
  call   <memset@plt>
  test   %r15d,%r15d
  jle    L14
  movsd  D36(%rip),%xmm0
  addsd  (%r12),%xmm0
  xor    %eax,%eax
  mov    $0x1,%ebx
  cmpl   $0x1,0x3c(%rsp)
  movsd  %xmm0,(%r12)
  je     L98
  mov    %r12,0x20(%rsp)
  mov    %rbp,%r15
  mov    0x10(%rsp),%rbp
  nopl   0x0(%rax)
L50:
  mov    0x20(%rsp),%rax
  movsd  D36(%rip),%xmm0
  xor    %r12d,%r12d
  mov    %ebx,0x10(%rsp)
  addsd  (%rax,%rbx,8),%xmm0
  movsd  %xmm0,(%rax,%rbx,8)
  mov    %rbp,%rax
  mov    %r15,%rbp
  mov    %r12,%r15
  mov    %r14,%r12
  mov    %rax,%r14
  jmp    L5
  nop
L102:
  add    $0x1,%r15
  cmp    %rbx,%r15
  je     L41
L5:
  sub    $0x8,%rsp
  mov    %r14,%r9
  mov    %rbp,%r8
  mov    %rbp,%rcx
  mov    0x40(%rsp),%eax
  mov    %r12,%rdx
  mov    %r12,%rsi
  mov    %r13d,%edi
  push   %rax
  push   %r15
  mov    0x28(%rsp),%eax
  push   %rax
  mov    0x38(%rsp),%rax
  call   *%rax
  movsd  0x28(%rsp),%xmm2
  add    $0x20,%rsp
  comisd %xmm0,%xmm2
  jbe    L102
  divsd  %xmm2,%xmm0
  movsd  D36(%rip),%xmm1
  subsd  %xmm0,%xmm1
  cvttsd2si %xmm1,%edi
  call   <log@plt>
  mulsd  0x28(%rsp),%xmm0
  call   <exp@plt>
  mov    0x20(%rsp),%rax
  movsd  (%rax,%rbx,8),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax,%rbx,8)
  addsd  (%rax,%r15,8),%xmm0
  movsd  %xmm0,(%rax,%r15,8)
  add    $0x1,%r15
  cmp    %rbx,%r15
  jne    L5
L41:
  mov    %r14,%rax
  mov    %r12,%r14
  mov    %r15,%r12
  mov    %rbp,%r15
  lea    0x1(%r12),%rbx
  mov    %rax,%rbp
  cmp    0x30(%rsp),%rbx
  jne    L50
  mov    0x3c(%rsp),%edx
  mov    0x20(%rsp),%r12
  movapd D36(%rip),%xmm1
  shr    %edx
  mov    %r12,%rax
  sub    $0x1,%edx
  shl    $0x4,%rdx
  lea    0x10(%r12,%rdx,1),%rdx
  nopw   0x0(%rax,%rax,1)
L89:
  movupd (%rax),%xmm5
  movapd %xmm1,%xmm0
  add    $0x10,%rax
  divpd  %xmm5,%xmm0
  movups %xmm0,-0x10(%rax)
  cmp    %rdx,%rax
  jne    L89
  mov    0x3c(%rsp),%ecx
  mov    %ecx,%eax
  and    $0xfffffffe,%eax
  and    $0x1,%ecx
  je     L14
L98:
  cltq
  movsd  D36(%rip),%xmm0
  lea    (%r12,%rax,8),%rax
  divsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
L14:
  add    $0x48,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D36
datatype: f64[2]

tool: {"D36": [1.0,1.0]}

assistant: ```c
double *calculate_weights(int nrows, int ncolumns, double **data, int **mask, double weights[], int transpose, char dist, double cutoff, double exponent) {
  int i, j;
  const int ndata = (transpose == 0) ? ncolumns : nrows;
  const int nelements = (transpose == 0) ? nrows : ncolumns;
  double (*metric)(int, double **, double **, int **, int **, const double[], int, int, int) = setmetric(dist);
  double *result = malloc(nelements * sizeof(double));
  if (!result)
    return NULL;
  memset(result, 0, nelements * sizeof(double));
  for (i = 0; i < nelements; i++) {
    result[i] += 1.0;
    for (j = 0; j < i; j++) {
      const double distance = metric(ndata, data, data, mask, mask, weights, i, j, transpose);
      if (distance < cutoff) {
        const double dweight = exp(exponent * log(1 - distance / cutoff));
        result[i] += dweight;
        result[j] += dweight;
      }
    }
  }
  for (i = 0; i < nelements; i++)
    result[i] = 1.0 / result[i];
  return result;
}
```