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

```asm
<grad>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8d,-0x44(%rbp)
  mov    -0x44(%rbp),%ecx
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <mlnL@plt>
  movq   %xmm0,%rax
  movq   D27(%rip),%xmm0
  movq   %rax,%xmm2
  xorpd  %xmm0,%xmm2
  movapd %xmm2,%xmm0
  movsd  %xmm0,-0x18(%rbp)
  movl   $0x0,-0x20(%rbp)
  jmp    L2
L34:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x20(%rbp)
L2:
  mov    -0x20(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jle    L34
  movl   $0x1,-0x20(%rbp)
  jmp    L84
L56:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x44(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rxn_coor@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  call   <tanh@plt>
  movsd  D29(%rip),%xmm1
  addsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x40(%rbp),%rax
  movsd  (%rax),%xmm0
  addsd  -0x8(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movsd  %xmm0,(%rax)
  movl   $0x1,-0x1c(%rbp)
  jmp    L23
L99:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mulsd  -0x8(%rbp),%xmm0
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  addsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x1c(%rbp)
L23:
  mov    -0x1c(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jle    L99
  addl   $0x1,-0x20(%rbp)
L84:
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x20(%rbp),%xmm1
  mov    -0x30(%rbp),%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jae    L56
  movl   $0x1,-0x20(%rbp)
  jmp    L68
L88:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rcx
  mov    -0x44(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <rxn_coor@plt>
  movq   %xmm0,%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  movq   %rax,%xmm0
  call   <tanh@plt>
  movapd %xmm0,%xmm1
  movsd  D29(%rip),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x40(%rbp),%rax
  movsd  (%rax),%xmm0
  subsd  -0x8(%rbp),%xmm0
  mov    -0x40(%rbp),%rax
  movsd  %xmm0,(%rax)
  movl   $0x1,-0x1c(%rbp)
  jmp    L14
L64:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mulsd  -0x8(%rbp),%xmm1
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  subsd  %xmm1,%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x1c(%rbp)
L14:
  mov    -0x1c(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jle    L64
  addl   $0x1,-0x20(%rbp)
L68:
  pxor   %xmm1,%xmm1
  cvtsi2sdl -0x20(%rbp),%xmm1
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jae    L88
  movsd  -0x18(%rbp),%xmm0
  movq   D27(%rip),%xmm1
  xorpd  %xmm1,%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D27
data_type: f32[2]
name: unpack_data
arguments: label: D29
data_type: f64

tool: {"D27": [0.0,-0.0]}

tool: D29: 1

assistant: ```c
double grad(double *a, double **zA, double **zB, double *dmlnL, int m) {
  int i, j, k;
  double lnl, rk, C;
  lnl = -mlnL(a, zA, zB, m);
  for (i = 0; i <= m; i = i + 1) {
    dmlnL[i] = 0.0;
  }
  for (i = 1; i <= zA[0][0]; i = i + 1) {
    rk = rxn_coor(a, zA[i], m);
    C = 1.0 + tanh(rk);
    dmlnL[0] = dmlnL[0] + C;
    for (j = 1; j <= m; j = j + 1) {
      dmlnL[j] = dmlnL[j] + C * zA[i][j];
    }
  }
  for (i = 1; i <= zB[0][0]; i = i + 1) {
    rk = rxn_coor(a, zB[i], m);
    C = 1.0 - tanh(rk);
    dmlnL[0] = dmlnL[0] - C;
    for (j = 1; j <= m; j = j + 1) {
      dmlnL[j] = dmlnL[j] - C * zB[i][j];
    }
  }
  return (-lnl);
}
```