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

```asm
<R_Hartree>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  movq   %xmm0,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  call   <N_LogGrid@plt>
  mov    %eax,0x18(%rsp)
  mov    %eax,%r15d
  xor    %eax,%eax
  call   <log_amesh_LogGrid@plt>
  pxor   %xmm6,%xmm6
  cvtsi2sd %eax,%xmm6
  xor    %eax,%eax
  movsd  %xmm6,(%rsp)
  call   <r_LogGrid@plt>
  movslq %eax,%rbx
  xor    %eax,%eax
  call   <alloc_LogGrid@plt>
  movslq %eax,%rbp
  test   %r15d,%r15d
  jle    L115
  lea    -0x1(%r15),%eax
  mov    %rbp,%rsi
  mov    %r12,%rcx
  mov    %eax,0x1c(%rsp)
  lea    0x8(%rbx,%rax,8),%rdi
  sub    %rbx,%rsi
  mov    %rbx,%rax
  sub    %rbx,%rcx
  nopl   0x0(%rax,%rax,1)
L21:
  movsd  (%rax),%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  (%rsp),%xmm0
  mulsd  (%rcx,%rax,1),%xmm0
  movsd  %xmm0,(%rsi,%rax,1)
  add    $0x8,%rax
  cmp    %rdi,%rax
  jne    L21
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <Zero_LogGrid@plt>
  movslq 0x18(%rsp),%rax
  mov    %rax,%rdx
  shl    $0x3,%rax
  mov    %r14,-0x8(%r13,%rax,1)
  mov    %r14,-0x10(%r13,%rax,1)
  mov    %r14,-0x18(%r13,%rax,1)
  lea    -0x3(%rdx),%r14d
  movslq %r14d,%rax
  mov    %rax,0x10(%rsp)
  mov    %rax,%r15
  test   %r14d,%r14d
  jle    L118
  nopl   0x0(%rax)
L64:
  movsd  0x0(%r13,%r15,8),%xmm4
  mov    %r15d,%edi
  mov    %rbp,%rsi
  xor    %eax,%eax
  movsd  %xmm4,0x8(%rsp)
  call   <Corrector_In_F@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  addsd  0x8(%rsp),%xmm0
  movsd  %xmm0,-0x8(%r13,%r15,8)
  sub    $0x1,%r15
  test   %r15d,%r15d
  jg     L64
  mov    0x18(%rsp),%eax
  test   %eax,%eax
  jle    L8
L118:
  mov    %rbp,%rdi
  mov    %r12,%rsi
  mov    %rbx,%rax
  xor    %ecx,%ecx
  sub    %rbx,%rdi
  sub    %rbx,%rsi
  nopl   0x0(%rax)
L68:
  movsd  (%rax),%xmm0
  add    $0x1,%ecx
  mulsd  %xmm0,%xmm0
  mulsd  (%rsp),%xmm0
  mulsd  (%rsi,%rax,1),%xmm0
  movsd  %xmm0,(%rdi,%rax,1)
  add    $0x8,%rax
  cmp    %ecx,0x18(%rsp)
  jg     L68
  test   %r14d,%r14d
  jle    L30
  movslq %r14d,%rax
  mov    %rax,0x10(%rsp)
L8:
  mov    0x10(%rsp),%r15
  pxor   %xmm1,%xmm1
  lea    -0x8(%rbx,%r15,8),%r14
  nop
L94:
  mov    %r15d,%edi
  mov    %rbp,%rsi
  xor    %eax,%eax
  movsd  %xmm1,(%rsp)
  call   <Corrector_In_F@plt>
  pxor   %xmm0,%xmm0
  movsd  (%rsp),%xmm1
  movsd  (%r14),%xmm2
  cvtsi2sd %eax,%xmm0
  sub    $0x8,%r14
  addsd  %xmm0,%xmm1
  movsd  -0x8(%r13,%r15,8),%xmm0
  mulsd  %xmm1,%xmm2
  subsd  %xmm2,%xmm0
  movsd  %xmm0,-0x8(%r13,%r15,8)
  sub    $0x1,%r15
  test   %r15d,%r15d
  jg     L94
L30:
  mov    0x18(%rsp),%edx
  test   %edx,%edx
  jle    L106
  mov    0x1c(%rsp),%eax
  sub    %r13,%rbx
  lea    0x0(,%rax,8),%rdx
  mov    %r13,%rax
  lea    0x8(%r13,%rdx,1),%rcx
  nopw   0x0(%rax,%rax,1)
L9:
  movsd  (%rax),%xmm0
  divsd  (%rbx,%rax,1),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rax,%rcx
  jne    L9
  lea    0x8(%rdx,%rbp,1),%rcx
  mov    %r13,%rdx
  mov    %rbp,%rax
  sub    %rbp,%r12
  sub    %rbp,%rdx
  nopl   0x0(%rax,%rax,1)
L88:
  movsd  (%r12,%rax,1),%xmm0
  mulsd  (%rdx,%rax,1),%xmm0
  add    $0x8,%rax
  movsd  %xmm0,-0x8(%rax)
  cmp    %rcx,%rax
  jne    L88
L106:
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <Integrate_LogGrid@plt>
  mov    %rbp,%rdi
  mov    %eax,%ebx
  xor    %eax,%eax
  call   <dealloc_LogGrid@plt>
  add    $0x28,%rsp
  pxor   %xmm0,%xmm0
  cvtsi2sd %ebx,%xmm0
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L115:
  mov    %r13,%rdi
  xor    %eax,%eax
  call   <Zero_LogGrid@plt>
  movslq 0x18(%rsp),%rax
  shl    $0x3,%rax
  mov    %r14,-0x8(%r13,%rax,1)
  mov    %r14,-0x10(%r13,%rax,1)
  mov    %r14,-0x18(%r13,%rax,1)
  jmp    L106
```

assistant: ```c
double R_Hartree(n, charge, Vh)
double n[], charge, Vh[];
{
  int i, Ngrid;
  double log_amesh;
  double *rgrid, *tmp;
  double r, r2, r3, tt;
  double E;
  Ngrid = N_LogGrid();
  log_amesh = log_amesh_LogGrid();
  rgrid = r_LogGrid();
  tmp = alloc_LogGrid();
  for (i = 0; i < Ngrid; ++i) {
    r = rgrid[i];
    r3 = r * r * r;
    tmp[i] = (log_amesh * r3) * n[i];
  }
  Zero_LogGrid(Vh);
  Vh[Ngrid - 1] = charge;
  Vh[Ngrid - 2] = charge;
  Vh[Ngrid - 3] = charge;
  for (i = (Ngrid - 3); i > 0; --i) {
    Vh[i - 1] = Vh[i] + Corrector_In_F(i, tmp);
  }
  for (i = 0; i < Ngrid; ++i) {
    r = rgrid[i];
    r2 = r * r;
    tmp[i] = (log_amesh * r2) * n[i];
  }
  tt = 0.0;
  for (i = (Ngrid - 3); i > 0; --i) {
    tt = tt + Corrector_In_F(i, tmp);
    Vh[i - 1] = Vh[i - 1] - rgrid[i - 1] * tt;
  }
  for (i = 0; i < Ngrid; ++i)
    Vh[i] = Vh[i] / rgrid[i];
  for (i = 0; i < Ngrid; ++i) {
    tmp[i] = n[i] * Vh[i];
  }
  E = Integrate_LogGrid(tmp);
  dealloc_LogGrid(tmp);
  return E;
}
```