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

```asm
<neiEK>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,%rbp
  mov    %esi,(%rsp)
  mov    %edx,0x10(%rsp)
  mov    %ecx,0x20(%rsp)
  mov    %r9d,%r14d
  movsd  %xmm0,0x40(%rsp)
  mov    0x98(%rsp),%rbx
  mov    0xa8(%rsp),%r12
  mov    0xb0(%rsp),%r15
  mov    0x90(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0xc(%rsp)
  mov    %r8d,0x34(%rsp)
  lea    0x0(,%r8,8),%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    0x34(%rsp),%r8d
  test   %r8d,%r8d
  jle    L17
  movslq (%rsp),%rdx
  shl    $0x3,%rdx
  mov    %r8d,%eax
  lea    0x0(%r13,%rax,8),%rsi
  mov    %r13,%rax
  mov    %rbp,%rcx
  sub    %r13,%rcx
L522:
  mov    (%rcx,%rax,1),%rdi
  movsd  (%rdi,%rdx,1),%xmm0
  movsd  %xmm0,(%rax)
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L522
L17:
  movslq 0x10(%rsp),%rax
  movsd  0x0(%r13,%rax,8),%xmm0
  movsd  0x40(%rsp),%xmm6
  divsd  %xmm6,%xmm0
  cvttsd2si %xmm0,%eax
  mov    0xc(%rsp),%edi
  and    %edi,%eax
  mov    %eax,0x38(%rsp)
  movslq 0x20(%rsp),%rax
  movsd  0x0(%r13,%rax,8),%xmm0
  divsd  %xmm6,%xmm0
  cvttsd2si %xmm0,%eax
  and    %edi,%eax
  mov    %eax,0x2c(%rsp)
  test   %r14d,%r14d
  jle    L455
  mov    %r15,%rax
  lea    -0x1(%r14),%edx
  lea    0x4(%r15,%rdx,4),%rdx
L807:
  movl   $0x0,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L807
L455:
  movslq %r14d,%rax
  lea    -0x8(%rbx,%rax,8),%rdx
  mov    0x90(%rsp),%eax
  shr    $0x1f,%eax
  add    0x90(%rsp),%eax
  sar    %eax
  mov    %eax,0x4c(%rsp)
  mov    0x34(%rsp),%esi
  lea    -0x2(%rsi),%eax
  lea    0x10(%r13,%rax,8),%rcx
  movl   $0x0,0x24(%rsp)
  movq   D41(%rip),%xmm4
  movapd %xmm4,%xmm3
  movapd %xmm4,%xmm2
  jmp    L426
L782:
  mov    0x38(%rsp),%eax
  mov    %eax,0x3c(%rsp)
  mov    %eax,0x28(%rsp)
  movl   $0x1,0x20(%rsp)
L796:
  mov    0x28(%rsp),%eax
  mov    %eax,0x30(%rsp)
  mov    %rbp,%r8
  sub    %r13,%r8
  mov    %r14d,%r9d
  jmp    L697
L744:
  add    $0x8,%rax
  cmp    %rcx,%rax
  je     L398
L665:
  movsd  (%rax),%xmm0
  mov    (%r8,%rax,1),%rsi
  subsd  (%rsi,%r10,1),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm1,%xmm0
  jbe    L744
  comisd (%rdx),%xmm0
  ja     L202
  movapd %xmm0,%xmm1
  jmp    L744
L398:
  mov    (%rsp),%esi
L447:
  test   %r14d,%r14d
  jle    L471
  mov    $0x0,%eax
  jmp    L124
L202:
  mov    (%rsp),%esi
  movapd %xmm0,%xmm1
  jmp    L447
L34:
  add    $0x1,%rax
  cmp    %r9,%rax
  je     L471
L124:
  movsd  (%rbx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jb     L34
  addl   $0x1,(%r15,%rax,4)
  jmp    L34
L471:
  mov    (%r12,%r11,4),%r11d
  cmp    $0xffffffff,%r11d
  je     L165
L392:
  movslq %r11d,%r11
  lea    0x0(,%r11,8),%r10
  mov    0x0(%rbp),%rax
  movsd  0x0(%r13),%xmm1
  subsd  (%rax,%r11,8),%xmm1
  andpd  %xmm4,%xmm1
  cmp    $0x1,%esi
  jle    L447
  lea    0x8(%r13),%rax
  mov    %esi,(%rsp)
  jmp    L665
L165:
  add    0x20(%rsp),%edi
  cmp    0x10(%rsp),%edi
  jg     L859
L667:
  mov    0xc(%rsp),%eax
  and    %edi,%eax
  cltq
  mov    0x18(%rsp),%r10
  mov    (%r10),%r10
  mov    (%r10,%rax,4),%r11d
  cmp    $0xffffffff,%r11d
  jne    L392
  jmp    L165
L859:
  addl   $0x1,0x30(%rsp)
  mov    0x30(%rsp),%eax
  cmp    0x3c(%rsp),%eax
  jg     L567
L697:
  mov    0xc(%rsp),%eax
  and    0x30(%rsp),%eax
  mov    0x2c(%rsp),%r11d
  mov    %r11d,%edi
  mov    0x48(%rsp),%r10d
  sub    %r10d,%edi
  add    %r11d,%r10d
  mov    %r10d,0x10(%rsp)
  cmp    %edi,%r10d
  jl     L859
  cltq
  mov    0xa0(%rsp),%r11
  lea    (%r11,%rax,8),%rax
  mov    %rax,0x18(%rsp)
  jmp    L667
L567:
  movq   D41(%rip),%xmm5
  mov    %rbp,%r8
  sub    %r13,%r8
  mov    %r14d,%r9d
  jmp    L445
L308:
  add    $0x8,%rax
  cmp    %rcx,%rax
  je     L259
L405:
  movsd  (%rax),%xmm0
  mov    (%r8,%rax,1),%rsi
  subsd  (%rsi,%r10,1),%xmm0
  andpd  %xmm2,%xmm0
  comisd %xmm1,%xmm0
  jbe    L308
  comisd (%rdx),%xmm0
  ja     L491
  movapd %xmm0,%xmm1
  jmp    L308
L259:
  mov    (%rsp),%esi
L454:
  test   %r14d,%r14d
  jle    L421
  mov    $0x0,%eax
  jmp    L683
L491:
  mov    (%rsp),%esi
  movapd %xmm0,%xmm1
  jmp    L454
L111:
  add    $0x1,%rax
  cmp    %rax,%r9
  je     L421
L683:
  movsd  (%rbx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jb     L111
  addl   $0x1,(%r15,%rax,4)
  jmp    L111
L421:
  mov    (%r12,%r11,4),%r11d
  cmp    $0xffffffff,%r11d
  je     L484
L639:
  movslq %r11d,%r11
  lea    0x0(,%r11,8),%r10
  mov    0x0(%rbp),%rax
  movsd  0x0(%r13),%xmm1
  subsd  (%rax,%r11,8),%xmm1
  andpd  %xmm5,%xmm1
  cmp    $0x1,%esi
  jle    L454
  lea    0x8(%r13),%rax
  mov    %esi,(%rsp)
  jmp    L405
L484:
  add    $0x1,%edi
  cmp    0x10(%rsp),%edi
  je     L781
L525:
  mov    0xc(%rsp),%eax
  and    %edi,%eax
  cltq
  mov    0x18(%rsp),%r11
  mov    (%r11),%r10
  mov    (%r10,%rax,4),%r11d
  cmp    $0xffffffff,%r11d
  jne    L639
  jmp    L484
L781:
  mov    0x20(%rsp),%edi
  add    %edi,0x28(%rsp)
  mov    0x28(%rsp),%eax
  cmp    0x3c(%rsp),%eax
  jg     L568
L445:
  mov    0xc(%rsp),%eax
  and    0x28(%rsp),%eax
  mov    0x2c(%rsp),%edi
  add    $0x1,%edi
  sub    0x48(%rsp),%edi
  cmp    %edi,0x10(%rsp)
  jle    L781
  cltq
  mov    0xa0(%rsp),%r11
  lea    (%r11,%rax,8),%rax
  mov    %rax,0x18(%rsp)
  jmp    L525
L568:
  addl   $0x1,0x24(%rsp)
  mov    0x24(%rsp),%eax
  cmp    %eax,0x4c(%rsp)
  je     L116
L426:
  mov    0x24(%rsp),%eax
  mov    %eax,0x48(%rsp)
  sub    $0x1,%eax
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  mulsd  0x40(%rsp),%xmm0
  movsd  (%rdx),%xmm1
  comisd %xmm0,%xmm1
  jbe    L487
  cmpl   $0x0,0x24(%rsp)
  je     L782
  mov    0x48(%rsp),%eax
  lea    (%rax,%rax,1),%edi
  mov    %edi,0x20(%rsp)
  mov    0x38(%rsp),%edi
  mov    %edi,%r11d
  sub    %eax,%r11d
  mov    %r11d,0x28(%rsp)
  add    %edi,%eax
  mov    %eax,0x3c(%rsp)
  cmp    %eax,%r11d
  jle    L796
  jmp    L568
L487:
  mov    0x24(%rsp),%edi
  cmp    %edi,0x4c(%rsp)
  je     L116
L713:
  mov    %r13,%rdi
  call   <free@plt>
  test   %r14d,%r14d
  jle    L288
  mov    %r15,%rax
  lea    -0x1(%r14),%edx
  lea    0x4(%r15,%rdx,4),%rdx
L159:
  subl   $0x1,(%rax)
  add    $0x4,%rax
  cmp    %rax,%rdx
  jne    L159
L288:
  add    $0x58,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L116:
  mov    0x38(%rsp),%eax
  mov    %eax,%r10d
  mov    0x24(%rsp),%edi
  sub    %edi,%r10d
  add    %edi,%eax
  mov    %eax,0x10(%rsp)
  cmp    %eax,%r10d
  jge    L482
  mov    0x2c(%rsp),%eax
  sub    %edi,%eax
  and    0xc(%rsp),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,(%rsp)
  mov    %r10d,%r11d
  mov    %rbp,%rdi
  sub    %r13,%rdi
  movq   D41(%rip),%xmm2
  mov    %r14d,%r9d
  mov    %r10d,0x20(%rsp)
  jmp    L19
L761:
  add    $0x8,%rax
  cmp    %rcx,%rax
  je     L507
L658:
  mov    (%rdi,%rax,1),%rsi
  movsd  (%rax),%xmm0
  subsd  (%rsi,%r10,1),%xmm0
  andpd  %xmm2,%xmm0
  comisd %xmm1,%xmm0
  jbe    L761
  comisd (%rdx),%xmm0
  ja     L360
  movapd %xmm0,%xmm1
  jmp    L761
L360:
  movapd %xmm0,%xmm1
L507:
  test   %r14d,%r14d
  jle    L38
  mov    $0x0,%eax
  jmp    L823
L638:
  add    $0x1,%rax
  cmp    %rax,%r9
  je     L38
L823:
  movsd  (%rbx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jb     L638
  addl   $0x1,(%r15,%rax,4)
  jmp    L638
L38:
  mov    (%r12,%r8,4),%esi
  cmp    $0xffffffff,%esi
  je     L453
L81:
  movslq %esi,%r8
  lea    0x0(,%r8,8),%r10
  mov    0x0(%rbp),%rax
  movsd  0x0(%r13),%xmm1
  subsd  (%rax,%r8,8),%xmm1
  andpd  D41(%rip),%xmm1
  cmpl   $0x1,0x34(%rsp)
  jle    L507
  lea    0x8(%r13),%rax
  jmp    L658
L453:
  add    $0x1,%r11d
  cmp    0x10(%rsp),%r11d
  je     L822
L19:
  mov    0xc(%rsp),%eax
  and    %r11d,%eax
  cltq
  mov    0xa0(%rsp),%rsi
  mov    (%rsi,%rax,8),%rax
  mov    (%rsp),%rsi
  mov    (%rax,%rsi,1),%esi
  cmp    $0xffffffff,%esi
  jne    L81
  jmp    L453
L822:
  mov    0x20(%rsp),%r10d
L482:
  mov    %r10d,%eax
  and    0xc(%rsp),%eax
  mov    0x2c(%rsp),%edi
  mov    %edi,%esi
  mov    0x24(%rsp),%r11d
  sub    %r11d,%esi
  add    $0x1,%esi
  add    %r11d,%edi
  mov    %edi,(%rsp)
  cmp    %edi,%esi
  jge    L713
  cltq
  mov    0xa0(%rsp),%rdi
  lea    (%rdi,%rax,8),%r10
  mov    %rbp,%r8
  sub    %r13,%r8
  movq   D41(%rip),%xmm2
  mov    %r14d,%r11d
  mov    %r14d,%r9d
  jmp    L397
L90:
  add    $0x8,%rax
  cmp    %rcx,%rax
  je     L263
L309:
  mov    (%r8,%rax,1),%rdi
  movsd  (%rax),%xmm0
  subsd  (%rdi,%r14,1),%xmm0
  andpd  %xmm2,%xmm0
  comisd %xmm1,%xmm0
  jbe    L90
  comisd (%rdx),%xmm0
  ja     L765
  movapd %xmm0,%xmm1
  jmp    L90
L765:
  movapd %xmm0,%xmm1
L263:
  test   %r9d,%r9d
  jle    L321
  mov    $0x0,%eax
  jmp    L516
L441:
  add    $0x1,%rax
  cmp    %r11,%rax
  je     L321
L516:
  movsd  (%rbx,%rax,8),%xmm0
  comisd %xmm1,%xmm0
  jb     L441
  addl   $0x1,(%r15,%rax,4)
  jmp    L441
L321:
  mov    (%r12,%r10,4),%edi
  cmp    $0xffffffff,%edi
  je     L432
L496:
  movslq %edi,%r10
  lea    0x0(,%r10,8),%r14
  mov    0x0(%rbp),%rax
  movsd  0x0(%r13),%xmm1
  subsd  (%rax,%r10,8),%xmm1
  andpd  D41(%rip),%xmm1
  cmpl   $0x1,0x34(%rsp)
  jle    L263
  lea    0x8(%r13),%rax
  jmp    L309
L432:
  mov    0x10(%rsp),%r10
L92:
  add    $0x1,%esi
  cmp    (%rsp),%esi
  je     L249
L397:
  mov    0xc(%rsp),%eax
  and    %esi,%eax
  cltq
  mov    (%r10),%rdi
  mov    (%rdi,%rax,4),%edi
  cmp    $0xffffffff,%edi
  je     L92
  mov    %r10,0x10(%rsp)
  jmp    L496
L249:
  mov    %r9d,%r14d
  jmp    L713
```

