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

```asm
<contr_grad_eri>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x148,%rsp
  mov    0x250(%rsp),%eax
  mov    %rsi,0xe8(%rsp)
  mov    %rdx,0xf0(%rsp)
  mov    0x1a8(%rsp),%ebp
  mov    %rcx,0xf8(%rsp)
  mov    0x1b0(%rsp),%r12d
  mov    %r8d,0xa4(%rsp)
  mov    0x1b8(%rsp),%r15d
  mov    %r9d,0xa8(%rsp)
  movsd  %xmm0,0x38(%rsp)
  movsd  %xmm3,0x100(%rsp)
  movsd  %xmm4,0x108(%rsp)
  movsd  %xmm5,0x110(%rsp)
  movsd  %xmm6,0x40(%rsp)
  movsd  %xmm7,0x48(%rsp)
  cmp    $0x2,%eax
  ja     L19
  lea    D4(%rip),%rdx
  mov    (%rdx,%rax,4),%esi
  lea    D22(%rip),%rdx
  mov    (%rdx,%rax,4),%edi
  lea    D9(%rip),%rdx
  mov    (%rdx,%rax,4),%eax
  mov    %esi,0x9c(%rsp)
  mov    %edi,0xa0(%rsp)
  mov    %eax,0xe4(%rsp)
L118:
  mov    0x9c(%rsp),%eax
  mov    0xa0(%rsp),%edx
  lea    -0x1(%rbx),%esi
  imul   0xa8(%rsp),%edx
  mov    0xe4(%rsp),%edi
  mov    %esi,0x13c(%rsp)
  imul   0xa4(%rsp),%eax
  add    %edx,%eax
  mov    0x180(%rsp),%edx
  imul   %edi,%edx
  add    %edx,%eax
  mov    %eax,0xd8(%rsp)
  test   %eax,%eax
  jle    L62
  test   %esi,%esi
  js     L173
  mov    0x188(%rsp),%eax
  mov    0xe8(%rsp),%r11
  pxor   %xmm4,%xmm4
  mov    %r15d,%r13d
  mov    0xf0(%rsp),%rdx
  movsd  %xmm4,(%rsp)
  movsd  0x100(%rsp),%xmm5
  movsd  %xmm4,0xd0(%rsp)
  lea    -0x1(%rax),%ecx
  mov    0x1c0(%rsp),%eax
  mov    %ecx,0x138(%rsp)
  lea    -0x1(%rax),%r10d
  mov    0x200(%rsp),%eax
  mov    %r10d,0xe0(%rsp)
  sub    $0x1,%eax
  mov    %eax,0xac(%rsp)
  movslq %esi,%rax
  shl    $0x3,%rax
  add    %rax,%r11
  lea    (%rdx,%rax,1),%rbx
  lea    -0x8(%rdx,%rax,1),%rdx
  mov    %r11,0x80(%rsp)
  mov    0xf8(%rsp),%r11
  add    %rax,%r11
  mov    %esi,%eax
  mov    0x198(%rsp),%rsi
  shl    $0x3,%rax
  mov    %r11,0x88(%rsp)
  sub    %rax,%rdx
  movslq %ecx,%rax
  mov    %rdx,0x130(%rsp)
  mov    0x198(%rsp),%rdx
  shl    $0x3,%rax
  add    %rax,%rdx
  mov    %rdx,0x118(%rsp)
  mov    0x190(%rsp),%rdx
  add    %rax,%rdx
  add    0x1a0(%rsp),%rax
  mov    %rax,0x128(%rsp)
  movslq 0x188(%rsp),%rax
  mov    %rdx,0x120(%rsp)
  lea    -0x10(%rsi,%rax,8),%rdx
  mov    %ecx,%eax
  mov    0x1d0(%rsp),%rsi
  shl    $0x3,%rax
  sub    %rax,%rdx
  movslq %r10d,%rax
  shl    $0x3,%rax
  mov    %rdx,0xb0(%rsp)
  add    %rax,%rsi
  mov    %rsi,0xc0(%rsp)
  mov    0x1c8(%rsp),%rsi
  add    %rax,%rsi
  add    0x1d8(%rsp),%rax
  mov    %rax,0xc8(%rsp)
  mov    0x180(%rsp),%eax
  mov    %rsi,0xb8(%rsp)
  sub    %edi,%eax
  mov    %eax,0x94(%rsp)
  movsd  0x108(%rsp),%xmm6
  movsd  0x110(%rsp),%xmm7
  mov    %ebp,0x1a8(%rsp)
L209:
  mov    0x138(%rsp),%edx
  test   %edx,%edx
  js     L60
  mov    0x128(%rsp),%rax
  mov    %r12d,%r15d
  mov    %r13d,%r14d
  mov    %rax,0x78(%rsp)
  mov    0x120(%rsp),%rax
  mov    %rax,0x70(%rsp)
  mov    0x118(%rsp),%rax
  mov    %rax,0x68(%rsp)
L164:
  mov    0xe0(%rsp),%eax
  test   %eax,%eax
  js     L0
  mov    0xc8(%rsp),%rsi
  mov    0xb8(%rsp),%rdx
  mov    %eax,0x98(%rsp)
  mov    0xc0(%rsp),%rdi
  mov    %rsi,0x58(%rsp)
  mov    %rdx,0x60(%rsp)
  mov    %rdi,0x50(%rsp)
  xchg   %ax,%ax
L25:
  mov    0xac(%rsp),%eax
  test   %eax,%eax
  js     L95
  mov    0xa4(%rsp),%ebp
  sub    0x9c(%rsp),%ebp
  movslq %eax,%r13
  mov    %rbx,%rax
  mov    %ebp,%esi
  mov    0xa8(%rsp),%r12d
  mov    %r13,%rbx
  mov    %rax,%r13
  sub    0xa0(%rsp),%r12d
  mov    %r12d,%ebp
  mov    %esi,%r12d
  nopl   0x0(%rax)
L50:
  mov    0x68(%rsp),%rax
  movsd  0x0(%r13),%xmm0
  mov    %r14d,%r9d
  mov    %ebp,%esi
  mov    %r15d,%r8d
  mov    %r12d,%edi
  mulsd  (%rax),%xmm0
  mov    0x50(%rsp),%rax
  mulsd  (%rax),%xmm0
  mov    0x210(%rsp),%rax
  mulsd  (%rax,%rbx,8),%xmm0
  mov    0x208(%rsp),%rax
  movsd  %xmm0,0x8(%rsp)
  push   (%rax,%rbx,8)
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x238(%rsp),%rax
  push   (%rax,%rbx,8)
  sub    $0x1,%rbx
  push   0x258(%rsp)
  push   0x258(%rsp)
  push   0x258(%rsp)
  mov    0xa0(%rsp),%rax
  push   (%rax)
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0xb8(%rsp),%rax
  push   (%rax)
  push   0x248(%rsp)
  push   0xb8(%rsp)
  push   0xb8(%rsp)
  mov    0xf0(%rsp),%rax
  push   (%rax)
  mov    0x100(%rsp),%rax
  push   (%rax)
  mov    0x110(%rsp),%rax
  mov    0x238(%rsp),%ecx
  movsd  (%rax),%xmm4
  mov    0x124(%rsp),%edx
  mov    0x118(%rsp),%rax
  movsd  0xc8(%rsp),%xmm0
  movsd  %xmm7,0xc0(%rsp)
  movsd  %xmm6,0xb8(%rsp)
  movsd  %xmm5,0xb0(%rsp)
  movsd  (%rax),%xmm3
  movsd  %xmm2,0xa8(%rsp)
  movsd  %xmm1,0xa0(%rsp)
  call   <eri@plt>
  mulsd  0x98(%rsp),%xmm0
  addsd  0x90(%rsp),%xmm0
  movsd  %xmm0,0x90(%rsp)
  add    $0x90,%rsp
  test   %ebx,%ebx
  movsd  0x10(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm2
  movsd  0x20(%rsp),%xmm5
  movsd  0x28(%rsp),%xmm6
  movsd  0x30(%rsp),%xmm7
  jns    L50
  mov    %r13,%rbx
L95:
  subl   $0x1,0x98(%rsp)
  mov    0x98(%rsp),%eax
  subq   $0x8,0x50(%rsp)
  subq   $0x8,0x60(%rsp)
  subq   $0x8,0x58(%rsp)
  cmp    $0xffffffff,%eax
  jne    L25
L0:
  subq   $0x8,0x68(%rsp)
  mov    0x68(%rsp),%rax
  subq   $0x8,0x70(%rsp)
  subq   $0x8,0x78(%rsp)
  cmp    0xb0(%rsp),%rax
  jne    L164
  mov    %r15d,%r12d
  mov    %r14d,%r13d
L60:
  subq   $0x8,0x80(%rsp)
  sub    $0x8,%rbx
  subq   $0x8,0x88(%rsp)
  cmp    0x130(%rsp),%rbx
  jne    L209
  mov    0x1a8(%rsp),%ebp
  mov    %r13d,%r15d
L57:
  pxor   %xmm0,%xmm0
  mov    0x13c(%rsp),%edi
  cvtsi2sdl 0xd8(%rsp),%xmm0
  mulsd  (%rsp),%xmm0
  movsd  %xmm0,0xd8(%rsp)
  test   %edi,%edi
  js     L146
L53:
  mov    0x188(%rsp),%eax
  mov    %r15d,%r13d
  mov    0xf0(%rsp),%r11
  mov    0xe8(%rsp),%rdx
  movsd  0xd0(%rsp),%xmm4
  lea    -0x1(%rax),%esi
  mov    0x1c0(%rsp),%eax
  mov    %esi,0x138(%rsp)
  lea    -0x1(%rax),%ecx
  mov    0x200(%rsp),%eax
  movsd  %xmm4,(%rsp)
  mov    %ecx,0xe0(%rsp)
  sub    $0x1,%eax
  mov    %eax,0xac(%rsp)
  movslq %edi,%rax
  shl    $0x3,%rax
  add    %rax,%r11
  lea    (%rdx,%rax,1),%rbx
  lea    -0x8(%rdx,%rax,1),%rdx
  mov    %r11,0x88(%rsp)
  mov    0xf8(%rsp),%r11
  add    %rax,%r11
  mov    %edi,%eax
  mov    0x198(%rsp),%rdi
  shl    $0x3,%rax
  mov    %r11,0x80(%rsp)
  sub    %rax,%rdx
  movslq %esi,%rax
  shl    $0x3,%rax
  mov    %rdx,0xe8(%rsp)
  add    %rax,%rdi
  mov    %rdi,0x118(%rsp)
  mov    0x190(%rsp),%rdi
  add    %rax,%rdi
  add    0x1a0(%rsp),%rax
  mov    %rdi,0xf8(%rsp)
  mov    0x198(%rsp),%rdi
  mov    %rax,0xf0(%rsp)
  movslq 0x188(%rsp),%rax
  lea    -0x10(%rdi,%rax,8),%rdx
  mov    %esi,%eax
  mov    0x1d0(%rsp),%rdi
  shl    $0x3,%rax
  sub    %rax,%rdx
  movslq %ecx,%rax
  shl    $0x3,%rax
  mov    %rdx,0xb0(%rsp)
  add    %rax,%rdi
  mov    %rdi,0xc8(%rsp)
  mov    0x1c8(%rsp),%rdi
  add    %rax,%rdi
  add    0x1d8(%rsp),%rax
  mov    %rax,0xb8(%rsp)
  mov    0xe4(%rsp),%eax
  add    0x180(%rsp),%eax
  mov    %rdi,0xc0(%rsp)
  mov    %eax,0x94(%rsp)
  movsd  0x100(%rsp),%xmm5
  movsd  0x108(%rsp),%xmm6
  mov    %ebp,0x1a8(%rsp)
  movsd  0x110(%rsp),%xmm7
L179:
  mov    0x138(%rsp),%eax
  test   %eax,%eax
  js     L182
  mov    0xf0(%rsp),%rax
  mov    %r12d,%r15d
  mov    %r13d,%r14d
  mov    %rax,0x70(%rsp)
  mov    0xf8(%rsp),%rax
  mov    %rax,0x78(%rsp)
  mov    0x118(%rsp),%rax
  mov    %rax,0x68(%rsp)
  nopl   0x0(%rax)
L174:
  mov    0xe0(%rsp),%eax
  test   %eax,%eax
  js     L133
  mov    0xb8(%rsp),%rdi
  mov    0xc0(%rsp),%rsi
  mov    %eax,0x98(%rsp)
  mov    0xc8(%rsp),%rdx
  mov    %rdi,0x50(%rsp)
  mov    %rsi,0x58(%rsp)
  mov    %rdx,0x60(%rsp)
  nopl   (%rax)
L183:
  mov    0xac(%rsp),%eax
  test   %eax,%eax
  js     L126
  mov    0x9c(%rsp),%ebp
  add    0xa4(%rsp),%ebp
  movslq %eax,%r13
  mov    %ebp,%eax
  mov    0xa0(%rsp),%r12d
  mov    %r13,%rbp
  add    0xa8(%rsp),%r12d
  mov    %eax,%r13d
  nopl   0x0(%rax,%rax,1)
L30:
  movsd  (%rbx),%xmm4
  mov    %r14d,%r9d
  mov    %r15d,%r8d
  mov    %r12d,%esi
  mov    0x88(%rsp),%rax
  mov    %r13d,%edi
  movsd  (%rax),%xmm0
  mov    0x68(%rsp),%rax
  mulsd  %xmm4,%xmm0
  mulsd  (%rax),%xmm0
  mov    0x60(%rsp),%rax
  mulsd  (%rax),%xmm0
  mov    0x210(%rsp),%rax
  mulsd  (%rax,%rbp,8),%xmm0
  mov    0x208(%rsp),%rax
  movsd  %xmm0,0x8(%rsp)
  push   (%rax,%rbp,8)
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x250(%rsp),%eax
  push   %rax
  mov    0x238(%rsp),%rax
  push   (%rax,%rbp,8)
  sub    $0x1,%rbp
  push   0x258(%rsp)
  push   0x258(%rsp)
  push   0x258(%rsp)
  mov    0x98(%rsp),%rax
  push   (%rax)
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0x240(%rsp),%eax
  push   %rax
  mov    0xb0(%rsp),%rax
  push   (%rax)
  push   0x248(%rsp)
  push   0xb8(%rsp)
  push   0xb8(%rsp)
  mov    0xf8(%rsp),%rax
  push   (%rax)
  mov    0xf8(%rsp),%rax
  push   (%rax)
  mov    0x110(%rsp),%rax
  mov    0x238(%rsp),%ecx
  mov    0x124(%rsp),%edx
  movsd  (%rax),%xmm3
  movsd  0xc8(%rsp),%xmm0
  movsd  %xmm7,0xc0(%rsp)
  movsd  %xmm6,0xb8(%rsp)
  movsd  %xmm5,0xb0(%rsp)
  movsd  %xmm2,0xa8(%rsp)
  movsd  %xmm1,0xa0(%rsp)
  call   <eri@plt>
  mulsd  0x98(%rsp),%xmm0
  addsd  0x90(%rsp),%xmm0
  movsd  %xmm0,0x90(%rsp)
  add    $0x90,%rsp
  test   %ebp,%ebp
  movsd  0x10(%rsp),%xmm1
  movsd  0x18(%rsp),%xmm2
  movsd  0x20(%rsp),%xmm5
  movsd  0x28(%rsp),%xmm6
  movsd  0x30(%rsp),%xmm7
  jns    L30
L126:
  subl   $0x1,0x98(%rsp)
  mov    0x98(%rsp),%eax
  subq   $0x8,0x60(%rsp)
  subq   $0x8,0x58(%rsp)
  subq   $0x8,0x50(%rsp)
  cmp    $0xffffffff,%eax
  jne    L183
L133:
  subq   $0x8,0x68(%rsp)
  mov    0x68(%rsp),%rax
  subq   $0x8,0x78(%rsp)
  subq   $0x8,0x70(%rsp)
  cmp    %rax,0xb0(%rsp)
  jne    L174
  mov    %r15d,%r12d
  mov    %r14d,%r13d
L182:
  subq   $0x8,0x88(%rsp)
  sub    $0x8,%rbx
  subq   $0x8,0x80(%rsp)
  cmp    %rbx,0xe8(%rsp)
  jne    L179
L73:
  movsd  (%rsp),%xmm4
  movapd %xmm4,%xmm0
  subsd  0xd8(%rsp),%xmm0
  add    $0x148,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  addsd  %xmm4,%xmm0
  pop    %r14
  pop    %r15
  ret
L19:
  lea    D33(%rip),%rdi
  movsd  %xmm2,0x8(%rsp)
  movsd  %xmm1,(%rsp)
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  movsd  0x8(%rsp),%xmm2
  movsd  (%rsp),%xmm1
  jmp    L118
L62:
  mov    0x13c(%rsp),%edi
  pxor   %xmm4,%xmm4
  movsd  %xmm4,0xd0(%rsp)
  movsd  %xmm4,0xd8(%rsp)
  test   %edi,%edi
  jns    L53
L146:
  movsd  0xd0(%rsp),%xmm4
  movsd  %xmm4,(%rsp)
  jmp    L73
L173:
  pxor   %xmm4,%xmm4
  movsd  %xmm4,0xd0(%rsp)
  movsd  %xmm4,(%rsp)
  jmp    L57
```

