user: Please show me the C implementation that matches the assembly code listed below:

```asm
<paw_get_kinetic_energy>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  mov    %edi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rsi,0x38(%rsp)
  mov    %rdx,0x28(%rsp)
  mov    %rcx,0x40(%rsp)
  mov    %r8,0x48(%rsp)
  call   <paw_N_LogGrid@plt>
  mov    %eax,0x8(%rsp)
  xor    %eax,%eax
  call   <paw_log_amesh_LogGrid@plt>
  xor    %eax,%eax
  movsd  %xmm0,0x10(%rsp)
  call   <paw_r_LogGrid@plt>
  mov    %rax,%r15
  xor    %eax,%eax
  call   <paw_alloc_LogGrid@plt>
  mov    %rax,%rbp
  test   %r13d,%r13d
  jle    L48
  mov    0x8(%rsp),%r10d
  pxor   %xmm1,%xmm1
  movsd  D38(%rip),%xmm4
  xor    %r14d,%r14d
  movapd D38(%rip),%xmm5
  movsd  0x10(%rsp),%xmm3
  movsd  %xmm1,0x8(%rsp)
  lea    -0x1(%r10),%eax
  mov    %eax,0x58(%rsp)
  movslq %r13d,%rax
  mov    %rax,0x30(%rsp)
  mov    %r10d,%eax
  shr    %eax
  lea    -0x1(%rax),%r8d
  mov    %r10d,%eax
  and    $0xfffffffe,%eax
  add    $0x1,%r8
  movslq %eax,%r13
  mov    %eax,0x5c(%rsp)
  lea    0x8(%r15),%rax
  shl    $0x4,%r8
  shl    $0x3,%r13
  mov    %rax,0x50(%rsp)
  lea    (%r15,%r13,1),%rbx
  lea    0x0(%rbp,%r13,1),%r12
  mov    %rbx,%r11
  mov    %r12,%rbx
  mov    %r8,%r12
  nopl   0x0(%rax,%rax,1)
L68:
  test   %r10d,%r10d
  jle    L61
  mov    0x38(%rsp),%rdi
  pxor   %xmm0,%xmm0
  mov    0x48(%rsp),%rax
  pxor   %xmm2,%xmm2
  mov    (%rdi,%r14,4),%edx
  mov    (%rax,%r14,8),%rax
  mov    0x40(%rsp),%rdi
  cvtsi2sd %edx,%xmm0
  add    $0x1,%edx
  cmp    0x50(%rsp),%rbp
  setne  %cl
  cvtsi2sd %edx,%xmm2
  cmp    $0x1,%r10d
  mov    (%rdi,%r14,8),%rdx
  setne  %sil
  and    %esi,%ecx
  lea    0x8(%rax),%rsi
  mulsd  %xmm4,%xmm0
  cmp    %rsi,%rbp
  setne  %sil
  mulsd  %xmm0,%xmm2
  test   %sil,%cl
  je     L32
  lea    0x8(%rdx),%rcx
  cmp    %rcx,%rbp
  je     L32
  movapd %xmm3,%xmm8
  movapd %xmm2,%xmm7
  xor    %ecx,%ecx
  unpcklpd %xmm8,%xmm8
  unpcklpd %xmm7,%xmm7
  xchg   %ax,%ax
L91:
  movupd (%r15,%rcx,1),%xmm6
  movupd (%rax,%rcx,1),%xmm0
  movupd (%rax,%rcx,1),%xmm10
  movupd (%rdx,%rcx,1),%xmm11
  mulpd  %xmm5,%xmm0
  movapd %xmm6,%xmm9
  mulpd  %xmm8,%xmm9
  mulpd  %xmm6,%xmm6
  divpd  %xmm9,%xmm0
  mulpd  %xmm10,%xmm0
  divpd  %xmm9,%xmm0
  movapd %xmm6,%xmm9
  movapd %xmm7,%xmm6
  divpd  %xmm9,%xmm6
  mulpd  %xmm11,%xmm6
  mulpd  %xmm11,%xmm6
  addpd  %xmm6,%xmm0
  movups %xmm0,0x0(%rbp,%rcx,1)
  add    $0x10,%rcx
  cmp    %r12,%rcx
  jne    L91
  cmp    0x5c(%rsp),%r10d
  je     L61
  movsd  (%r11),%xmm0
  movsd  (%rax,%r13,1),%xmm8
  movapd %xmm3,%xmm7
  movsd  (%rdx,%r13,1),%xmm9
  mulsd  %xmm0,%xmm7
  movapd %xmm0,%xmm6
  mulsd  %xmm0,%xmm6
  divsd  %xmm6,%xmm2
  movapd %xmm2,%xmm0
  movapd %xmm8,%xmm2
  mulsd  %xmm4,%xmm2
  mulsd  %xmm9,%xmm0
  divsd  %xmm7,%xmm2
  mulsd  %xmm9,%xmm0
  mulsd  %xmm8,%xmm2
  divsd  %xmm7,%xmm2
  addsd  %xmm2,%xmm0
  movsd  %xmm0,(%rbx)
L61:
  mov    0x58(%rsp),%esi
  movapd %xmm1,%xmm0
  mov    %rbp,%rdi
  mov    %r11,0x20(%rsp)
  mov    %r10d,0x1c(%rsp)
  movsd  %xmm3,0x10(%rsp)
  call   <paw_Def_Integr@plt>
  mov    0x28(%rsp),%rax
  movsd  0x10(%rsp),%xmm3
  pxor   %xmm1,%xmm1
  movapd D38(%rip),%xmm5
  mov    0x1c(%rsp),%r10d
  mulsd  (%rax,%r14,8),%xmm0
  add    $0x1,%r14
  cmp    0x30(%rsp),%r14
  addsd  0x8(%rsp),%xmm0
  mov    D38(%rip),%rax
  mov    0x20(%rsp),%r11
  movq   %rax,%xmm4
  movsd  %xmm0,0x8(%rsp)
  jne    L68
L28:
  mov    %rbp,%rdi
  call   <paw_dealloc_LogGrid@plt>
  movsd  0x8(%rsp),%xmm0
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L32:
  mov    0x58(%rsp),%edi
  xor    %ecx,%ecx
  xchg   %ax,%ax
L99:
  movsd  (%r15,%rcx,8),%xmm0
  movsd  (%rax,%rcx,8),%xmm8
  movapd %xmm3,%xmm7
  mov    %rcx,%rsi
  movsd  (%rdx,%rcx,8),%xmm9
  mulsd  %xmm0,%xmm7
  movapd %xmm0,%xmm6
  mulsd  %xmm0,%xmm6
  movapd %xmm2,%xmm0
  divsd  %xmm6,%xmm0
  movapd %xmm8,%xmm6
  mulsd  %xmm4,%xmm6
  divsd  %xmm7,%xmm6
  mulsd  %xmm9,%xmm0
  mulsd  %xmm9,%xmm0
  mulsd  %xmm8,%xmm6
  divsd  %xmm7,%xmm6
  addsd  %xmm6,%xmm0
  movsd  %xmm0,0x0(%rbp,%rcx,8)
  add    $0x1,%rcx
  cmp    %rsi,%rdi
  jne    L99
  jmp    L61
L48:
  pxor   %xmm5,%xmm5
  movsd  %xmm5,0x8(%rsp)
  jmp    L28
```

tool_calls: name: unpack_data
arguments: data_tag: D38
datatype: f64[2]

tool: {"D38": [0.5,0.5]}

assistant: ```c
double paw_get_kinetic_energy(int num_states, int *l, double *fill, double **psi, double **psi_prime) {
  int i;
  int k;
  int Ngrid;
  double ekin;
  double ekin_total;
  double log_amesh;
  double *f;
  double *r;
  Ngrid = paw_N_LogGrid();
  log_amesh = paw_log_amesh_LogGrid();
  r = paw_r_LogGrid();
  f = paw_alloc_LogGrid();
  ekin_total = 0.0;
  for (i = 0; i <= num_states - 1; i++) {
    for (k = 0; k <= Ngrid - 1; k++) {
      f[k] = 0.5 * psi_prime[i][k] / (r[k] * log_amesh) * psi_prime[i][k] / (r[k] * log_amesh) + 0.5 * l[i] * (l[i] + 1) / (r[k] * r[k]) * psi[i][k] * psi[i][k];
    }
    ekin = paw_Def_Integr(0.0, f, 0.0, Ngrid - 1);
    ekin_total = ekin_total + ekin * fill[i];
  }
  paw_dealloc_LogGrid(f);
  return ekin_total;
}
```