user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<mi_xnynKembed>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  push   %rbp
  lea    0x1(%rcx),%ebp
  push   %rbx
  movslq %ebp,%r12
  mov    %rdi,%rbx
  mov    %ebp,%ebp
  lea    0x0(,%r12,8),%r14
  mov    %r14,%rdi
  sub    $0x148,%rsp
  mov    0x180(%rsp),%rax
  mov    %esi,0x8(%rsp)
  mov    %edx,0x3c(%rsp)
  mov    0x1b0(%rsp),%r15
  mov    %rax,0x90(%rsp)
  mov    0x188(%rsp),%rax
  mov    %ecx,0x38(%rsp)
  mov    %rax,0x98(%rsp)
  mov    0x190(%rsp),%rax
  mov    %r8,0x80(%rsp)
  mov    %rax,0xa0(%rsp)
  mov    0x198(%rsp),%rax
  mov    %r9,0x88(%rsp)
  mov    %rax,0xa8(%rsp)
  mov    0x1a0(%rsp),%rax
  mov    %rax,0xb0(%rsp)
  mov    0x1a8(%rsp),%rax
  mov    %rax,0xb8(%rsp)
  mov    0x1b8(%rsp),%rax
  mov    %rax,0x110(%rsp)
  call   <malloc@plt>
  test   %r13d,%r13d
  mov    0x8(%rsp),%r10d
  movsd  D7(%rip),%xmm1
  mov    %rax,0xc0(%rsp)
  mov    $0x1,%eax
  jle    L202
L137:
  pxor   %xmm0,%xmm0
  movapd %xmm1,%xmm2
  mov    0xc0(%rsp),%rsi
  cvtsi2sd %eax,%xmm0
  divsd  %xmm0,%xmm2
  movsd  (%r15,%rax,8),%xmm0
  subsd  %xmm2,%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rbp
  jne    L137
