user: What would the C source look like for the assembly code provided here:

```asm
<redr_embed>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xe8,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %esi,0x50(%rsp)
  mov    %edx,%edi
  mov    %edx,0x1c(%rsp)
  mov    %ecx,%r15d
  mov    %r8d,0x88(%rsp)
  mov    %r9d,%r12d
  lea    -0x1(%rdx),%eax
  mov    %eax,0x38(%rsp)
  imul   %ecx,%eax
  sub    %eax,%r8d
  mov    %r8d,%r14d
  mov    %r8d,0xd8(%rsp)
  imul   %esi,%edi
  mov    %edi,%ebx
  mov    %edi,0x54(%rsp)
  movslq %edi,%rdi
  shl    $0x3,%rdi
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %ebx,%ebx
  jle    L346
  movslq %r14d,%rax
  lea    0x0(,%rax,8),%r14
  mov    %ebx,%ebx
  mov    $0x0,%r13d
L27:
  mov    %r13d,0x8(%rsp)
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x0(%rbp,%r13,8)
  mov    0x8(%rsp),%eax
  cltd
  idivl  0x1c(%rsp)
  cltq
  imul   %r15d,%edx
  movslq %edx,%rdx
  mov    0x10(%rsp),%rsi
  mov    (%rsi,%rax,8),%rax
  lea    (%rax,%rdx,8),%rsi
  mov    %r14,%rdx
  call   <memcpy@plt>
  add    $0x1,%r13
  cmp    %rbx,%r13
  jne    L27
L346:
  mov    0x50(%rsp),%ebx
  movslq %ebx,%rax
  mov    %rax,0x90(%rsp)
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x68(%rsp)
  test   %ebx,%ebx
  jle    L109
  mov    0x1c(%rsp),%ecx
  movslq %ecx,%rax
  shl    $0x3,%rax
  mov    %rax,0x28(%rsp)
  movslq 0xd8(%rsp),%r14
  shl    $0x3,%r14
  mov    %rdi,0x10(%rsp)
  mov    %ebx,%eax
  lea    (%rdi,%rax,8),%rax
  mov    %rax,0x30(%rsp)
  lea    -0x1(%rcx),%eax
  movl   $0x0,0x20(%rsp)
  add    $0x1,%rax
  mov    %rax,0x40(%rsp)
L407:
  mov    0x28(%rsp),%rdi
  call   <malloc@plt>
  mov    0x10(%rsp),%rdi
  mov    %rax,(%rdi)
  cmpl   $0x0,0x1c(%rsp)
  jle    L43
  mov    %rax,%rbx
  movslq 0x20(%rsp),%rdx
  lea    0x0(%rbp,%rdx,8),%r13
  mov    0x40(%rsp),%rsi
  lea    (%rax,%rsi,8),%r15
L233:
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,(%rbx)
  mov    0x0(%r13),%rsi
  mov    %r14,%rdx
  call   <memcpy@plt>
  add    $0x8,%rbx
  add    $0x8,%r13
  cmp    %r15,%rbx
  jne    L233
L43:
  addq   $0x8,0x10(%rsp)
  mov    0x10(%rsp),%rax
  mov    0x1c(%rsp),%edi
  add    %edi,0x20(%rsp)
  cmp    0x30(%rsp),%rax
  jne    L407
L109:
  movslq 0xd8(%rsp),%rax
  mov    %rax,0xa0(%rsp)
  shl    $0x2,%rax
  mov    %rax,0x48(%rsp)
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,0x70(%rsp)
  lea    0x1(%r12),%eax
  movslq %eax,%rbx
  lea    0x0(,%rbx,8),%rax
  mov    %rax,0xa8(%rsp)
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,0x80(%rsp)
  test   %r12d,%r12d
  jle    L253
  lea    0x1(%r12),%ecx
  mov    $0x1,%eax
  mov    0x50(%rsp),%edi
  lea    -0x1(%rdi),%edx
  pxor   %xmm1,%xmm1
  cvtsi2sd %edx,%xmm1
  mov    0x120(%rsp),%rdx
L4:
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movapd %xmm1,%xmm2
  divsd  %xmm0,%xmm2
  movsd  (%rdx,%rax,8),%xmm0
  subsd  %xmm2,%xmm0
  mov    0x80(%rsp),%rsi
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L4
L253:
  lea    0x0(,%rbx,4),%rdi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    0x54(%rsp),%eax
  lea    0x1(%rax),%edi
  movslq %edi,%rdi
  shl    $0x3,%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  pxor   %xmm3,%xmm3
  cvtsi2sd %r12d,%xmm3
  pxor   %xmm2,%xmm2
  cvtsi2sdl 0x88(%rsp),%xmm2
  movapd %xmm3,%xmm0
  mulsd  D38(%rip),%xmm0
  movl   $0x1,0x10(%rsp)
  comisd %xmm0,%xmm2
  jbe    L219
L86:
  shll   0x10(%rsp)
  mov    0x10(%rsp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movapd %xmm1,%xmm0
  mulsd  D38(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  comisd %xmm0,%xmm2
  ja     L86
L337:
  movsd  D22(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x40(%rsp)
  mov    0x10(%rsp),%ebx
  lea    0x3(%rbx),%eax
  test   %ebx,%ebx
  cmovns %ebx,%eax
  sar    $0x2,%eax
  mov    %eax,0x98(%rsp)
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,0x20(%rsp)
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,%rdx
  mov    %rax,0x28(%rsp)
  mov    0x50(%rsp),%ecx
  test   %ecx,%ecx
  jle    L385
  mov    %ebx,%esi
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rdi
  mov    %rdi,0x60(%rsp)
  lea    0x0(,%rax,4),%rbx
  mov    %r13,0x30(%rsp)
  mov    %rdx,0x58(%rsp)
  mov    %ecx,%eax
  shl    $0x3,%rax
  mov    %rax,0x78(%rsp)
  add    %r13,%rax
  mov    %rax,0xb0(%rsp)
  lea    -0x1(%rsi),%eax
  add    $0x1,%rax
  mov    %rax,0xb8(%rsp)
  mov    %rbx,%r13
  mov    %rbp,0xc0(%rsp)
L48:
  mov    0x60(%rsp),%rdi
  call   <malloc@plt>
  mov    0x30(%rsp),%rsi
  mov    %rax,(%rsi)
  cmpl   $0x0,0x10(%rsp)
  jle    L145
  mov    %rax,%rbx
  mov    0xb8(%rsp),%rsi
  lea    (%rax,%rsi,8),%rbp
L18:
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L18
L145:
  mov    0x48(%rsp),%rdi
  call   <malloc@plt>
  mov    0x58(%rsp),%rsi
  mov    %rax,(%rsi)
  addq   $0x8,0x30(%rsp)
  mov    0x30(%rsp),%rax
  add    $0x8,%rsi
  mov    %rsi,0x58(%rsp)
  cmp    0xb0(%rsp),%rax
  jne    L48
  mov    0xc0(%rsp),%rbp
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,0x60(%rsp)
  mov    %rax,%rbx
  mov    0x78(%rsp),%r13
  add    %rax,%r13
L266:
  mov    0x48(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %r13,%rbx
  jne    L266
L308:
  mov    0x10(%rsp),%r13d
  movslq %r13d,%rbx
  lea    0x0(,%rbx,8),%rdi
  call   <malloc@plt>
  mov    %rax,0x78(%rsp)
  test   %r13d,%r13d
  jle    L69
  lea    0x0(,%rbx,4),%rdi
  mov    %rdi,0x30(%rsp)
  mov    %rax,%rdi
  mov    %rax,%rbx
  mov    %r13d,%eax
  lea    (%rdi,%rax,8),%r13
L283:
  mov    0x30(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %r13,%rbx
  jne    L283
L69:
  movslq 0x88(%rsp),%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %rax,0x88(%rsp)
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  mov    0x90(%rsp),%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,0x90(%rsp)
  push   %rbx
  push   0x80(%rsp)
  push   0x80(%rsp)
  mov    0xb0(%rsp),%eax
  push   %rax
  mov    0x30(%rsp),%r9d
  mov    0x3c(%rsp),%r8d
  mov    $0x0,%ecx
  mov    0xf8(%rsp),%edx
  mov    0x74(%rsp),%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <make_box2ind@plt>
  add    $0x20,%rsp
  mov    0x50(%rsp),%eax
  test   %eax,%eax
  jle    L207
  mov    %eax,%r13d
  mov    $0x0,%ebx
L184:
  mov    0x68(%rsp),%rax
  mov    (%rax,%rbx,8),%rdi
  mov    0x28(%rsp),%rax
  push   (%rax,%rbx,8)
  mov    0x28(%rsp),%rax
  push   (%rax,%rbx,8)
  mov    0x70(%rsp),%rax
  push   (%rax,%rbx,8)
  mov    0xb0(%rsp),%eax
  push   %rax
  mov    0x30(%rsp),%r9d
  mov    0x58(%rsp),%r8d
  mov    $0x0,%ecx
  mov    0xf8(%rsp),%edx
  mov    0x3c(%rsp),%esi
  mov    $0x0,%eax
  call   <make_box2ind@plt>
  add    $0x1,%rbx
  add    $0x20,%rsp
  cmp    %r13,%rbx
  jne    L184
L207:
  mov    0xd8(%rsp),%eax
  test   %eax,%eax
  jle    L179
  mov    %eax,%eax
  shl    $0x2,%rax
  mov    %rax,0xb0(%rsp)
  mov    0x50(%rsp),%eax
  lea    -0x1(%rax),%eax
  mov    %rax,0x48(%rsp)
  mov    0x30(%rsp),%rsi
  lea    0x8(%rsi,%rax,8),%rax
  mov    %rax,0x98(%rsp)
  lea    -0x1(%r12),%eax
  lea    0x8(%r15,%rax,4),%rbx
  movq   $0x0,0x58(%rsp)
  pxor   %xmm5,%xmm5
  movsd  %xmm5,0x8(%rsp)
  jmp    L426
L219:
  movl   $0x1,0x10(%rsp)
  movsd  D36(%rip),%xmm1
  jmp    L337
L468:
  add    $0x4,%rax
  cmp    %rax,%rbx
  je     L465
L152:
  movslq (%rax),%r13
  movapd %xmm1,%xmm0
  subsd  (%rcx,%r13,8),%xmm0
  andpd  D19(%rip),%xmm0
  comisd (%rdx),%xmm0
  jbe    L468
  movsd  %xmm0,(%rdx)
  jmp    L468
L465:
  add    $0x1,%esi
  cmp    %edi,%esi
  je     L82
L133:
  test   %r12d,%r12d
  jle    L465
  movslq %esi,%rax
  movsd  (%r14,%rax,8),%xmm1
  mov    0x0(%rbp,%rax,8),%rcx
  lea    0x4(%r15),%rax
  jmp    L152
L82:
  add    $0x8,%r8
  add    %r10d,%edi
  add    %r10d,%r9d
  cmp    %r11,%r8
  je     L494
L384:
  mov    %r8,%rdx
  movq   $0x0,(%r8)
  mov    %r9d,%esi
  test   %r10d,%r10d
  jg     L133
  jmp    L82
L494:
  mov    $0x0,%r13d
  mov    %rbp,0xb8(%rsp)
  mov    0x68(%rsp),%rbp
  mov    %r15,0xc0(%rsp)
  mov    %r14,0xc8(%rsp)
  mov    %rbx,0xd0(%rsp)
  mov    0x60(%rsp),%rbx
  mov    0x58(%rsp),%r14
  mov    %r12d,0xdc(%rsp)
  mov    0x90(%rsp),%r12
  mov    0x120(%rsp),%r15
L365:
  mov    (%rbx,%r13,8),%rax
  mov    (%rax,%r14,1),%esi
  mov    0x0(%rbp,%r13,8),%rdi
  mov    0x28(%rsp),%rax
  push   (%rax,%r13,8)
  mov    0x28(%rsp),%rax
  push   (%rax,%r13,8)
  mov    0x40(%rsp),%rax
  movsd  (%rax,%r13,8),%xmm1
  movsd  0x50(%rsp),%xmm0
  mov    0x20(%rsp),%r9d
  mov    0x2c(%rsp),%r8d
  mov    0x48(%rsp),%ecx
  mov    $0x0,%edx
  mov    $0x2,%eax
  call   <neiE@plt>
  mov    %eax,(%r12,%r13,4)
  cltq
  movsd  0x18(%rsp),%xmm4
  addsd  (%r15,%rax,8),%xmm4
  movsd  %xmm4,0x18(%rsp)
  mov    %r13,%rax
  add    $0x1,%r13
  add    $0x10,%rsp
  cmp    0x48(%rsp),%rax
  jne    L365
  mov    0xb8(%rsp),%rbp
  mov    0xc0(%rsp),%r15
  mov    0xc8(%rsp),%r14
  mov    0xd0(%rsp),%rbx
  mov    0xdc(%rsp),%r12d
L120:
  addq   $0x4,0x58(%rsp)
  mov    0x58(%rsp),%rax
  cmp    0xb0(%rsp),%rax
  je     L70
L426:
  cmpl   $0x0,0x54(%rsp)
  jle    L477
  mov    0x70(%rsp),%rax
  mov    0x58(%rsp),%rsi
  movslq (%rax,%rsi,1),%rcx
  shl    $0x3,%rcx
  mov    0x54(%rsp),%esi
  mov    $0x0,%eax
L134:
  mov    0x0(%rbp,%rax,8),%rdx
  movsd  (%rdx,%rcx,1),%xmm0
  movsd  %xmm0,(%r14,%rax,8)
  add    $0x1,%rax
  cmp    %rsi,%rax
  jne    L134
L477:
  push   %r15
  push   0x90(%rsp)
  push   0x88(%rsp)
  push   %r12
  movsd  0x60(%rsp),%xmm0
  mov    0x30(%rsp),%r9d
  mov    0x90(%rsp),%rax
  mov    0x78(%rsp),%rdi
  mov    (%rax,%rdi,1),%r8d
  mov    0x3c(%rsp),%r13d
  mov    %r13d,%ecx
  mov    $0x0,%edx
  mov    0x74(%rsp),%esi
  mov    %rbp,%rdi
  mov    $0x1,%eax
  call   <neiK@plt>
  add    $0x20,%rsp
  cmpl   $0x0,0x50(%rsp)
  jle    L120
  mov    %r13d,%edi
  mov    0x30(%rsp),%r8
  mov    $0x0,%r9d
  mov    0x98(%rsp),%r11
  mov    %r13d,%r10d
  jmp    L384
L179:
  pxor   %xmm6,%xmm6
  movsd  %xmm6,0x8(%rsp)
L70:
  mov    0x50(%rsp),%eax
  sub    $0x1,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  mov    0x120(%rsp),%rax
  mov    0xa0(%rsp),%rdi
  mulsd  (%rax,%rdi,8),%xmm1
  mov    0x80(%rsp),%rax
  mov    0xa8(%rsp),%rsi
  addsd  -0x8(%rax,%rsi,1),%xmm1
  pxor   %xmm2,%xmm2
  cvtsi2sdl 0xd8(%rsp),%xmm2
  movsd  0x8(%rsp),%xmm0
  divsd  %xmm2,%xmm0
  subsd  %xmm0,%xmm1
  mov    0x128(%rsp),%rax
  movsd  %xmm1,(%rax)
  mov    0x54(%rsp),%eax
  test   %eax,%eax
  jle    L360
  mov    %rbp,%rbx
  mov    %eax,%eax
  lea    0x0(%rbp,%rax,8),%r12
L206:
  mov    (%rbx),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %r12,%rbx
  jne    L206
L360:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    0x50(%rsp),%eax
  test   %eax,%eax
  jle    L151
  mov    0x20(%rsp),%rsi
  mov    %rsi,%rbp
  mov    0x28(%rsp),%rdi
  mov    %rdi,0x38(%rsp)
  mov    0x68(%rsp),%r12
  mov    0x60(%rsp),%rdi
  mov    %rdi,0x8(%rsp)
  mov    %eax,%eax
  lea    (%rsi,%rax,8),%rax
  mov    %rax,0x40(%rsp)
  mov    0x1c(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(,%rax,8),%r13
  mov    0x10(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x8(,%rax,8),%rax
  mov    %r15,0x48(%rsp)
  mov    %rax,%r15
  jmp    L397
L350:
  mov    (%r12),%rax
  mov    (%rax,%rbx,1),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %r13,%rbx
  jne    L350
L424:
  cmpl   $0x0,0x10(%rsp)
  jle    L102
  mov    $0x0,%ebx
L264:
  mov    0x0(%rbp),%rax
  mov    (%rax,%rbx,1),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %r15,%rbx
  jne    L264
L102:
  mov    0x0(%rbp),%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rbx
  mov    (%rbx),%rdi
  call   <free@plt>
  mov    (%r12),%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rax
  mov    (%rax),%rdi
  call   <free@plt>
  add    $0x8,%rbp
  add    $0x8,%rbx
  mov    %rbx,0x38(%rsp)
  add    $0x8,%r12
  addq   $0x8,0x8(%rsp)
  cmp    %rbp,0x40(%rsp)
  je     L156
L397:
  mov    $0x0,%ebx
  cmpl   $0x0,0x1c(%rsp)
  jg     L350
  jmp    L424
L156:
  mov    0x48(%rsp),%r15
L151:
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  mov    0x80(%rsp),%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x10(%rsp),%eax
  test   %eax,%eax
  jle    L290
  mov    0x78(%rsp),%rdi
  mov    %rdi,%rbx
  mov    %eax,%eax
  lea    (%rdi,%rax,8),%rbp
L380:
  mov    (%rbx),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L380
L290:
  mov    0x78(%rsp),%rdi
  call   <free@plt>
  mov    0x88(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L385:
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,0x60(%rsp)
  jmp    L308
```

