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
  sub    $0x108,%rsp
  mov    %edi,0xc0(%rsp)
  mov    %rsi,0xc8(%rsp)
  mov    %rdx,0xd0(%rsp)
  mov    %rcx,0xd8(%rsp)
  movsd  %xmm0,0x28(%rsp)
  movsd  %xmm1,0x30(%rsp)
  movsd  %xmm2,0x38(%rsp)
  mov    %r8d,0x20(%rsp)
  mov    %r9d,0x24(%rsp)
  movsd  %xmm3,0x40(%rsp)
  movsd  %xmm4,0x48(%rsp)
  movsd  %xmm5,0x50(%rsp)
  movsd  %xmm6,0x58(%rsp)
  movsd  %xmm7,0x60(%rsp)
  cmpl   $0x1,0x210(%rsp)
  je     L138
  cmpl   $0x2,0x210(%rsp)
  je     L222
  cmpl   $0x0,0x210(%rsp)
  je     L219
  lea    D5(%rip),%rdi
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
  jmp    L246
L138:
  movl   $0x0,0x8c(%rsp)
  movl   $0x0,0x1c(%rsp)
  jmp    L246
L222:
  movl   $0x1,0x8c(%rsp)
  movl   $0x0,0x210(%rsp)
  movl   $0x0,0x1c(%rsp)