L202:
  lea    0x0(,%r12,4),%rdx
  mov    %r10d,0x10(%rsp)
  sub    $0x8,%r14
  mov    %rdx,%rdi
  mov    %rdx,0x8(%rsp)
  call   <malloc@plt>
  mov    0x10(%rsp),%r10d
  mov    %rax,%r12
  lea    (%r10,%r10,1),%r13d
  movslq %r13d,%rax
  lea    0x0(,%rax,8),%rdi
  mov    %rax,0x120(%rsp)
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,0x48(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%rdx
  mov    %rax,0x50(%rsp)
  lea    -0x4(%rdx),%rdi
  mov    %rdi,0x8(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%rdi
  mov    %rax,0x58(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%rdi
  mov    %rax,0x60(%rsp)
  call   <malloc@plt>
  mov    0x8(%rsp),%rdi
  mov    %rax,0x68(%rsp)
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,0x70(%rsp)
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,0x28(%rsp)
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,0x40(%rsp)
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  movslq 0x38(%rsp),%rax
  mov    %rax,%rdi
  mov    %rax,%r14
  mov    %rax,0x20(%rsp)
  call   <malloc@plt>
  pxor   %xmm3,%xmm3
  movsd  D35(%rip),%xmm2
  pxor   %xmm6,%xmm6
  cvtsi2sd %r14d,%xmm3
  mov    %rax,0x78(%rsp)
  mov    0x10(%rsp),%r10d
  mov    $0x1,%eax
  cvtsi2sdl 0x3c(%rsp),%xmm6
  movl   $0x1,0x8(%rsp)
  movapd %xmm3,%xmm0
  movsd  %xmm6,0xe0(%rsp)
  mulsd  %xmm2,%xmm0
  comisd %xmm0,%xmm6
  jbe    L264
L210:
  movsd  0xe0(%rsp),%xmm7
  add    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm2,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  comisd %xmm0,%xmm7
  ja     L210
  movsd  D33(%rip),%xmm0
  cltq
  mov    %rax,%rsi
  mov    %eax,0x8(%rsp)
  lea    0x0(,%rax,8),%rdi
  lea    0x0(,%rax,4),%r14
  divsd  %xmm1,%xmm0
  sar    $0x2,%esi
  mov    %esi,0x10(%rsp)
  movsd  %xmm0,0x18(%rsp)
L229:
  mov    %r10d,0xd0(%rsp)
  call   <malloc@plt>
  mov    0xd0(%rsp),%r10d
  mov    %r15,0xd0(%rsp)
  mov    %rbx,%r15
  mov    %rax,%rdx
  mov    %rax,0xc8(%rsp)
  mov    %rax,0x100(%rsp)
  mov    0x8(%rsp),%eax
  mov    %rdx,%rbx
  sub    $0x1,%eax
  lea    0x8(%rdx,%rax,8),%rax
  mov    %rax,0xe8(%rsp)
L32:
  mov    %r14,%rdi
  mov    %r10d,0xd8(%rsp)
  add    $0x8,%rbx
  call   <malloc@plt>
  mov    0xd8(%rsp),%r10d
  mov    %rax,-0x8(%rbx)
  cmp    %rbx,0xe8(%rsp)
  jne    L32
  movslq 0x3c(%rsp),%rsi
  mov    %r10d,0xf0(%rsp)
  mov    %r15,%rbx
  mov    0xd0(%rsp),%r15
  lea    0x0(,%rsi,4),%r14
  mov    %rsi,0xf8(%rsp)
  mov    %r14,%rdi
  call   <malloc@plt>
  mov    %r14,%rdi
  mov    %rax,0xd0(%rsp)
  call   <malloc@plt>
  xor    %ecx,%ecx
  mov    %rbx,%rdi
  mov    %rax,0xd8(%rsp)
  push   0xd0(%rsp)
  push   0xd0(%rsp)
  push   %rax
  xor    %eax,%eax
  mov    0x28(%rsp),%esi
  push   %rsi
  mov    0x110(%rsp),%r10d
  mov    %r13d,%esi
  mov    0x28(%rsp),%r9d
  mov    0x5c(%rsp),%edx
  mov    %r10d,%r8d
  mov    %r10d,0x30(%rsp)
  call   <make_box2ind@plt>
  mov    0x58(%rsp),%edi
  add    $0x20,%rsp
  mov    0x10(%rsp),%r10d
  test   %edi,%edi
  jle    L21
  mov    0x20(%rsp),%r14
  mov    0x50(%rsp),%rdi
  xor    %esi,%esi
  shl    $0x3,%r14
  mov    %r14,%rdx
  call   <memset@plt>
  mov    0x48(%rsp),%rdi
  xor    %esi,%esi
  mov    %r14,%rdx
  call   <memset@plt>
  mov    0x3c(%rsp),%esi
  mov    0x10(%rsp),%r10d
  test   %esi,%esi
  jle    L118
L354:
  mov    0x38(%rsp),%eax
  mov    0x28(%rsp),%rsi
  lea    -0x1(%r10),%r14d
  movq   $0x0,0x10(%rsp)
  mov    %r14d,0x20(%rsp)
  shl    $0x3,%r14
  lea    -0x1(%rax),%r11d
  lea    0x1(%r11),%rax
  mov    %r11,0xf0(%rsp)
  mov    %rax,0x118(%rsp)
  lea    (%rsi,%rax,8),%rax
  mov    %rax,0x108(%rsp)
L209:
  mov    0xd8(%rsp),%rax
  mov    0x10(%rsp),%rsi
  movslq (%rax,%rsi,4),%rcx
  mov    0x120(%rsp),%rsi
  xor    %eax,%eax
  mov    %rcx,%r8
  shl    $0x3,%rcx
  test   %r13d,%r13d
  jle    L95
  nopl   (%rax)
L340:
  mov    (%rbx,%rax,8),%rdx
  movsd  (%rdx,%rcx,1),%xmm0
  movsd  %xmm0,0x0(%rbp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L340
L95:
  push   %r12
  mov    %r10d,%ecx
  xor    %edx,%edx
  mov    %r13d,%esi
  push   0xd8(%rsp)
  mov    %rbx,%rdi
  push   0xd8(%rsp)
  mov    0x50(%rsp),%eax
  push   %rax
  movsd  0x38(%rsp),%xmm0
  mov    $0x1,%eax
  mov    0x28(%rsp),%r9d
  mov    %r10d,0x158(%rsp)
  call   <neiK@plt>
  mov    0x58(%rsp),%ecx
  add    $0x20,%rsp
  movq   D22(%rip),%xmm3
  pxor   %xmm5,%xmm5
  mov    0x138(%rsp),%r10d
  test   %ecx,%ecx
  movapd %xmm3,%xmm4
  jle    L190
  mov    0x40(%rsp),%rsi
  mov    0x28(%rsp),%rcx
  mov    %r12,%rdx
  mov    0x108(%rsp),%r8
  nopw   0x0(%rax,%rax,1)
L355:
  movq   $0x0,(%rcx)
  xor    %r11d,%r11d
  movapd %xmm5,%xmm1
  test   %r10d,%r10d
  jle    L165
  nopl   0x0(%rax,%rax,1)
L143:
  movsd  0x0(%rbp,%r11,1),%xmm2
  mov    (%rbx,%r11,1),%rdi
  mov    %r12,%rax
  jmp    L92
L384:
  movsd  (%rcx),%xmm1
  add    $0x4,%rax
L92:
  movslq 0x4(%rax),%r9
  movapd %xmm2,%xmm0
  subsd  (%rdi,%r9,8),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm1,%xmm0
  jbe    L129
  movsd  %xmm0,(%rcx)
L129:
  cmp    %rax,%rdx
  jne    L384
  cmp    %r11,%r14
  je     L165
  movsd  (%rcx),%xmm1
  add    $0x8,%r11
  jmp    L143
  nopl   0x0(%rax,%rax,1)
L165:
  movq   $0x0,(%rsi)
  cmp    %r10d,%r13d
  jle    L269
  movslq %r10d,%r11
  movapd %xmm5,%xmm1
  nopl   0x0(%rax,%rax,1)
L318:
  movsd  0x0(%rbp,%r11,8),%xmm2
  mov    (%rbx,%r11,8),%rdi
  mov    %r12,%rax
  jmp    L270
  nopl   0x0(%rax,%rax,1)
L213:
  movsd  (%rsi),%xmm1
  add    $0x4,%rax
L270:
  movslq 0x4(%rax),%r9
  movapd %xmm2,%xmm0
  subsd  (%rdi,%r9,8),%xmm0
  andpd  %xmm4,%xmm0
  comisd %xmm1,%xmm0
  jbe    L260
  movsd  %xmm0,(%rsi)
L260:
  cmp    %rax,%rdx
  jne    L213
  add    $0x1,%r11
  cmp    %r11d,%r13d
  jle    L269
  movsd  (%rsi),%xmm1
  jmp    L318
  nopl   0x0(%rax,%rax,1)
L269:
  add    $0x8,%rcx
  add    $0x8,%rsi
  add    $0x4,%rdx
  cmp    %rcx,%r8
  jne    L355
  mov    0x10(%rsp),%rax
  sub    $0x8,%rsp
  mov    %r10d,%r8d
  xor    %edx,%edx
  mov    0xa8(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x68(%rsp)
  mov    $0x1,%eax
  push   0xa8(%rsp)
  push   0xa8(%rsp)
  push   0x48(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x50(%rsp),%ecx
  mov    0xb0(%rsp),%rdi
  mov    %r10d,0x168(%rsp)
  call   <neiEK@plt>
  mov    0x40(%rsp),%rax
  add    $0x28,%rsp
  xor    %edx,%edx
  mov    0xc0(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x78(%rsp)
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  push   0x60(%rsp)
  mov    0x30(%rsp),%eax
  push   %rax
  movsd  0x48(%rsp),%xmm0
  mov    $0x1,%eax
  mov    0x68(%rsp),%r9d
  mov    0x168(%rsp),%r8d
  mov    0x50(%rsp),%ecx
  mov    0xb8(%rsp),%rdi
  call   <neiEK@plt>
  mov    0x148(%rsp),%rdx
  add    $0x30,%rsp
  mov    0x78(%rsp),%rdi
  xor    %esi,%esi
  call   <memset@plt>
  mov    0x28(%rsp),%rdx
  mov    0x40(%rsp),%rcx
  xor    %eax,%eax
  mov    0x30(%rsp),%rdi
  mov    0x78(%rsp),%r8
  mov    0xf0(%rsp),%rsi
  mov    0x138(%rsp),%r10d
  jmp    L24
L62:
  movsd  %xmm1,(%rdi,%rax,8)
  lea    0x1(%rax),%r9
  cmp    %rax,%rsi
  je     L156
L58:
  mov    %r9,%rax
L24:
  movsd  (%rdx,%rax,8),%xmm1
  movsd  (%rcx,%rax,8),%xmm0
  comisd %xmm0,%xmm1
  ja     L62
  movb   $0x1,(%r8,%rax,1)
  lea    0x1(%rax),%r9
  movsd  %xmm0,(%rdi,%rax,8)
  cmp    %rax,%rsi
  jne    L58
L156:
  mov    0x10(%rsp),%rax
  sub    $0x8,%rsp
  mov    %r10d,%r8d
  xor    %edx,%edx
  mov    0xc0(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x70(%rsp)
  mov    $0x1,%eax
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  push   0x50(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x50(%rsp),%ecx
  mov    0xb8(%rsp),%rdi
  mov    %r10d,0x168(%rsp)
  call   <neiEK@plt>
  mov    0x40(%rsp),%rax
  add    $0x28,%rsp
  xor    %edx,%edx
  mov    0xa8(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x60(%rsp)
  push   0xa8(%rsp)
  push   0xa8(%rsp)
  push   0x50(%rsp)
  mov    0x30(%rsp),%eax
  push   %rax
  mov    0x168(%rsp),%r10d
  mov    $0x1,%eax
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x50(%rsp),%ecx
  mov    0xb0(%rsp),%rdi
  mov    %r10d,%r8d
  mov    %r10d,0x16c(%rsp)
  call   <neiEK@plt>
  add    $0x30,%rsp
  xor    %eax,%eax
  mov    0x48(%rsp),%r11
  mov    0x50(%rsp),%rdx
  mov    0x58(%rsp),%rdi
  mov    %r13d,0x138(%rsp)
  mov    0x60(%rsp),%r8
  mov    %r12,0x128(%rsp)
  mov    0xf0(%rsp),%r13
  mov    %rbp,0x130(%rsp)
  mov    0x78(%rsp),%r12
  mov    0x70(%rsp),%rbp
  mov    0x68(%rsp),%r9
  mov    0x13c(%rsp),%r10d
  jmp    L363
L300:
  movsd  0x8(%r15,%rcx,8),%xmm1
  addsd  (%r15,%rsi,8),%xmm1
  addsd  %xmm1,%xmm0
L67:
  movslq 0x0(%rbp,%rax,4),%rcx
  movslq (%r8,%rax,4),%rsi
  movsd  %xmm0,(%r11,%rax,8)
  movsd  (%r15,%rsi,8),%xmm0
  addsd  (%r15,%rcx,8),%xmm0
  lea    0x1(%rax),%rcx
  addsd  (%rdx,%rax,8),%xmm0
  movsd  %xmm0,(%rdx,%rax,8)
  cmp    %rax,%r13
  je     L353
  mov    %rcx,%rax
L363:
  cmpb   $0x0,(%r12,%rax,1)
  movsd  (%r11,%rax,8),%xmm0
  movslq (%rdi,%rax,4),%rcx
  movslq (%r9,%rax,4),%rsi
  jne    L300
  movsd  0x8(%r15,%rsi,8),%xmm1
  addsd  (%r15,%rcx,8),%xmm1
  addsd  %xmm1,%xmm0
  jmp    L67
L353:
  mov    0x138(%rsp),%r13d
  mov    0x128(%rsp),%r12
  mov    0x130(%rsp),%rbp
L102:
  addq   $0x1,0x10(%rsp)
  mov    0x10(%rsp),%rax
  cmp    %eax,0x3c(%rsp)
  jg     L209
  mov    0x38(%rsp),%edx
  test   %edx,%edx
  jle    L382
L118:
  mov    0xf8(%rsp),%rax
  mov    0x110(%rsp),%rdx
  mov    0x48(%rsp),%rsi
  mov    0x50(%rsp),%rdi
  lea    (%r15,%rax,8),%rcx
  xor    %eax,%eax
L74:
  movsd  (%rsi,%rax,8),%xmm1
  movsd  (%rcx),%xmm0
  add    $0x10,%rdx
  movsd  0xe0(%rsp),%xmm7
  addsd  0x8(%r15,%rax,8),%xmm0
  mov    0xc0(%rsp),%rbx
  divsd  %xmm7,%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm1,(%rsi,%rax,8)
  movsd  (%rdi,%rax,8),%xmm1
  divsd  %xmm7,%xmm1
  movsd  %xmm0,-0x10(%rdx)
  movsd  (%rcx),%xmm0
  addsd  0x8(%rbx,%rax,8),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm1,(%rdi,%rax,8)
  add    $0x1,%rax
  movsd  %xmm0,-0x8(%rdx)
  cmp    %eax,0x38(%rsp)
  jg     L74
L382:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  call   <free@plt>
  mov    0xd0(%rsp),%rdi
  call   <free@plt>
  mov    0x100(%rsp),%rbx
L315:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    0xe8(%rsp),%rbx
  jne    L315
  mov    0xc8(%rsp),%rdi
  call   <free@plt>
  mov    0xd8(%rsp),%rdi
  call   <free@plt>
  mov    0xc0(%rsp),%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rdi
  call   <free@plt>
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  mov    0x78(%rsp),%rdi
  call   <free@plt>
  mov    0x58(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x70(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    0x50(%rsp),%rdi
  add    $0x148,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10a0 <free@plt>
L190:
  mov    0x10(%rsp),%rax
  sub    $0x8,%rsp
  mov    %r10d,%r8d
  xor    %edx,%edx
  mov    0xa8(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x68(%rsp)
  mov    $0x1,%eax
  push   0xa8(%rsp)
  push   0xa8(%rsp)
  push   0x48(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x50(%rsp),%ecx
  mov    0xb0(%rsp),%rdi
  mov    %r10d,0x168(%rsp)
  call   <neiEK@plt>
  mov    0x40(%rsp),%rax
  add    $0x28,%rsp
  mov    0xc0(%rsp),%rdx
  mov    (%rdx,%rax,4),%esi
  push   0x78(%rsp)
  xor    %edx,%edx
  mov    $0x1,%eax
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  push   0x60(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x168(%rsp),%r8d
  mov    0x50(%rsp),%ecx
  mov    0xb8(%rsp),%rdi
  call   <neiEK@plt>
  mov    0x40(%rsp),%rax
  add    $0x28,%rsp
  mov    0xc0(%rsp),%rdx
  mov    (%rdx,%rax,4),%esi
  push   0x70(%rsp)
  xor    %edx,%edx
  mov    $0x1,%eax
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  push   0x50(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x168(%rsp),%r8d
  mov    0x50(%rsp),%ecx
  mov    0xb8(%rsp),%rdi
  call   <neiEK@plt>
  mov    0x40(%rsp),%rax
  add    $0x28,%rsp
  xor    %edx,%edx
  mov    0xa8(%rsp),%rsi
  mov    (%rsi,%rax,4),%esi
  push   0x60(%rsp)
  mov    $0x1,%eax
  push   0xa8(%rsp)
  push   0xa8(%rsp)
  push   0x50(%rsp)
  mov    0x30(%rsp),%ecx
  push   %rcx
  movsd  0x48(%rsp),%xmm0
  mov    0x68(%rsp),%r9d
  mov    0x168(%rsp),%r8d
  mov    0x50(%rsp),%ecx
  mov    0xb0(%rsp),%rdi
  call   <neiEK@plt>
  add    $0x30,%rsp
  mov    0x138(%rsp),%r10d
  jmp    L102
L264:
  movsd  D33(%rip),%xmm6
  mov    $0x4,%r14d
  mov    $0x8,%edi
  movl   $0x0,0x10(%rsp)
  movsd  %xmm6,0x18(%rsp)
  jmp    L229
L21:
  mov    0x3c(%rsp),%eax
  test   %eax,%eax
  jg     L354
  jmp    L382
```

tool_calls: name: disassemble_data
arguments: data_tag: D7
data_type: f32[2]
name: disassemble_data
arguments: data_tag: D35
data_type: f64
name: disassemble_data
arguments: data_tag: D33
data_type: f64
name: disassemble_data
arguments: data_tag: D22
data_type: qword

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

tool: D35: 0.5

tool: D33: 4

tool: D22: 9223372036854775807

assistant: ```c
void mi_xnynKembed(double **x, int dim, int N, int K, double **xx, double **yy, int **boxx, int *lisx, int *indx, int **boxy, int *lisy, int *indy, double *psi, double *mi_cr) {
  int i, ik, k, *nx1, *ny1, *nx2, *ny2;
  double *xc, dy, dx;
  double *epsx, *epsy, *Eps;
  char *maxdim;
  double *dxy1, *dxy2;
  int *nn;
  int d;
  int BOX;
  int **box, *lis;
  int *ind;
  double epsilon;
  int inveps;
  double *phi;
  phi = (double *)malloc((K + 1) * sizeof(double));
  for (i = 1; i <= K; i++)
    phi[i] = psi[i] - 1 / ((double)(i));
  nn = (int *)malloc((K + 1) * sizeof(int));
  xc = (double *)malloc((2 * dim) * sizeof(double));
  dxy1 = (double *)malloc((K) * sizeof(double));
  dxy2 = (double *)malloc((K) * sizeof(double));
  nx1 = (int *)malloc((K) * sizeof(int));
  nx2 = (int *)malloc((K) * sizeof(int));
  ny1 = (int *)malloc((K) * sizeof(int));
  ny2 = (int *)malloc((K) * sizeof(int));
  epsx = (double *)malloc((K) * sizeof(double));
  epsy = (double *)malloc((K) * sizeof(double));
  Eps = (double *)malloc((K) * sizeof(double));
  maxdim = (char *)malloc((K) * sizeof(char));
  BOX = 1;
  while (0.5 * BOX * BOX * K < N)
    BOX *= 2;
  epsilon = 4.0 / BOX;
  inveps = BOX / 4;
  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));
  ind = (int *)malloc((N) * sizeof(int));
  make_box2ind(x, 2 * dim, N, 0, dim, BOX, inveps, ind, box, lis);
  for (ik = 0; ik < K; ik++) {
    dxy1[ik] = dxy2[ik] = 0.0;
  }
  for (i = 0; i < N; i++) {
    for (d = 0; d < 2 * dim; d++)
      xc[d] = x[d][ind[i]];
    neiK(x, 2 * dim, 0, dim, ind[i], BOX, epsilon, K, box, lis, nn);
    for (ik = 0; ik < K; ik++) {
      epsx[ik] = 0;
      for (d = 0; d < dim; d++)
        for (k = 1; k <= ik + 1; k++)
          if ((dx = fabs(xc[d] - x[d][nn[k]])) > epsx[ik])
            epsx[ik] = dx;
      epsy[ik] = 0;
      for (d = dim; d < 2 * dim; d++)
        for (k = 1; k <= ik + 1; k++)
          if ((dy = fabs(xc[d] - x[d][nn[k]])) > epsy[ik])
            epsy[ik] = dy;
    }
    neiEK(xx, indx[i], 0, dim - 1, dim, K, BOX, epsilon, epsx, boxx, lisx, nx2);
    neiEK(yy, indy[i], 0, dim - 1, dim, K, BOX, epsilon, epsy, boxy, lisy, ny2);
    for (ik = 0; ik < K; ik++) {
      maxdim[ik] = 0;
      if (epsx[ik] > epsy[ik]) {
        Eps[ik] = epsx[ik];
      } else {
        Eps[ik] = epsy[ik];
        maxdim[ik] = 1;
      }
    }
    neiEK(yy, indy[i], 0, dim - 1, dim, K, BOX, epsilon, Eps, boxy, lisy, ny1);
    neiEK(xx, indx[i], 0, dim - 1, dim, K, BOX, epsilon, Eps, boxx, lisx, nx1);
    for (ik = 0; ik < K; ik++) {
      if (maxdim[ik])
        dxy1[ik] += psi[nx1[ik] + 1] + psi[ny1[ik]];
      else
        dxy1[ik] += psi[nx1[ik]] + psi[ny1[ik] + 1];
      dxy2[ik] += psi[nx2[ik]] + psi[ny2[ik]];
    }
  }
  for (ik = 0; ik < K; ik++) {
    dxy1[ik] /= N;
    mi_cr[2 * ik] = psi[N] + psi[ik + 1] - dxy1[ik];
    dxy2[ik] /= N;
    mi_cr[2 * ik + 1] = psi[N] + phi[ik + 1] - dxy2[ik];
  }
  free(xc);
  free(nn);
  free(lis);
  for (i = 0; i < BOX; i++)
    free(box[i]);
  free(box);
  free(ind);
  free(phi);
  free(epsx);
  free(epsy);
  free(Eps);
  free(maxdim);
  free(nx1);
  free(nx2);
  free(ny1);
  free(ny2);
  free(dxy1);
  free(dxy2);
}
```