tool_calls: name: retrieve_data
arguments: label: D38
datatype: f64
name: retrieve_data
arguments: label: D22
datatype: f64
name: retrieve_data
arguments: label: D36
datatype: f32[2]
name: retrieve_data
arguments: label: D19
datatype: qword[2]

tool: D38: 0.5

tool: D22: 4

tool: {"D36": [0.0,1.875]}

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

assistant: ```c
void redr_embed(double **x, int dim, int edim, int tau, int N, int K, double *psi, double *mir) {
  int i, k, *n2;
  double *xc, dx;
  double *eps;
  double dxy2;
  int *nn;
  int d, de;
  int N_;
  double **xx;
  double ***xxx;
  int BOX;
  int **box, *lis;
  int ***boxxx;
  int **lisxx;
  double epsilon;
  int inveps;
  int *ind;
  int **indxx;
  double *phi;
  N_ = N - (edim - 1) * tau;
  xx = (double **)malloc(dim * edim * sizeof(double *));
  for (d = 0; d < dim * edim; d++) {
    xx[d] = (double *)malloc(N_ * sizeof(double));
    memcpy(xx[d], x[d / edim] + tau * (d % edim), N_ * sizeof(double));
  }
  xxx = (double ***)malloc(dim * sizeof(double **));
  for (d = 0; d < dim; d++) {
    xxx[d] = (double **)malloc(edim * sizeof(double *));
    for (de = 0; de < edim; de++) {
      xxx[d][de] = (double *)malloc(N_ * sizeof(double));
      memcpy(xxx[d][de], xx[d * edim + de], N_ * sizeof(double));
    }
  }
  ind = (int *)malloc(N_ * sizeof(int));
  phi = (double *)malloc((K + 1) * sizeof(double));
  for (i = 1; i <= K; i++)
    phi[i] = psi[i] - (dim - 1) / ((double)i);
  nn = (int *)malloc((K + 1) * sizeof(int));
  xc = (double *)malloc((dim * edim + 1) * sizeof(double));
  BOX = 1;
  while (0.5 * BOX * BOX * K < N)
    BOX *= 2;
  epsilon = 4.0 / BOX;
  inveps = BOX / 4;
  boxxx = (int ***)malloc(dim * sizeof(int **));
  lisxx = (int **)malloc(dim * sizeof(int *));
  for (d = 0; d < dim; d++) {
    boxxx[d] = (int **)malloc(BOX * sizeof(int *));
    for (i = 0; i < BOX; i++)
      boxxx[d][i] = (int *)malloc(BOX * sizeof(int));
    lisxx[d] = (int *)malloc(N_ * sizeof(int));
  }
  indxx = (int **)malloc(dim * sizeof(int *));
  for (d = 0; d < dim; d++) {
    indxx[d] = (int *)malloc(N_ * sizeof(int));
  }
  box = (int **)malloc(BOX * sizeof(int *));
  for (i = 0; i < BOX; i++)
    box[i] = (int *)malloc(BOX * sizeof(int));
  lis = (int *)malloc(N * sizeof(int));
  eps = (double *)malloc(dim * sizeof(double));
  n2 = (int *)malloc(dim * sizeof(int));
  make_box2ind(xx, dim * edim, N_, 0, edim, BOX, inveps, ind, box, lis);
  for (d = 0; d < dim; d++)
    make_box2ind(xxx[d], edim, N_, 0, edim - 1, BOX, inveps, indxx[d], boxxx[d], lisxx[d]);
  dxy2 = 0.0;
  for (i = 0; i < N_; i++) {
    for (d = 0; d < dim * edim; d++)
      xc[d] = xx[d][ind[i]];
    neiK(xx, dim * edim, 0, edim, ind[i], BOX, epsilon, K, box, lis, nn);
    for (d = 0; d < dim; d++) {
      eps[d] = 0;
      for (de = 0; de < edim; de++)
        for (k = 1; k <= K; k++)
          if ((dx = fabs(xc[d * edim + de] - xx[d * edim + de][nn[k]])) > eps[d])
            eps[d] = dx;
    }
    for (d = 0; d < dim; d++) {
      n2[d] = neiE(xxx[d], indxx[d][i], 0, edim - 1, edim, BOX, epsilon, eps[d], boxxx[d], lisxx[d]);
      dxy2 += psi[n2[d]];
    }
  }
  dxy2 /= N_;
  *mir = (dim - 1) * psi[N_] + phi[K] - dxy2;
  for (d = 0; d < dim * edim; d++)
    free(xx[d]);
  free(xx);
  for (d = 0; d < dim; d++) {
    for (de = 0; de < edim; de++)
      free(xxx[d][de]);
    for (i = 0; i < BOX; i++)
      free(boxxx[d][i]);
    free(boxxx[d]);
    free(lisxx[d]);
    free(xxx[d]);
    free(indxx[d]);
  }
  free(xxx);
  free(boxxx);
  free(lisxx);
  free(indxx);
  free(ind);
  free(phi);
  free(nn);
  free(xc);
  for (i = 0; i < BOX; i++)
    free(box[i]);
  free(box);
  free(lis);
  free(eps);
  free(n2);
}
```