user: 请将以下的汇编代码转换成C语言代码:

```asm
<mi_d>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x168,%rsp
  mov    %rdi,%r15
  mov    %esi,%r12d
  mov    %esi,0xa8(%rsp)
  mov    %edx,0xb0(%rsp)
  mov    %ecx,%r13d
  mov    %ecx,0xb4(%rsp)
  mov    %r8,0x118(%rsp)
  mov    %r9,0x8(%rsp)
  mov    0x1a0(%rsp),%rax
  mov    %rax,0x138(%rsp)
  movsd  %xmm0,0x10(%rsp)
  movq   %xmm1,%rbp
  movsd  %xmm2,0x20(%rsp)
  movq   %xmm3,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x158(%rsp)
  xor    %eax,%eax
  lea    0x1(%rcx),%eax
  cltq
  lea    0x0(,%rax,4),%r14
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    %rax,0x108(%rsp)
  lea    0x1(%r12),%eax
  cltq
  lea    0x0(,%rax,8),%r12
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    %rax,0xf0(%rsp)
  pxor   %xmm2,%xmm2
  cvtsi2sd %r13d,%xmm2
  pxor   %xmm4,%xmm4
  cvtsi2sdl 0xb0(%rsp),%xmm4
  movsd  %xmm4,0x110(%rsp)
  movapd %xmm2,%xmm0
  mulsd  D48(%rip),%xmm0
  movl   $0x1,0xac(%rsp)
  comisd %xmm0,%xmm4
  jbe    L4
L48:
  shll   0xac(%rsp)
  mov    0xac(%rsp),%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movapd %xmm1,%xmm0
  mulsd  D48(%rip),%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm2,%xmm0
  movsd  0x110(%rsp),%xmm6
  comisd %xmm0,%xmm6
  ja     L48
L64:
  movsd  D33(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x128(%rsp)
  mov    0xac(%rsp),%esi
  lea    0x3(%rsi),%eax
  test   %esi,%esi
  cmovns %esi,%eax
  sar    $0x2,%eax
  mov    %eax,%r13d
  mov    0xb0(%rsp),%eax
  sub    $0x5,%eax
  mov    %eax,0x1c(%rsp)
  pxor   %xmm0,%xmm0
  cvtsi2sd %eax,%xmm0
  movq   %rbp,%xmm1
  subsd  0x10(%rsp),%xmm1
  movapd %xmm0,%xmm2
  divsd  %xmm1,%xmm2
  movsd  %xmm2,0x140(%rsp)
  movq   %rbx,%xmm1
  subsd  0x20(%rsp),%xmm1
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x148(%rsp)
  mov    0xa8(%rsp),%ebx
  movslq %ebx,%rsi
  mov    %rsi,0x10(%rsp)
  sub    $0x8,%r12
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    %rax,0x68(%rsp)
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    %rax,0x70(%rsp)
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    %rax,0x78(%rsp)
  test   %ebx,%ebx
  jle    L112
  mov    0xb0(%rsp),%eax
  sub    $0x4,%eax
  cltq
  lea    0x0(,%rax,4),%rbp
  lea    0x10(%rbp),%rax
  mov    %rax,0x20(%rsp)
  mov    %ebx,%eax
  mov    %rax,0x28(%rsp)
  mov    $0x0,%ebx
L120:
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    0x68(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  mov    0x20(%rsp),%rdi
  call   <malloc@plt>
  mov    0x70(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    0x78(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  add    $0x1,%rbx
  cmp    0x28(%rsp),%rbx
  jne    L120
L112:
  mov    0xac(%rsp),%ebp
  movslq %ebp,%rbx
  lea    0x0(,%rbx,8),%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0xc8(%rsp)
  test   %ebp,%ebp
  jle    L37
  shl    $0x2,%rbx
  mov    %rbx,0x20(%rsp)
  mov    %rax,%rbx
  mov    %ebp,%eax
  lea    (%rdi,%rax,8),%rbp
L259:
  mov    0x20(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L259
L37:
  movslq 0xb0(%rsp),%rax
  mov    %rax,0x120(%rsp)
  lea    0x0(,%rax,4),%rdi
  call   <malloc@plt>
  mov    %rax,0xd0(%rsp)
  mov    0xb4(%rsp),%ebx
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rbp
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0x90(%rsp)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xf8(%rsp)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xd8(%rsp)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xe0(%rsp)
  lea    -0x4(%r14),%rdi
  call   <malloc@plt>
  mov    %rax,0x100(%rsp)
  test   %ebx,%ebx
  jle    L392
  mov    0x10(%rsp),%r14
  shl    $0x2,%r14
  mov    %ebx,%eax
  mov    %rax,0x10(%rsp)
  mov    $0x0,%ebx
L43:
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    0x90(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    0xd8(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    0xe0(%rsp),%rsi
  mov    %rax,(%rsi,%rbx,8)
  mov    0x118(%rsp),%rax
  movl   $0x0,(%rax,%rbx,8)
  movl   $0x0,0x4(%rax,%rbx,8)
  add    $0x1,%rbx
  cmp    0x10(%rsp),%rbx
  jne    L43
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xb8(%rsp)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xc0(%rsp)
  sub    $0x8,%rsp
  push   0xd8(%rsp)
  push   0xd8(%rsp)
  push   %r13
  mov    0xcc(%rsp),%r9d
  mov    $0x1,%r8d
  mov    $0x0,%ecx
  mov    0xd0(%rsp),%edx
  mov    0xc8(%rsp),%ebx
  mov    %ebx,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jle    L421
L163:
  mov    0xa8(%rsp),%ebp
  mov    $0x0,%ebx
  mov    0x68(%rsp),%r12
L201:
  mov    (%r12,%rbx,8),%rcx
  mov    %rbx,%rax
  and    $0x1,%eax
  movsd  0x140(%rsp,%rax,8),%xmm0
  mov    (%r15,%rbx,8),%rdi
  mov    0x78(%rsp),%rax
  mov    (%rax,%rbx,8),%r9
  mov    0x70(%rsp),%rax
  mov    (%rax,%rbx,8),%r8
  mov    0x1c(%rsp),%edx
  mov    0xb0(%rsp),%esi
  mov    $0x1,%eax
  call   <make_box1@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L201
  cmpl   $0x0,0xb4(%rsp)
  jle    L433
L421:
  mov    0xb4(%rsp),%edx
  mov    $0x0,%eax
L312:
  mov    0xc0(%rsp),%rbx
  movq   $0x0,(%rbx,%rax,8)
  mov    0xb8(%rsp),%rbx
  movq   $0x0,(%rbx,%rax,8)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L312
  cmpl   $0x0,0xb0(%rsp)
  jle    L303
L93:
  mov    0xb4(%rsp),%eax
  lea    -0x1(%rax),%eax
  mov    0xc0(%rsp),%rbx
  mov    %rbx,0x130(%rsp)
  lea    0x8(%rbx,%rax,8),%rbx
  mov    %rbx,0x98(%rsp)
  movq   $0x0,0xe8(%rsp)
  add    $0x2,%rax
  mov    %rax,0xa0(%rsp)
  mov    %r15,%r13
  jmp    L371
L4:
  movl   $0x1,0xac(%rsp)
  movsd  D12(%rip),%xmm1
  jmp    L64
L187:
  add    $0x4,%rax
  cmp    %rdi,%rax
  je     L472
L7:
  movslq (%rax),%rbp
  movapd %xmm1,%xmm0
  subsd  (%rcx,%rbp,8),%xmm0
  andpd  D4(%rip),%xmm0
  comisd (%rdx),%xmm0
  jbe    L187
  movsd  %xmm0,(%rdx)
  jmp    L187
L472:
  movsd  (%rdx),%xmm0
  comisd -0x8(%r11,%r10,8),%xmm0
  jbe    L453
  movsd  %xmm0,-0x8(%r11,%r10,8)
  mov    %esi,-0x4(%r15,%r10,4)
L453:
  add    $0x1,%r8
  add    $0x8,%r9
  cmp    %rbx,%r8
  je     L316
L471:
  mov    %r8d,%esi
  mov    %r9,%rdx
  movq   $0x0,(%r9)
  test   %r10d,%r10d
  jle    L472
  movsd  (%r14,%r8,8),%xmm1
  mov    0x0(%r13,%r8,8),%rcx
  lea    0x4(%r12),%rax
  jmp    L7
L316:
  add    $0x1,%r10
  add    $0x4,%rdi
  cmp    0xa0(%rsp),%r10
  je     L205
L66:
  movq   $0x0,-0x8(%r11,%r10,8)
  movl   $0xffffffff,-0x4(%r15,%r10,4)
  cmpl   $0x0,0xa8(%rsp)
  jle    L316
  mov    0x90(%rsp),%rax
  mov    -0x8(%rax,%r10,8),%r9
  mov    $0x0,%r8d
  jmp    L471
L205:
  mov    0xd8(%rsp),%rax
  mov    %rax,0x60(%rsp)
  mov    0xb8(%rsp),%r15
  mov    0xf8(%rsp),%rax
  mov    %rax,0x88(%rsp)
  mov    0x90(%rsp),%rax
  mov    %rax,0x48(%rsp)
  mov    0xe0(%rsp),%rax
  mov    %rax,0x50(%rsp)
  mov    0x100(%rsp),%rax
  mov    %rax,0x58(%rsp)
  mov    0x130(%rsp),%r14
  mov    0xa8(%rsp),%eax
  mov    %rax,0x80(%rsp)
  mov    %r15,%r12
  mov    %r13,%r15
  jmp    L82
L469:
  mov    0x60(%rsp),%rax
  add    (%rax),%rbp
  mov    (%r15,%r13,8),%rdi
  mov    0x28(%rsp),%r9
  mov    0x30(%rsp),%r8
  mov    0x38(%rsp),%rcx
  mov    0x88(%rsp),%rax
  movsd  (%rax),%xmm1
  mov    0x1c(%rsp),%edx
  movsd  0x40(%rsp),%xmm0
  mov    0x20(%rsp),%esi
  mov    $0x2,%eax
  call   <neiE1@plt>
  mov    %eax,0x0(%rbp)
  cltq
  movsd  (%r12),%xmm0
  mov    0x8(%rsp),%rsi
  addsd  0x8(%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%r12)
L272:
  movslq %ebx,%rbx
  movsd  (%r14),%xmm0
  mov    0x8(%rsp),%rax
  addsd  (%rax,%rbx,8),%xmm0
  movsd  %xmm0,(%r14)
  add    $0x1,%r13
  cmp    0x80(%rsp),%r13
  je     L177
L208:
  mov    0x78(%rsp),%rax
  mov    (%rax,%r13,8),%r9
  mov    %r9,0x28(%rsp)
  mov    0x70(%rsp),%rax
  mov    (%rax,%r13,8),%r8
  mov    %r8,0x30(%rsp)
  mov    0x68(%rsp),%rax
  mov    (%rax,%r13,8),%rcx
  mov    %rcx,0x38(%rsp)
  mov    %r13,%rax
  and    $0x1,%eax
  movsd  0x140(%rsp,%rax,8),%xmm0
  movsd  %xmm0,0x40(%rsp)
  lea    0x0(,%r13,4),%rbp
  mov    0x50(%rsp),%rsi
  mov    %rbp,%rax
  add    (%rsi),%rax
  mov    %rax,0x10(%rsp)
  mov    0x48(%rsp),%rsi
  mov    (%rsi),%rax
  mov    (%r15,%r13,8),%rdi
  movsd  (%rax,%r13,8),%xmm1
  mov    0x1c(%rsp),%edx
  mov    0x20(%rsp),%esi
  mov    $0x2,%eax
  call   <neiE1@plt>
  mov    %eax,%ebx
  mov    0x10(%rsp),%rax
  mov    %ebx,(%rax)
  mov    0x58(%rsp),%rax
  cmp    %r13d,(%rax)
  jne    L469
  mov    0x60(%rsp),%rax
  mov    (%rax),%rax
  mov    %ebx,(%rax,%r13,4)
  movslq %ebx,%rax
  movsd  (%r12),%xmm0
  mov    0x8(%rsp),%rsi
  addsd  (%rsi,%rax,8),%xmm0
  movsd  %xmm0,(%r12)
  jmp    L272
L177:
  add    $0x8,%r14
  addq   $0x8,0x60(%rsp)
  add    $0x8,%r12
  addq   $0x8,0x88(%rsp)
  addq   $0x8,0x48(%rsp)
  addq   $0x8,0x50(%rsp)
  addq   $0x4,0x58(%rsp)
  cmp    0x98(%rsp),%r14
  je     L358
L82:
  mov    $0x0,%r13d
  cmpl   $0x0,0xa8(%rsp)
  jg     L208
  jmp    L177
L358:
  mov    %r15,%r13
L137:
  addq   $0x1,0xe8(%rsp)
  mov    0xe8(%rsp),%rax
  cmp    %eax,0xb0(%rsp)
  jle    L390
L371:
  mov    0xe8(%rsp),%rax
  mov    %eax,0x20(%rsp)
  lea    0x0(,%rax,8),%rsi
  mov    0xa8(%rsp),%ebx
  mov    %ebx,%ecx
  mov    $0x0,%eax
  mov    0xf0(%rsp),%rdi
  test   %ebx,%ebx
  jle    L305
L331:
  mov    0x0(%r13,%rax,8),%rdx
  movsd  (%rdx,%rsi,1),%xmm0
  movsd  %xmm0,(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L331
L305:
  mov    0x108(%rsp),%r12
  push   %r12
  push   0xd8(%rsp)
  push   0xd8(%rsp)
  mov    0xcc(%rsp),%ebx
  push   %rbx
  movsd  0x148(%rsp),%xmm0
  mov    0xcc(%rsp),%r9d
  mov    0x40(%rsp),%r8d
  mov    $0x1,%ecx
  mov    $0x0,%edx
  mov    0xc8(%rsp),%r15d
  mov    %r15d,%esi
  mov    %r13,%rdi
  mov    $0x1,%eax
  call   <neiK@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jle    L137
  lea    0x8(%r12),%rdi
  mov    $0x1,%r10d
  mov    %r15d,%ebx
  mov    0xf0(%rsp),%r14
  mov    0xf8(%rsp),%r11
  mov    0x100(%rsp),%r15
  jmp    L66
L390:
  cmpl   $0x0,0xb4(%rsp)
  jle    L283
L303:
  mov    0x8(%rsp),%rax
  mov    0x120(%rsp),%rbx
  lea    (%rax,%rbx,8),%rdx
  mov    $0x0,%eax
  mov    0xa8(%rsp),%ebx
  lea    -0x1(%rbx),%ecx
  pxor   %xmm2,%xmm2
  cvtsi2sd %ecx,%xmm2
  mov    0xb8(%rsp),%rcx
  mov    0xc0(%rsp),%rsi
  mov    0x118(%rsp),%rdi
L81:
  movsd  (%rcx,%rax,8),%xmm1
  movsd  0x110(%rsp),%xmm5
  divsd  %xmm5,%xmm1
  movsd  %xmm1,(%rcx,%rax,8)
  movapd %xmm2,%xmm0
  mulsd  (%rdx),%xmm0
  mov    0x8(%rsp),%rbx
  addsd  0x8(%rbx,%rax,8),%xmm0
  subsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rdi,%rax,8)
  movsd  (%rsi,%rax,8),%xmm1
  divsd  %xmm5,%xmm1
  movsd  %xmm1,(%rsi,%rax,8)
  movapd %xmm2,%xmm0
  mulsd  (%rdx),%xmm0
  mov    0x138(%rsp),%rbx
  addsd  0x8(%rbx,%rax,8),%xmm0
  subsd  %xmm1,%xmm0
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x4(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %eax,0xb4(%rsp)
  jg     L81
L283:
  mov    0xf0(%rsp),%rdi
  call   <free@plt>
  mov    0x108(%rsp),%rdi
  call   <free@plt>
  mov    0xac(%rsp),%eax
  test   %eax,%eax
  jle    L264
  mov    0xc8(%rsp),%rsi
  mov    %rsi,%rbx
  mov    %eax,%eax
  lea    (%rsi,%rax,8),%rbp
L444:
  mov    (%rbx),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %rbx,%rbp
  jne    L444
L264:
  mov    0xc8(%rsp),%rdi
  call   <free@plt>
  mov    0xd0(%rsp),%rdi
  call   <free@plt>
  mov    0xa8(%rsp),%eax
  test   %eax,%eax
  jle    L98
  mov    %eax,%ebp
  mov    $0x0,%ebx
  mov    0x68(%rsp),%r12
  mov    0x70(%rsp),%r13
  mov    0x78(%rsp),%r14
L110:
  mov    (%r12,%rbx,8),%rdi
  call   <free@plt>
  mov    0x0(%r13,%rbx,8),%rdi
  call   <free@plt>
  mov    (%r14,%rbx,8),%rdi
  call   <free@plt>
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L110
L98:
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  mov    0x78(%rsp),%rdi
  call   <free@plt>
  mov    0xb4(%rsp),%eax
  test   %eax,%eax
  jle    L387
  mov    %eax,%ebp
  mov    $0x0,%ebx
  mov    0x90(%rsp),%r12
  mov    0xd8(%rsp),%r13
  mov    0xe0(%rsp),%r14
L375:
  mov    (%r12,%rbx,8),%rdi
  call   <free@plt>
  mov    0x0(%r13,%rbx,8),%rdi
  call   <free@plt>
  mov    (%r14,%rbx,8),%rdi
  call   <free@plt>
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L375
L387:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0xd8(%rsp),%rdi
  call   <free@plt>
  mov    0xe0(%rsp),%rdi
  call   <free@plt>
  mov    0xf8(%rsp),%rdi
  call   <free@plt>
  mov    0x100(%rsp),%rdi
  call   <free@plt>
  mov    0xb8(%rsp),%rdi
  call   <free@plt>
  mov    0xc0(%rsp),%rdi
  call   <free@plt>
  mov    0x158(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L35
  add    $0x168,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L392:
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xb8(%rsp)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,0xc0(%rsp)
  sub    $0x8,%rsp
  push   0xd8(%rsp)
  push   0xd8(%rsp)
  push   %r13
  mov    0xcc(%rsp),%r9d
  mov    $0x1,%r8d
  mov    $0x0,%ecx
  mov    0xd0(%rsp),%edx
  mov    0xc8(%rsp),%ebx
  mov    %ebx,%esi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jg     L163
L433:
  cmpl   $0x0,0xb0(%rsp)
  jg     L93
  jmp    L283
L35:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D48
type: f64
name: extract_symbolic_data
arguments: data_label: D33
type: f64
name: extract_symbolic_data
arguments: data_label: D12
type: f32[2]
name: extract_symbolic_data
arguments: data_label: D4
type: qword[2]

tool: D48: 0.5

tool: D33: 4

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

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

assistant: ```c
void mi_d(double **x, int dim, int N, int K, float *mi_cr, double *psi, double *phi, double minx, double maxx, double miny, double maxy) {
  int i, k, ik, **n1, **n2;
  double *xc, dx;
  double **eps, *Eps;
  int *maxdim;
  double *dxy1, *dxy2;
  int *nn;
  int d;
  int BOX, BOX1;
  int **box, *lis;
  int **box1;
  int **lis1;
  int **mxi;
  double epsilon;
  int inveps;
  double scal[2];
  nn = (int *)malloc((K + 1) * sizeof(int));
  xc = (double *)malloc((dim + 1) * sizeof(double));
  BOX = 1;
  while (0.5 * BOX * BOX * K < N)
    BOX *= 2;
  epsilon = 4.0 / BOX;
  inveps = BOX / 4;
  BOX1 = N - 5;
  scal[0] = BOX1 / (maxx - minx);
  scal[1] = BOX1 / (maxy - miny);
  box1 = (int **)malloc((dim) * sizeof(int *));
  lis1 = (int **)malloc((dim) * sizeof(int *));
  mxi = (int **)malloc((dim) * sizeof(int *));
  for (d = 0; d < dim; d++) {
    box1[d] = (int *)malloc((BOX1 + 1) * sizeof(int));
    lis1[d] = (int *)malloc((N) * sizeof(int));
    mxi[d] = (int *)malloc((BOX1 + 1) * 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((K) * sizeof(double *));
  Eps = (double *)malloc((K) * sizeof(double));
  n1 = (int **)malloc((K) * sizeof(int *));
  n2 = (int **)malloc((K) * sizeof(int *));
  maxdim = (int *)malloc((K) * sizeof(int));
  for (ik = 0; ik < K; ik++) {
    eps[ik] = (double *)malloc((dim) * sizeof(double));
    n1[ik] = (int *)malloc((dim) * sizeof(int));
    n2[ik] = (int *)malloc((dim) * sizeof(int));
    mi_cr[ik * 2] = 0;
    mi_cr[ik * 2 + 1] = 0;
  }
  dxy1 = (double *)malloc((K) * sizeof(double));
  dxy2 = (double *)malloc((K) * sizeof(double));
  make_box2(x, dim, N, 0, 1, BOX, inveps, box, lis);
  for (d = 0; d < dim; d++) {
    make_box1(x[d], N, scal[d & 1], BOX1, box1[d], lis1[d], mxi[d]);
  }
  for (ik = 0; ik < K; ik++) {
    dxy1[ik] = dxy2[ik] = 0.0;
  }
  for (i = 0; i < N; i++) {
    for (d = 0; d < dim; d++)
      xc[d] = x[d][i];
    neiK(x, dim, 0, 1, i, BOX, epsilon, K, box, lis, nn);
    for (ik = 0; ik < K; ik++) {
      Eps[ik] = 0;
      maxdim[ik] = -1;
      for (d = 0; d < dim; d++) {
        eps[ik][d] = 0;
        for (k = 1; k <= ik + 1; k++) {
          if ((dx = fabs(xc[d] - x[d][nn[k]])) > eps[ik][d])
            eps[ik][d] = dx;
        }
        if (eps[ik][d] > Eps[ik]) {
          Eps[ik] = eps[ik][d];
          maxdim[ik] = d;
        }
      }
    }
    for (ik = 0; ik < K; ik++) {
      for (d = 0; d < dim; d++) {
        n2[ik][d] = neiE1(x[d], i, scal[d & 1], BOX1, eps[ik][d], box1[d], lis1[d], mxi[d]);
        if (d == maxdim[ik]) {
          n1[ik][d] = n2[ik][d];
          dxy1[ik] += psi[n1[ik][d]];
        } else {
          n1[ik][d] = neiE1(x[d], i, scal[d & 1], BOX1, Eps[ik], box1[d], lis1[d], mxi[d]);
          dxy1[ik] += psi[n1[ik][d] + 1];
        }
        dxy2[ik] += psi[n2[ik][d]];
      }
    }
  }
  for (ik = 0; ik < K; ik++) {
    dxy1[ik] /= N;
    mi_cr[ik * 2] = (float)((dim - 1) * psi[N] + psi[ik + 1] - dxy1[ik]);
    dxy2[ik] /= N;
    mi_cr[ik * 2 + 1] = (float)((dim - 1) * psi[N] + phi[ik + 1] - dxy2[ik]);
  }
  free(xc);
  free(nn);
  for (i = 0; i < BOX; i++)
    free(box[i]);
  free(box);
  free(lis);
  for (d = 0; d < dim; d++) {
    free(box1[d]);
    free(lis1[d]);
    free(mxi[d]);
  }
  free(box1);
  free(lis1);
  free(mxi);
  for (ik = 0; ik < K; ik++) {
    free(eps[ik]);
    free(n1[ik]);
    free(n2[ik]);
  }
  free(eps);
  free(n1);
  free(n2);
  free(Eps);
  free(maxdim);
  free(dxy1);
  free(dxy2);
}
```