user: 请从给定的汇编指令推导出C源代码：

```asm
<mi_d>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %ecx,%r14d
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x188,%rsp
  mov    0x1c0(%rsp),%rax
  mov    %esi,0x8c(%rsp)
  mov    %edx,0xcc(%rsp)
  mov    %ecx,0xc8(%rsp)
  mov    %r8,0x130(%rsp)
  mov    %r9,0x70(%rsp)
  mov    %rax,0x158(%rsp)
  movsd  %xmm0,0x20(%rsp)
  movsd  %xmm1,0x8(%rsp)
  movsd  %xmm2,0x28(%rsp)
  movsd  %xmm3,(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x178(%rsp)
  xor    %eax,%eax
  lea    0x1(%rcx),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,%rdi
  mov    %rax,0x18(%rsp)
  call   <malloc@plt>
  mov    %rax,0xa0(%rsp)
  lea    0x1(%rbx),%eax
  movslq %eax,%rbx
  mov    %eax,0x30(%rsp)
  shl    $0x3,%rbx
  mov    %rbx,%rdi
  call   <malloc@plt>
  pxor   %xmm5,%xmm5
  pxor   %xmm7,%xmm7
  movsd  D34(%rip),%xmm4
  cvtsi2sd %r14d,%xmm5
  movsd  (%rsp),%xmm0
  mov    %rax,0x100(%rsp)
  mov    $0x1,%eax
  cvtsi2sd %ebp,%xmm7
  mov    %eax,0x138(%rsp)
  movsd  0x8(%rsp),%xmm1
  movapd %xmm5,%xmm2
  movsd  %xmm7,0x120(%rsp)
  mulsd  %xmm4,%xmm2
  comisd %xmm2,%xmm7
  jbe    L35
L207:
  movsd  0x120(%rsp),%xmm7
  add    %eax,%eax
  pxor   %xmm3,%xmm3
  cvtsi2sd %eax,%xmm3
  movapd %xmm3,%xmm2
  mulsd  %xmm4,%xmm2
  mulsd  %xmm3,%xmm2
  mulsd  %xmm5,%xmm2
  comisd %xmm2,%xmm7
  ja     L207
  movsd  D10(%rip),%xmm2
  cltq
  mov    %rax,%rsi
  lea    0x0(,%rax,8),%rcx
  mov    %eax,0x138(%rsp)
  shl    $0x2,%rax
  divsd  %xmm3,%xmm2
  sar    $0x2,%esi
  mov    %rcx,0x8(%rsp)
  mov    %rax,0x10(%rsp)
  mov    %esi,(%rsp)
  movsd  %xmm2,0x128(%rsp)
L429:
  mov    0xcc(%rsp),%ebp
  pxor   %xmm2,%xmm2
  subsd  0x20(%rsp),%xmm1
  sub    $0x8,%rbx
  subsd  0x28(%rsp),%xmm0
  movslq 0x8c(%rsp),%rsi
  mov    %rbx,%rdi
  xor    %r12d,%r12d
  lea    -0x5(%rbp),%r14d
  cvtsi2sd %r14d,%xmm2
  mov    %rsi,0x108(%rsp)
  movapd %xmm2,%xmm6
  divsd  %xmm1,%xmm6
  divsd  %xmm0,%xmm2
  movsd  %xmm6,0xa8(%rsp)
  movsd  %xmm6,0x160(%rsp)
  movsd  %xmm2,0x168(%rsp)
  call   <malloc@plt>
  mov    %rbx,%rdi
  mov    %rax,0x50(%rsp)
  call   <malloc@plt>
  mov    %rbx,%rdi
  mov    %rax,0x58(%rsp)
  call   <malloc@plt>
  movslq %ebp,%rsi
  mov    %rax,0x60(%rsp)
  mov    0x8c(%rsp),%eax
  lea    0x0(,%rsi,4),%rbp
  mov    %rsi,0x150(%rsp)
  lea    -0x10(%rbp),%r13
  test   %eax,%eax
  jle    L44
L99:
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    0x50(%rsp),%rsi
  mov    %rbp,%rdi
  mov    %rax,(%rsi,%r12,8)
  call   <malloc@plt>
  mov    0x58(%rsp),%rsi
  mov    %r13,%rdi
  mov    %rax,(%rsi,%r12,8)
  call   <malloc@plt>
  mov    0x60(%rsp),%rsi
  mov    %rax,(%rsi,%r12,8)
  add    $0x1,%r12
  cmp    %r12,0x108(%rsp)
  jne    L99
L44:
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    %rax,0xe8(%rsp)
  mov    %rax,0x148(%rsp)
  mov    0x138(%rsp),%eax
  lea    0x0(%r13,%rax,8),%rax
  mov    %rax,0x110(%rsp)
L57:
  mov    0x10(%rsp),%rdi
  add    $0x8,%r13
  call   <malloc@plt>
  mov    %rax,-0x8(%r13)
  cmp    %r13,0x110(%rsp)
  jne    L57
  mov    %rbp,%rdi
  xor    %r12d,%r12d
  call   <malloc@plt>
  mov    %rax,0xf0(%rsp)
  movslq 0xc8(%rsp),%rax
  lea    0x0(,%rax,8),%r13
  mov    %rax,0x140(%rsp)
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,0x90(%rsp)
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,0x80(%rsp)
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,0xf8(%rsp)
  call   <malloc@plt>
  mov    0x18(%rsp),%rdi
  mov    %rax,0x98(%rsp)
  sub    $0x4,%rdi
  call   <malloc@plt>
  mov    0x108(%rsp),%rsi
  mov    %rax,0x118(%rsp)
  mov    0xc8(%rsp),%eax
  lea    0x0(,%rsi,4),%rbp
  test   %eax,%eax
  jle    L341
L343:
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    0x90(%rsp),%rsi
  mov    %rbp,%rdi
  mov    %rax,(%rsi,%r12,8)
  call   <malloc@plt>
  mov    0xf8(%rsp),%rsi
  mov    %rbp,%rdi
  mov    %rax,(%rsi,%r12,8)
  call   <malloc@plt>
  mov    0x98(%rsp),%rsi
  mov    %rax,(%rsi,%r12,8)
  mov    0x130(%rsp),%rax
  movl   $0x0,(%rax,%r12,8)
  movl   $0x0,0x4(%rax,%r12,8)
  add    $0x1,%r12
  cmp    %r12,0x140(%rsp)
  jne    L343
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,0xd0(%rsp)
  call   <malloc@plt>
  sub    $0x8,%rsp
  xor    %ecx,%ecx
  mov    %r15,%rdi
  mov    %rax,0xe0(%rsp)
  mov    $0x1,%r8d
  push   0xf8(%rsp)
  push   0xf8(%rsp)
  mov    0x18(%rsp),%eax
  push   %rax
  mov    0xac(%rsp),%ebx
  xor    %eax,%eax
  mov    0x158(%rsp),%r9d
  mov    0xec(%rsp),%edx
  mov    %ebx,%esi
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jle    L258
L266:
  mov    0x30(%rsp),%ebx
  mov    0x50(%rsp),%r12
  mov    $0x1,%ebp
  movsd  0xa8(%rsp),%xmm0
  jmp    L384
L71:
  and    $0x1,%eax
  movsd  0x160(%rsp,%rax,8),%xmm0
L384:
  mov    0x60(%rsp),%rax
  mov    -0x8(%r12,%rbp,8),%rcx
  mov    %r14d,%edx
  mov    -0x8(%r15,%rbp,8),%rdi
  mov    0xcc(%rsp),%esi
  mov    -0x8(%rax,%rbp,8),%r9
  mov    0x58(%rsp),%rax
  mov    -0x8(%rax,%rbp,8),%r8
  mov    $0x1,%eax
  call   <make_box1@plt>
  mov    %ebp,%eax
  add    $0x1,%rbp
  cmp    %rbp,%rbx
  jne    L71
  mov    0xc8(%rsp),%r11d
  test   %r11d,%r11d
  jle    L278
L258:
  mov    0xc8(%rsp),%r12d
  mov    0xd8(%rsp),%rdi
  xor    %esi,%esi
  shl    $0x3,%r12
  mov    %r12,%rdx
  call   <memset@plt>
  mov    0xd0(%rsp),%rdi
  mov    %r12,%rdx
  xor    %esi,%esi
  call   <memset@plt>
  mov    0xcc(%rsp),%r10d
  test   %r10d,%r10d
  jle    L222
L326:
  mov    0xc8(%rsp),%eax
  mov    0x80(%rsp),%rsi
  mov    %r14d,0x10(%rsp)
  movq   $0x0,0xe0(%rsp)
  sub    $0x1,%eax
  mov    %rax,0xb8(%rsp)
  lea    0x8(%rsi,%rax,8),%rax
  mov    %rax,0xb0(%rsp)
  mov    0x8c(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x13c(%rsp)
  mov    %rax,0x68(%rsp)
  lea    0x8(,%rax,8),%rax
  mov    %rax,0xc0(%rsp)
L193:
  mov    0xe0(%rsp),%rax
  mov    0x8c(%rsp),%edi
  mov    %eax,%r14d
  lea    0x0(,%rax,8),%rcx
  xor    %eax,%eax
  test   %edi,%edi
  jle    L263
  mov    0x100(%rsp),%rsi
  mov    0x68(%rsp),%rdi
  nopl   0x0(%rax,%rax,1)
L351:
  mov    (%r15,%rax,8),%rdx
  movsd  (%rdx,%rcx,1),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rdi,%rdx
  jne    L351
L263:
  mov    0xa0(%rsp),%rbp
  mov    %r14d,%r8d
  xor    %edx,%edx
  mov    %r15,%rdi
  mov    $0x1,%ecx
  mov    $0x1,%eax
  push   %rbp
  push   0xf8(%rsp)
  push   0xf8(%rsp)
  mov    0xe0(%rsp),%ebx
  push   %rbx
  mov    0x158(%rsp),%r9d
  movsd  0x148(%rsp),%xmm0
  mov    0xac(%rsp),%esi
  call   <neiK@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jle    L30
  mov    0x118(%rsp),%r12
  mov    0x90(%rsp),%r13
  mov    %r14d,0x8(%rsp)
  lea    0x8(%rbp),%rbx
  mov    0x80(%rsp),%rbp
  mov    %r12,0x20(%rsp)
  mov    %r13,%r14
  mov    %r12,%r8
  mov    0x68(%rsp),%r13
  mov    0x100(%rsp),%r12
  nopl   (%rax)
L89:
  mov    0x8c(%rsp),%r9d
  movq   $0x0,0x0(%rbp)
  movl   $0xffffffff,(%r8)
  test   %r9d,%r9d
  jle    L126
  mov    (%r14),%rdi
  mov    0xc0(%rsp),%rdx
  xor    %esi,%esi
  mov    %r8,(%rsp)
  call   <memset@plt>
  mov    (%rsp),%r8
  xor    %ecx,%ecx
  pxor   %xmm4,%xmm4
  mov    %rax,%rdi
  mov    0xa0(%rsp),%rax
  movq   D23(%rip),%xmm3
  lea    0x4(%rax),%r11
  nopw   0x0(%rax,%rax,1)
L257:
  movsd  (%r12,%rcx,8),%xmm2
  mov    (%r15,%rcx,8),%rdx
  mov    %ecx,%esi
  mov    %r11,%rax
  pxor   %xmm1,%xmm1
  nopl   0x0(%rax,%rax,1)
L338:
  movslq (%rax),%r9
  movapd %xmm2,%xmm0
  subsd  (%rdx,%r9,8),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm1,%xmm0
  jbe    L311
  movsd  %xmm0,(%rdi,%rcx,8)
  movapd %xmm0,%xmm1
L311:
  add    $0x4,%rax
  cmp    %rax,%rbx
  jne    L338
  comisd %xmm4,%xmm1
  jbe    L399
  mov    %esi,(%r8)
  movsd  %xmm1,0x0(%rbp)
L399:
  lea    0x1(%rcx),%rax
  cmp    %rcx,%r13
  je     L126
  movsd  0x0(%rbp),%xmm4
  mov    %rax,%rcx
  jmp    L257
  nopw   0x0(%rax,%rax,1)
L126:
  add    $0x8,%rbp
  add    $0x4,%r8
  add    $0x4,%rbx
  add    $0x8,%r14
  cmp    %rbp,0xb0(%rsp)
  jne    L89
  mov    0xd8(%rsp),%rax
  mov    0x8(%rsp),%r14d
  movq   $0x0,0x78(%rsp)
  mov    %rax,0x28(%rsp)
  mov    0xf8(%rsp),%rax
  mov    %r14d,0x18(%rsp)
  mov    %rax,0x38(%rsp)
  mov    0xd0(%rsp),%rax
  mov    %rax,0x30(%rsp)
L291:
  mov    0x8c(%rsp),%r8d
  test   %r8d,%r8d
  jle    L52
  mov    0x78(%rsp),%rax
  mov    0x90(%rsp),%rsi
  xor    %ebx,%ebx
  movsd  0xa8(%rsp),%xmm0
  mov    (%rsi,%rax,8),%rsi
  mov    %rsi,0x40(%rsp)
  mov    0x98(%rsp),%rsi
  mov    (%rsi,%rax,8),%rax
  mov    %rax,0x48(%rsp)
  jmp    L133
  nopl   (%rax)
L134:
  mov    (%rax),%rax
  mov    %ebp,(%rax,%rbx,4)
  mov    0x70(%rsp),%rax
  movsd  (%rax,%rbp,8),%xmm0
  mov    0x30(%rsp),%rax
  movsd  (%rax),%xmm1
  addsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax)
L33:
  mov    0x28(%rsp),%rax
  lea    0x1(%rbx),%rdx
  addsd  (%rax),%xmm0
  movsd  %xmm0,(%rax)
  lea    0x1(%rbx),%eax
  cmp    %rbx,0x68(%rsp)
  je     L52
  and    $0x1,%eax
  mov    %rdx,%rbx
  movsd  0x160(%rsp,%rax,8),%xmm0
L133:
  mov    0x60(%rsp),%rax
  mov    (%r15,%rbx,8),%rdi
  movsd  %xmm0,(%rsp)
  lea    0x0(,%rbx,4),%r14
  mov    0x10(%rsp),%edx
  mov    0x18(%rsp),%esi
  mov    (%rax,%rbx,8),%r9
  mov    0x58(%rsp),%rax
  mov    (%rax,%rbx,8),%r13
  mov    0x50(%rsp),%rax
  mov    %r9,0x8(%rsp)
  mov    (%rax,%rbx,8),%r12
  mov    0x40(%rsp),%rax
  mov    %r13,%r8
  movsd  (%rax,%rbx,8),%xmm1
  mov    %r12,%rcx
  mov    $0x2,%eax
  call   <neiE1@plt>
  movsd  (%rsp),%xmm0
  mov    0x8(%rsp),%r9
  movslq %eax,%rbp
  mov    0x48(%rsp),%rax
  mov    %ebp,(%rax,%rbx,4)
  mov    0x20(%rsp),%rax
  cmp    %ebx,(%rax)
  mov    0x38(%rsp),%rax
  je     L134
  mov    0x78(%rsp),%rsi
  add    (%rax),%r14
  mov    %r13,%r8
  mov    %r12,%rcx
  mov    0x80(%rsp),%rax
  mov    (%r15,%rbx,8),%rdi
  mov    0x10(%rsp),%edx
  movsd  (%rax,%rsi,8),%xmm1
  mov    0x18(%rsp),%esi
  mov    $0x2,%eax
  call   <neiE1@plt>
  mov    0x30(%rsp),%rsi
  mov    0x70(%rsp),%rdi
  mov    %eax,(%r14)
  cltq
  movsd  (%rsi),%xmm0
  addsd  0x8(%rdi,%rax,8),%xmm0
  movsd  %xmm0,(%rsi)
  movsd  (%rdi,%rbp,8),%xmm0
  jmp    L33
  nopl   0x0(%rax)
L52:
  mov    0x78(%rsp),%rsi
  addq   $0x8,0x28(%rsp)
  addq   $0x8,0x38(%rsp)
  addq   $0x8,0x30(%rsp)
  lea    0x1(%rsi),%rax
  addq   $0x4,0x20(%rsp)
  cmp    %rsi,0xb8(%rsp)
  je     L30
  mov    %rax,0x78(%rsp)
  jmp    L291
L30:
  addq   $0x1,0xe0(%rsp)
  mov    0xe0(%rsp),%rax
  cmp    %eax,0xcc(%rsp)
  jg     L193
  mov    0xc8(%rsp),%esi
  test   %esi,%esi
  jle    L78
L269:
  mov    0x70(%rsp),%rax
  mov    0x150(%rsp),%rsi
  pxor   %xmm1,%xmm1
  mov    0xd0(%rsp),%rdx
  mov    0xd8(%rsp),%rcx
  cvtsi2sdl 0x13c(%rsp),%xmm1
  mulsd  (%rax,%rsi,8),%xmm1
  mov    0x130(%rsp),%rsi
  xor    %eax,%eax
L120:
  movsd  (%rdx,%rax,8),%xmm2
  mov    0x70(%rsp),%rdi
  movsd  0x120(%rsp),%xmm5
  movsd  0x8(%rdi,%rax,8),%xmm0
  mov    0x158(%rsp),%rdi
  divsd  %xmm5,%xmm2
  addsd  %xmm1,%xmm0
  movsd  %xmm2,(%rdx,%rax,8)
  subsd  %xmm2,%xmm0
  movsd  (%rcx,%rax,8),%xmm2
  divsd  %xmm5,%xmm2
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,(%rsi,%rax,8)
  movsd  0x8(%rdi,%rax,8),%xmm0
  addsd  %xmm1,%xmm0
  subsd  %xmm2,%xmm0
  movsd  %xmm2,(%rcx,%rax,8)
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,0x4(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %eax,0xc8(%rsp)
  jg     L120
L78:
  mov    0x100(%rsp),%rdi
  call   <free@plt>
  mov    0xa0(%rsp),%rdi
  call   <free@plt>
  mov    0x148(%rsp),%rbx
L204:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbx,0x110(%rsp)
  jne    L204
  mov    0xe8(%rsp),%rdi
  xor    %ebx,%ebx
  call   <free@plt>
  mov    0xf0(%rsp),%rdi
  call   <free@plt>
  mov    0x8c(%rsp),%ecx
  test   %ecx,%ecx
  jle    L408
  mov    0x50(%rsp),%rbp
  mov    0x58(%rsp),%r12
  mov    0x60(%rsp),%r13
L407:
  mov    0x0(%rbp,%rbx,8),%rdi
  call   <free@plt>
  mov    (%r12,%rbx,8),%rdi
  call   <free@plt>
  mov    0x0(%r13,%rbx,8),%rdi
  add    $0x1,%rbx
  call   <free@plt>
  cmp    0x108(%rsp),%rbx
  jne    L407
L408:
  mov    0x50(%rsp),%rdi
  xor    %ebx,%ebx
  call   <free@plt>
  mov    0x58(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0xc8(%rsp),%edx
  test   %edx,%edx
  jle    L371
  mov    0x90(%rsp),%rbp
  mov    0xf8(%rsp),%r12
  mov    0x98(%rsp),%r13
L305:
  mov    0x0(%rbp,%rbx,8),%rdi
  call   <free@plt>
  mov    (%r12,%rbx,8),%rdi
  call   <free@plt>
  mov    0x0(%r13,%rbx,8),%rdi
  add    $0x1,%rbx
  call   <free@plt>
  cmp    %rbx,0x140(%rsp)
  jne    L305
L371:
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0xf8(%rsp),%rdi
  call   <free@plt>
  mov    0x98(%rsp),%rdi
  call   <free@plt>
  mov    0x80(%rsp),%rdi
  call   <free@plt>
  mov    0x118(%rsp),%rdi
  call   <free@plt>
  mov    0xd0(%rsp),%rdi
  call   <free@plt>
  mov    0x178(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L255
  mov    0xd8(%rsp),%rdi
  add    $0x188,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10c0 <free@plt>
L35:
  movsd  D10(%rip),%xmm6
  movl   $0x0,(%rsp)
  movq   $0x4,0x10(%rsp)
  movq   $0x8,0x8(%rsp)
  movsd  %xmm6,0x128(%rsp)
  jmp    L429
L341:
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %r13,%rdi
  mov    %rax,0xd0(%rsp)
  call   <malloc@plt>
  sub    $0x8,%rsp
  xor    %ecx,%ecx
  mov    %r15,%rdi
  mov    %rax,0xe0(%rsp)
  mov    $0x1,%r8d
  push   0xf8(%rsp)
  push   0xf8(%rsp)
  mov    0x18(%rsp),%eax
  push   %rax
  mov    0xac(%rsp),%ebx
  xor    %eax,%eax
  mov    0x158(%rsp),%r9d
  mov    0xec(%rsp),%edx
  mov    %ebx,%esi
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jg     L266
L278:
  mov    0xcc(%rsp),%eax
  test   %eax,%eax
  jg     L326
  jmp    L78
L222:
  mov    0x8c(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x13c(%rsp)
  jmp    L269
L255:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D34
type_guessed: f64
name: disassemble_data
arguments: tag: D10
type_guessed: f64
name: disassemble_data
arguments: tag: D23
type_guessed: qword

tool: D34: 0.5

tool: D10: 4

tool: D23: 9223372036854775807

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);
}
```