tool_calls: name: parse_data
arguments: data_label: D4
type: string
name: parse_data
arguments: data_label: D22
type: f32
name: parse_data
arguments: data_label: D9
type: f32
name: parse_data
arguments: data_label: D33
type: string

tool: D4: 

tool: D22: 0

tool: D9: 0

tool: D33: contr_grad_eri: error unrecognized direction flag


assistant: ```c
double contr_grad_eri(int lena, double *aexps, double *acoefs, double *anorms, double xa, double ya, double za, int la, int ma, int na, int lenb, double *bexps, double *bcoefs, double *bnorms, double xb, double yb, double zb, int lb, int mb, int nb, int lenc, double *cexps, double *ccoefs, double *cnorms, double xc, double yc, double zc, int lc, int mc, int nc, int lend, double *dexps, double *dcoefs, double *dnorms, double xd, double yd, double zd, int ld, int md, int nd, int direction) {
  double val;
  int p, q, r, s;
  int l, m, n;
  double EE;
  switch (direction) {
  case 0:
    l = 1;
    m = 0;
    n = 0;
    break;
  case 1:
    l = 0;
    m = 1;
    n = 0;
    break;
  case 2:
    l = 0;
    m = 0;
    n = 1;
    break;
  default:
    printf("contr_grad_eri: error unrecognized direction flag\n");
    exit(-1);
  }
  val = 0.0;
  if ((l * la + m * ma + n * na) > 0) {
    for (p = lena - 1; p >= 0; p--)
      for (q = lenb - 1; q >= 0; q--)
        for (r = lenc - 1; r >= 0; r--)
          for (s = lend - 1; s >= 0; s--)
            val += acoefs[p] * bcoefs[q] * ccoefs[r] * dcoefs[s] * eri(xa, ya, za, anorms[p], la - l, ma - m, na - n, aexps[p], xb, yb, zb, bnorms[q], lb, mb, nb, bexps[q], xc, yc, zc, cnorms[r], lc, mc, nc, cexps[r], xd, yd, zd, dnorms[s], ld, md, nd, dexps[s]);
    ;
    val = val * (l * la + m * ma + n * na);
  }
  EE = -val;
  val = 0.0;
  for (p = lena - 1; p >= 0; p--)
    for (q = lenb - 1; q >= 0; q--)
      for (r = lenc - 1; r >= 0; r--)
        for (s = lend - 1; s >= 0; s--)
          val += aexps[p] * acoefs[p] * bcoefs[q] * ccoefs[r] * dcoefs[s] * eri(xa, ya, za, anorms[p], la + l, ma + m, na + n, aexps[p], xb, yb, zb, bnorms[q], lb, mb, nb, bexps[q], xc, yc, zc, cnorms[r], lc, mc, nc, cexps[r], xd, yd, zd, dnorms[s], ld, md, nd, dexps[s]);
  ;
  EE = EE + val + val;
  return EE;
}
```