tool_calls: name: parse_data
arguments: data_tag: D41
data_type: qword[2]

tool: {"D41": [0x7fffffffffffffff,0x0000000000000000]}

assistant: ```c
void neiEK(double **x, int i, int comp1, int comp2, int dim, int K, int bs, double epsgrid, double *eps, int **box, int *lis, int *nx) {
  int ix, iy, ix1, iy1, ix2, jj, step, d, ik;
  int el, ib = bs - 1;
  double dd, dy;
  double *xx;
  xx = (double *)malloc(dim * sizeof(double));
  for (d = 0; d < dim; d++)
    xx[d] = x[d][i];
  ix = (int)(xx[comp1] / epsgrid) & ib;
  iy = (int)(xx[comp2] / epsgrid) & ib;
  jj = 0;
  for (ik = 0; ik < K; ik++)
    nx[ik] = 0;
  while (eps[K - 1] > epsgrid * (jj - 1)) {
    step = (jj) ? 2 * jj : 1;
    for (ix1 = ix - jj; ix1 <= ix + jj; ix1++) {
      ix2 = ix1 & ib;
      for (iy1 = iy - jj; iy1 <= iy + jj; iy1 += step) {
        el = box[ix2][iy1 & ib];
        while (el != -1) {
          dd = fabs(xx[0] - x[0][el]);
          for (d = 1; d < dim; d++)
            if ((dy = fabs(xx[d] - x[d][el])) > dd)
              if ((dd = dy) > eps[K - 1])
                break;
          ;
          for (ik = 0; ik < K; ik++) {
            if (dd <= eps[ik])
              nx[ik]++;
          }
          el = lis[el];
        }
      }
    }
    for (ix1 = ix - jj; ix1 <= ix + jj; ix1 += step) {
      ix2 = ix1 & ib;
      for (iy1 = iy - jj + 1; iy1 <= iy + jj - 1; iy1++) {
        el = box[ix2][iy1 & ib];
        while (el != -1) {
          dd = fabs(xx[0] - x[0][el]);
          for (d = 1; d < dim; d++)
            if ((dy = fabs(xx[d] - x[d][el])) > dd)
              if ((dd = dy) > eps[K - 1])
                break;
          for (ik = 0; ik < K; ik++) {
            if (dd <= eps[ik])
              nx[ik]++;
          }
          el = lis[el];
        }
      }
    }
    jj++;
    if (jj == (bs / 2))
      break;
  }
  if (jj == (bs / 2)) {
    for (ix1 = ix - jj; ix1 < ix + jj; ix1++) {
      ix2 = ix1 & ib;
      iy1 = iy - jj;
      el = box[ix2][iy1 & ib];
      while (el != -1) {
        dd = fabs(xx[0] - x[0][el]);
        for (d = 1; d < dim; d++)
          if ((dy = fabs(xx[d] - x[d][el])) > dd)
            if ((dd = dy) > eps[K - 1])
              break;
        for (ik = 0; ik < K; ik++) {
          if (dd <= eps[ik])
            nx[ik]++;
        }
        el = lis[el];
      }
    }
    ix1 = ix - jj;
    ix2 = ix1 & ib;
    for (iy1 = iy - jj + 1; iy1 <= iy + jj - 1; iy1++) {
      el = box[ix2][iy1 & ib];
      while (el != -1) {
        dd = fabs(xx[0] - x[0][el]);
        for (d = 1; d < dim; d++)
          if ((dy = fabs(xx[d] - x[d][el])) > dd)
            if ((dd = dy) > eps[K - 1])
              break;
        for (ik = 0; ik < K; ik++) {
          if (dd <= eps[ik])
            nx[ik]++;
        }
        el = lis[el];
      }
    }
  }
  free(xx);
  for (ik = 0; ik < K; ik++)
    nx[ik] -= 1;
}
```