L246:
  mov    0x1c(%rsp),%eax
  imul   0x20(%rsp),%eax
  mov    0x24(%rsp),%edx
  imul   0x210(%rsp),%edx
  add    %edx,%eax
  mov    0x8c(%rsp),%edx
  imul   0x140(%rsp),%edx
  add    %edx,%eax
  mov    %eax,0xe4(%rsp)
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0xb8(%rsp)
  test   %eax,%eax
  jle    L155
  mov    0xc0(%rsp),%ecx
  mov    %ecx,%eax
  sub    $0x1,%eax
  js     L35
  cltq
  shl    $0x3,%rax
  mov    0xd0(%rsp),%rdx
  lea    (%rdx,%rax,1),%r15
  mov    0xc8(%rsp),%rbx
  add    %rax,%rbx
  mov    %rbx,0x78(%rsp)
  mov    0xd8(%rsp),%rbx
  add    %rax,%rbx
  mov    %rbx,0x80(%rsp)
  lea    -0x8(%rdx,%rax,1),%rdx
  lea    -0x1(%rcx),%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0xf8(%rsp)
  mov    0x148(%rsp),%eax
  sub    $0x1,%eax
  movslq %eax,%rdx
  shl    $0x3,%rdx
  mov    %rdx,%rcx
  add    0x158(%rsp),%rcx
  mov    %rcx,0xb8(%rsp)
  mov    %rdx,%rcx
  add    0x150(%rsp),%rcx
  mov    %rcx,0xe8(%rsp)
  add    0x160(%rsp),%rdx
  mov    %rdx,0xf0(%rsp)
  movslq 0x148(%rsp),%rdx
  mov    0x158(%rsp),%rcx
  lea    -0x10(%rcx,%rdx,8),%rdx
  mov    %eax,%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0x98(%rsp)
  mov    0x180(%rsp),%eax
  sub    $0x1,%eax
  movslq %eax,%rdx
  shl    $0x3,%rdx
  mov    %rdx,%rcx
  add    0x190(%rsp),%rcx
  mov    %rcx,0xa0(%rsp)
  mov    %rdx,%rcx
  add    0x188(%rsp),%rcx
  mov    %rcx,0xa8(%rsp)
  add    0x198(%rsp),%rdx
  mov    %rdx,0xb0(%rsp)
  movslq 0x180(%rsp),%rdx
  mov    0x190(%rsp),%rcx
  lea    -0x10(%rcx,%rdx,8),%rdx
  mov    %eax,%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0x90(%rsp)
  movsd  %xmm7,0x8(%rsp)
  mov    0x1c0(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0xe0(%rsp)
  jmp    L175
L219:
  mov    0x210(%rsp),%eax
  mov    %eax,0x8c(%rsp)
  movl   $0x1,0x1c(%rsp)
  jmp    L246
L221:
  movsd  (%r15),%xmm0
  mulsd  (%r14),%xmm0
  mulsd  0x0(%rbp),%xmm0
  mov    0x1d0(%rsp),%rax
  mulsd  (%rax,%rbx,8),%xmm0
  movsd  %xmm0,0x10(%rsp)
  mov    0x24(%rsp),%esi
  sub    0x210(%rsp),%esi
  mov    0x20(%rsp),%edi
  sub    0x1c(%rsp),%edi
  mov    0x1c8(%rsp),%rax
  push   (%rax,%rbx,8)
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x1f8(%rsp),%rax
  push   (%rax,%rbx,8)
  push   0x218(%rsp)
  push   0x218(%rsp)
  push   0x218(%rsp)
  push   (%r12)
  mov    0x200(%rsp),%eax
  push   %rax
  mov    0x200(%rsp),%eax
  push   %rax
  mov    0x200(%rsp),%eax
  push   %rax
  push   0x0(%r13)
  push   0x208(%rsp)
  push   0xd0(%rsp)
  push   0xd0(%rsp)
  mov    0xe8(%rsp),%rax
  push   (%rax)
  mov    0xf8(%rsp),%rax
  push   (%rax)
  mov    0x208(%rsp),%r9d
  mov    0x200(%rsp),%r8d
  mov    0x1f8(%rsp),%ecx
  movsd  0xe0(%rsp),%xmm7
  movsd  0xd8(%rsp),%xmm6
  movsd  0xd0(%rsp),%xmm5
  mov    0x108(%rsp),%rax
  movsd  (%rax),%xmm4
  mov    0x118(%rsp),%edx
  mov    0x110(%rsp),%rax
  movsd  (%rax),%xmm3
  movsd  0xc8(%rsp),%xmm2
  movsd  0xc0(%rsp),%xmm1
  movsd  0xb8(%rsp),%xmm0
  call   <eri@plt>
  mulsd  0xa0(%rsp),%xmm0
  addsd  0x98(%rsp),%xmm0
  movsd  %xmm0,0x98(%rsp)
  sub    $0x1,%rbx
  add    $0x90,%rsp
  test   %ebx,%ebx
  jns    L221
L255:
  sub    $0x8,%rbp
  sub    $0x8,%r12
  sub    $0x8,%r13
  cmp    0x90(%rsp),%rbp
  je     L220
L30:
  mov    0xe0(%rsp),%eax
  test   %eax,%eax
  js     L255
  movslq %eax,%rbx
  mov    0x140(%rsp),%eax
  sub    0x8c(%rsp),%eax
  mov    %eax,0x88(%rsp)
  jmp    L221
L220:
  sub    $0x8,%r14
  subq   $0x8,0x68(%rsp)
  subq   $0x8,0x70(%rsp)
  cmp    0x98(%rsp),%r14
  je     L54
L142:
  cmpl   $0x0,0x180(%rsp)
  jle    L220
  mov    0xb0(%rsp),%r13
  mov    0xa8(%rsp),%r12
  mov    0xa0(%rsp),%rbp
  jmp    L30
L54:
  sub    $0x8,%r15
  subq   $0x8,0x78(%rsp)
  subq   $0x8,0x80(%rsp)
  cmp    0xf8(%rsp),%r15
  je     L130
L175:
  cmpl   $0x0,0x148(%rsp)
  jle    L54
  mov    0xf0(%rsp),%rax
  mov    %rax,0x70(%rsp)
  mov    0xe8(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0xb8(%rsp),%r14
  jmp    L142
L35:
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x8(%rsp)
L130:
  pxor   %xmm0,%xmm0
  cvtsi2sdl 0xe4(%rsp),%xmm0
  mulsd  0x8(%rsp),%xmm0
  movsd  %xmm0,0xb8(%rsp)
L155:
  mov    0xc0(%rsp),%ecx
  mov    %ecx,%eax
  sub    $0x1,%eax
  js     L135
  cltq
  shl    $0x3,%rax
  mov    0xc8(%rsp),%rdx
  lea    (%rdx,%rax,1),%r15
  mov    0xd0(%rsp),%rbx
  add    %rax,%rbx
  mov    %rbx,0x78(%rsp)
  mov    0xd8(%rsp),%rbx
  add    %rax,%rbx
  mov    %rbx,0x80(%rsp)
  lea    -0x8(%rdx,%rax,1),%rdx
  lea    -0x1(%rcx),%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0xd8(%rsp)
  mov    0x148(%rsp),%eax
  sub    $0x1,%eax
  movslq %eax,%rdx
  shl    $0x3,%rdx
  mov    %rdx,%rcx
  add    0x158(%rsp),%rcx
  mov    %rcx,0xc0(%rsp)
  mov    %rdx,%rcx
  add    0x150(%rsp),%rcx
  mov    %rcx,0xc8(%rsp)
  add    0x160(%rsp),%rdx
  mov    %rdx,0xd0(%rsp)
  movslq 0x148(%rsp),%rdx
  mov    0x158(%rsp),%rcx
  lea    -0x10(%rcx,%rdx,8),%rdx
  mov    %eax,%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0x98(%rsp)
  mov    0x180(%rsp),%eax
  sub    $0x1,%eax
  movslq %eax,%rdx
  shl    $0x3,%rdx
  mov    %rdx,%rcx
  add    0x190(%rsp),%rcx
  mov    %rcx,0xb0(%rsp)
  mov    %rdx,%rcx
  add    0x188(%rsp),%rcx
  mov    %rcx,0xa8(%rsp)
  add    0x198(%rsp),%rdx
  mov    %rdx,0xa0(%rsp)
  movslq 0x180(%rsp),%rdx
  mov    0x190(%rsp),%rcx
  lea    -0x10(%rcx,%rdx,8),%rdx
  mov    %eax,%eax
  shl    $0x3,%rax
  sub    %rax,%rdx
  mov    %rdx,0x90(%rsp)
  pxor   %xmm7,%xmm7
  movsd  %xmm7,0x8(%rsp)
  mov    0x1c0(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0xe0(%rsp)
L232:
  cmpl   $0x0,0x148(%rsp)
  jle    L63
  mov    0xd0(%rsp),%rax
  mov    %rax,0x70(%rsp)
  mov    0xc8(%rsp),%rax
  mov    %rax,0x68(%rsp)
  mov    0xc0(%rsp),%r14
L201:
  cmpl   $0x0,0x180(%rsp)
  jle    L5
  mov    0xa0(%rsp),%r13
  mov    0xa8(%rsp),%r12
  mov    0xb0(%rsp),%rbp
L84:
  mov    0xe0(%rsp),%eax
  test   %eax,%eax
  js     L217
  movslq %eax,%rbx
  mov    0x8c(%rsp),%eax
  add    0x140(%rsp),%eax
  mov    %eax,0x88(%rsp)
L126:
  movsd  (%r15),%xmm4
  mov    0x78(%rsp),%rax
  movapd %xmm4,%xmm0
  mulsd  (%rax),%xmm0
  mulsd  (%r14),%xmm0
  mulsd  0x0(%rbp),%xmm0
  mov    0x1d0(%rsp),%rax
  mulsd  (%rax,%rbx,8),%xmm0
  movsd  %xmm0,0x10(%rsp)
  mov    0x24(%rsp),%esi
  add    0x210(%rsp),%esi
  mov    0x1c(%rsp),%edi
  add    0x20(%rsp),%edi
  mov    0x1c8(%rsp),%rax
  push   (%rax,%rbx,8)
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x210(%rsp),%eax
  push   %rax
  mov    0x1f8(%rsp),%rax
  push   (%rax,%rbx,8)
  push   0x218(%rsp)
  push   0x218(%rsp)
  push   0x218(%rsp)
  push   (%r12)
  mov    0x200(%rsp),%eax
  push   %rax
  mov    0x200(%rsp),%eax
  push   %rax
  mov    0x200(%rsp),%eax
  push   %rax
  push   0x0(%r13)
  push   0x208(%rsp)
  push   0xd0(%rsp)
  push   0xd0(%rsp)
  mov    0xe8(%rsp),%rax
  push   (%rax)
  mov    0xf8(%rsp),%rax
  push   (%rax)
  mov    0x208(%rsp),%r9d
  mov    0x200(%rsp),%r8d
  mov    0x1f8(%rsp),%ecx
  movsd  0xe0(%rsp),%xmm7
  movsd  0xd8(%rsp),%xmm6
  movsd  0xd0(%rsp),%xmm5
  mov    0x118(%rsp),%edx
  mov    0x110(%rsp),%rax
  movsd  (%rax),%xmm3
  movsd  0xc8(%rsp),%xmm2
  movsd  0xc0(%rsp),%xmm1
  movsd  0xb8(%rsp),%xmm0
  call   <eri@plt>
  mulsd  0xa0(%rsp),%xmm0
  addsd  0x98(%rsp),%xmm0
  movsd  %xmm0,0x98(%rsp)
  sub    $0x1,%rbx
  add    $0x90,%rsp
  test   %ebx,%ebx
  jns    L126
L217:
  sub    $0x8,%rbp
  sub    $0x8,%r12
  sub    $0x8,%r13
  cmp    0x90(%rsp),%rbp
  jne    L84
L5:
  sub    $0x8,%r14
  subq   $0x8,0x68(%rsp)
  subq   $0x8,0x70(%rsp)
  cmp    0x98(%rsp),%r14
  jne    L201
L63:
  sub    $0x8,%r15
  subq   $0x8,0x78(%rsp)
  subq   $0x8,0x80(%rsp)
  cmp    0xd8(%rsp),%r15
  jne    L232
L210:
  movsd  0x8(%rsp),%xmm6
  movapd %xmm6,%xmm0
  subsd  0xb8(%rsp),%xmm0
  addsd  %xmm6,%xmm0
  add    $0x108,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L135:
  pxor   %xmm6,%xmm6
  movsd  %xmm6,0x8(%rsp)
  jmp    L210
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D5
datatype: string

tool: D5: 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;
}
```