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

```asm
<red>:
  endbr64
  push   %r15
  mov    %ecx,%r15d
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  lea    0x1(%rcx),%ebx
  movslq %ebx,%rbx
  sub    $0x128,%rsp
  mov    0x160(%rsp),%rax
  mov    %esi,0x98(%rsp)
  mov    %ecx,0x9c(%rsp)
  mov    %rax,0x110(%rsp)
  mov    0x168(%rsp),%rax
  mov    %r8,0x58(%rsp)
  mov    %rax,0x118(%rsp)
  lea    0x0(,%rbx,8),%rax
  mov    %rax,%rdi
  mov    %r9,0xd8(%rsp)
  mov    %rax,0xf8(%rsp)
  call   <malloc@plt>
  mov    %rax,0xe8(%rsp)
  lea    -0x1(%rbp),%eax
  mov    %eax,0xa0(%rsp)
  test   %r15d,%r15d
  jle    L211
  pxor   %xmm5,%xmm5
  mov    0x9c(%rsp),%ecx
  cvtsi2sdl 0xa0(%rsp),%xmm5
  lea    -0x1(%rcx),%eax
  movsd  %xmm5,0xf0(%rsp)
  cmp    $0x2,%eax
  jbe    L14
  mov    %ecx,%eax
  movapd %xmm5,%xmm3
  movdqa D53(%rip),%xmm2
  movdqa D11(%rip),%xmm5
  shr    $0x2,%eax
  mov    0xe8(%rsp),%rcx
  mov    0x58(%rsp),%rsi
  unpcklpd %xmm3,%xmm3
  lea    -0x1(%rax),%edx
  mov    $0x8,%eax
  shl    $0x5,%rdx
  add    $0x28,%rdx
L183:
  movdqa %xmm2,%xmm0
  movapd %xmm3,%xmm4
  paddd  %xmm5,%xmm2
  pshufd $0xee,%xmm0,%xmm1
  cvtdq2pd %xmm0,%xmm0
  cvtdq2pd %xmm1,%xmm1
  divpd  %xmm1,%xmm4
  movupd 0x10(%rsi,%rax,1),%xmm1
  subpd  %xmm4,%xmm1
  movapd %xmm3,%xmm4
  divpd  %xmm0,%xmm4
  movupd (%rsi,%rax,1),%xmm0
  movups %xmm1,0x10(%rcx,%rax,1)
  subpd  %xmm4,%xmm0
  movups %xmm0,(%rcx,%rax,1)
  add    $0x20,%rax
  cmp    %rdx,%rax
  jne    L183
  mov    0x9c(%rsp),%ecx
  mov    %ecx,%edx
  and    $0xfffffffc,%edx
  lea    0x1(%rdx),%eax
  cmp    %ecx,%edx
  je     L135
L46:
  pxor   %xmm0,%xmm0
  mov    0x58(%rsp),%rsi
  movslq %eax,%rcx
  movsd  0xf0(%rsp),%xmm5
  cvtsi2sd %eax,%xmm0
  mov    0xe8(%rsp),%rdi
  mov    0x9c(%rsp),%r11d
  lea    0x0(,%rcx,8),%rdx
  movapd %xmm5,%xmm7
  divsd  %xmm0,%xmm7
  movsd  (%rsi,%rcx,8),%xmm0
  subsd  %xmm7,%xmm0
  movsd  %xmm0,(%rdi,%rcx,8)
  lea    0x1(%rax),%ecx
  cmp    %ecx,%r11d
  jl     L135
  pxor   %xmm0,%xmm0
  movapd %xmm5,%xmm1
  add    $0x2,%eax
  cvtsi2sd %ecx,%xmm0
  divsd  %xmm0,%xmm1
  movsd  0x8(%rsi,%rdx,1),%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,0x8(%rdi,%rdx,1)
  cmp    %eax,%r11d
  jl     L135
  pxor   %xmm0,%xmm0
  movapd %xmm5,%xmm7
  cvtsi2sd %eax,%xmm0
  divsd  %xmm0,%xmm7
  movsd  0x10(%rsi,%rdx,1),%xmm0
  subsd  %xmm7,%xmm0
  movsd  %xmm0,0x10(%rdi,%rdx,1)
L135:
  lea    0x0(,%rbx,4),%rdi
  call   <malloc@plt>
  mov    %rax,0xa8(%rsp)
  mov    0x98(%rsp),%eax
  lea    0x1(%rax),%ebx
  movslq %ebx,%rbx
  shl    $0x3,%rbx
  mov    %rbx,%rdi
  call   <malloc@plt>
  pxor   %xmm3,%xmm3
  pxor   %xmm7,%xmm7
  movsd  D1(%rip),%xmm2
  cvtsi2sd %r13d,%xmm7
  mov    %rax,0x88(%rsp)
  mov    $0x1,%eax
  cvtsi2sdl 0x9c(%rsp),%xmm3
  movl   $0x1,0xa4(%rsp)
  movsd  %xmm7,0xc0(%rsp)
  movapd %xmm3,%xmm0
  mulsd  %xmm2,%xmm0
  comisd %xmm0,%xmm7
  jbe    L217
  xchg   %ax,%ax
L297:
  movsd  0xc0(%rsp),%xmm6
  add    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm2,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  comisd %xmm0,%xmm6
  ja     L297
  movsd  D56(%rip),%xmm0
  cltq
  mov    %rax,%rcx
  lea    0x0(,%rax,8),%rsi
  mov    %eax,0xa4(%rsp)
  lea    0x0(,%rax,4),%r15
  divsd  %xmm1,%xmm0
  sar    $0x2,%ecx
  mov    %rsi,0x8(%rsp)
  mov    %ecx,0x10(%rsp)
  movsd  %xmm0,0xc8(%rsp)
L43:
  movslq 0x98(%rsp),%rcx
  sub    $0x8,%rbx
  lea    -0x5(%r13),%eax
  mov    %rbx,%rdi
  mov    %rbx,0x18(%rsp)
  mov    %rcx,0x80(%rsp)
  mov    %eax,0x48(%rsp)
  call   <malloc@plt>
  mov    %rbx,%rdi
  mov    %rax,0x50(%rsp)
  call   <malloc@plt>
  mov    %rbx,%rdi
  xor    %ebx,%ebx
  mov    %rax,0x38(%rsp)
  call   <malloc@plt>
  movslq %r13d,%rcx
  lea    0x0(,%rcx,4),%r12
  mov    %rcx,0xd0(%rsp)
  mov    0x98(%rsp),%ecx
  mov    %rax,0x40(%rsp)
  lea    -0x10(%r12),%rbp
  test   %ecx,%ecx
  jle    L15
  mov    %r15,0x20(%rsp)
  mov    0x40(%rsp),%r15
  mov    %r14,0x28(%rsp)
  mov    0x38(%rsp),%r14
  mov    %r13d,0x30(%rsp)
  mov    0x50(%rsp),%r13
  nopl   0x0(%rax)
L145:
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %r12,%rdi
  mov    %rax,0x0(%r13,%rbx,8)
  call   <malloc@plt>
  mov    %rbp,%rdi
  mov    %rax,(%r14,%rbx,8)
  call   <malloc@plt>
  mov    %rax,(%r15,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,0x80(%rsp)
  jne    L145
  mov    0x20(%rsp),%r15
  mov    0x28(%rsp),%r14
  mov    0x30(%rsp),%r13d
L15:
  mov    0x8(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %rax,0xb0(%rsp)
  mov    %rax,0x108(%rsp)
  mov    0xa4(%rsp),%eax
  lea    (%rbx,%rax,8),%rbp
  mov    %rbp,0x100(%rsp)
  nopw   0x0(%rax,%rax,1)
L296:
  mov    %r15,%rdi
  add    $0x8,%rbx
  call   <malloc@plt>
  mov    %rax,-0x8(%rbx)
  cmp    %rbx,%rbp
  jne    L296
  mov    %r12,%rdi
  call   <malloc@plt>
  mov    0x18(%rsp),%rdi
  mov    %rax,0xb8(%rsp)
  mov    %rax,%rbx
  call   <malloc@plt>
  mov    %rax,%r15
  mov    0x80(%rsp),%rax
  lea    0x0(,%rax,4),%rbp
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rbp,%rdi
  mov    %rax,0x68(%rsp)
  call   <malloc@plt>
  sub    $0x8,%rsp
  xor    %ecx,%ecx
  mov    %r13d,%edx
  mov    %rax,0x68(%rsp)
  mov    %r14,%rdi
  push   %rbx
  xor    %ebx,%ebx
  push   0xc0(%rsp)
  mov    0x28(%rsp),%eax
  push   %rax
  mov    0xb8(%rsp),%ebp
  xor    %eax,%eax
  mov    0xc4(%rsp),%r9d
  mov    0xc0(%rsp),%r8d
  mov    %ebp,%esi
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebp,%ebp
  jle    L191
  mov    0x48(%rsp),%ebp
  mov    0x50(%rsp),%r12
  mov    %r15,0x8(%rsp)
  mov    %r14,%r15
  mov    0xd8(%rsp),%r14
  nopl   0x0(%rax,%rax,1)
L74:
  mov    0x40(%rsp),%rax
  mov    (%r12,%rbx,8),%rcx
  mov    %ebp,%edx
  mov    %r13d,%esi
  movsd  (%r14,%rbx,8),%xmm0
  mov    (%r15,%rbx,8),%rdi
  mov    (%rax,%rbx,8),%r9
  mov    0x38(%rsp),%rax
  mov    (%rax,%rbx,8),%r8
  mov    $0x1,%eax
  add    $0x1,%rbx
  call   <make_box1@plt>
  cmp    %rbx,0x80(%rsp)
  jne    L74
  mov    %r15,%r14
  mov    0x8(%rsp),%r15
L191:
  test   %r13d,%r13d
  jle    L172
  mov    0xa0(%rsp),%eax
  mov    0xa8(%rsp),%rcx
  movq   $0x0,0x78(%rsp)
  movq   $0x0,0x10(%rsp)
  mov    %rax,0x28(%rsp)
  lea    0x8(,%rax,8),%rax
  mov    %rax,0xe0(%rsp)
  mov    0x9c(%rsp),%eax
  movq   $0x0,0x8(%rsp)
  sub    $0x1,%eax
  lea    0x8(%rcx,%rax,4),%rbp
  nopl   0x0(%rax)
L319:
  mov    0x78(%rsp),%rax
  mov    0x98(%rsp),%edx
  mov    %eax,%r10d
  lea    0x0(,%rax,8),%rcx
  xor    %eax,%eax
  test   %edx,%edx
  jle    L98
  mov    0x88(%rsp),%rsi
  mov    0x28(%rsp),%rdi
  xchg   %ax,%ax
L200:
  mov    (%r14,%rax,8),%rdx
  movsd  (%rdx,%rcx,1),%xmm0
  mov    %rax,%rdx
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %rdi,%rdx
  jne    L200
  mov    0xa8(%rsp),%rbx
  mov    %r10d,%r8d
  xor    %edx,%edx
  mov    %r14,%rdi
  mov    $0x1,%eax
  push   %rbx
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  mov    0xb4(%rsp),%r13d
  push   %r13
  mov    0xc4(%rsp),%r9d
  movsd  0xe8(%rsp),%xmm0
  mov    0xc0(%rsp),%ecx
  mov    0xb8(%rsp),%esi
  mov    %r10d,0x38(%rsp)
  call   <neiK@plt>
  add    $0x20,%rsp
  xor    %esi,%esi
  mov    %r15,%rdi
  mov    0xe0(%rsp),%rdx
  call   <memset@plt>
  xor    %edx,%edx
  mov    %r13d,%r9d
  mov    %rbx,%r11
  mov    0x18(%rsp),%r10d
  mov    0x28(%rsp),%r8
  pxor   %xmm4,%xmm4
  mov    %edx,%edi
  mov    0x88(%rsp),%rbx
  movq   D27(%rip),%xmm3
  mov    $0xffffffff,%esi
  test   %r9d,%r9d
  jle    L22
  nopl   0x0(%rax)
L265:
  movsd  (%rbx,%rdx,8),%xmm2
  mov    (%r14,%rdx,8),%rcx
  lea    0x4(%r11),%rax
  pxor   %xmm1,%xmm1
  nopl   0x0(%rax)
L302:
  movslq (%rax),%r12
  movapd %xmm2,%xmm0
  subsd  (%rcx,%r12,8),%xmm0
  andpd  %xmm3,%xmm0
  comisd %xmm1,%xmm0
  jbe    L122
  movsd  %xmm0,(%r15,%rdx,8)
  movapd %xmm0,%xmm1
L122:
  add    $0x4,%rax
  cmp    %rax,%rbp
  jne    L302
L57:
  comisd %xmm4,%xmm1
  maxsd  %xmm4,%xmm1
  lea    0x1(%rdx),%rax
  cmovbe %esi,%edi
  movapd %xmm1,%xmm4
  mov    %edi,%esi
  cmp    %r8,%rdx
  je     L112
  mov    %rax,%rdx
  mov    %edx,%edi
  test   %r9d,%r9d
  jg     L265
L22:
  pxor   %xmm1,%xmm1
  jmp    L57
  nopl   0x0(%rax)
L112:
  mov    %r15,0x30(%rsp)
  mov    %r14,%r13
  xor    %ebx,%ebx
  mov    %r10d,%r15d
  mov    %rbp,0x90(%rsp)
  mov    0xd8(%rsp),%r14
  mov    %edi,0x4c(%rsp)
  movsd  %xmm1,0x70(%rsp)
  jmp    L134
  nopl   0x0(%rax)
L273:
  movsd  (%r14,%rbx,8),%xmm0
  mov    0x48(%rsp),%edx
  mov    %r15d,%esi
  mov    %r12,%rcx
  mov    0x0(%r13,%rbx,8),%rdi
  movsd  0x70(%rsp),%xmm1
  mov    $0x2,%eax
  call   <neiE1@plt>
  mov    0x68(%rsp),%rsi
  movsd  0x8(%rsp),%xmm6
  movsd  0x10(%rsp),%xmm7
  mov    %eax,(%rsi,%rbx,4)
  mov    0x58(%rsp),%rsi
  cltq
  addsd  0x8(%rsi,%rax,8),%xmm6
  addsd  (%rsi,%rbp,8),%xmm7
  lea    0x1(%rbx),%rax
  movsd  %xmm6,0x8(%rsp)
  movsd  %xmm7,0x10(%rsp)
  cmp    0x28(%rsp),%rbx
  je     L192
L1:
  mov    %rax,%rbx
L134:
  mov    0x40(%rsp),%rax
  movsd  (%r14,%rbx,8),%xmm0
  mov    %r15d,%esi
  mov    0x0(%r13,%rbx,8),%rdi
  mov    0x48(%rsp),%edx
  mov    (%rax,%rbx,8),%r9
  mov    0x38(%rsp),%rax
  mov    (%rax,%rbx,8),%r8
  mov    0x50(%rsp),%rax
  mov    %r9,0x20(%rsp)
  mov    (%rax,%rbx,8),%r12
  mov    0x30(%rsp),%rax
  mov    %r8,0x18(%rsp)
  movsd  (%rax,%rbx,8),%xmm1
  mov    %r12,%rcx
  mov    $0x2,%eax
  call   <neiE1@plt>
  cmp    %ebx,0x4c(%rsp)
  mov    0x18(%rsp),%r8
  movslq %eax,%rbp
  mov    0x60(%rsp),%rax
  mov    0x20(%rsp),%r9
  mov    %ebp,(%rax,%rbx,4)
  jne    L273
  mov    0x68(%rsp),%rax
  movsd  0x8(%rsp),%xmm5
  mov    %ebp,(%rax,%rbx,4)
  mov    0x58(%rsp),%rax
  movsd  (%rax,%rbp,8),%xmm0
  lea    0x1(%rbx),%rax
  addsd  %xmm0,%xmm5
  addsd  0x10(%rsp),%xmm0
  movsd  %xmm5,0x8(%rsp)
  movsd  %xmm0,0x10(%rsp)
  cmp    0x28(%rsp),%rbx
  jne    L1
L192:
  mov    0x30(%rsp),%r15
  mov    0x90(%rsp),%rbp
  mov    %r13,%r14
L317:
  addq   $0x1,0x78(%rsp)
  mov    0x78(%rsp),%rax
  cmp    %rax,0xd0(%rsp)
  jne    L319
L125:
  movsd  0xc0(%rsp),%xmm7
  movsd  0x8(%rsp),%xmm0
  mov    0x58(%rsp),%rcx
  mov    0xd0(%rsp),%rax
  divsd  %xmm7,%xmm0
  mov    0xf8(%rsp),%rsi
  movsd  0xf0(%rsp),%xmm5
  lea    (%rcx,%rax,8),%rax
  mov    0x88(%rsp),%rdi
  movsd  (%rax),%xmm1
  mulsd  %xmm5,%xmm1
  addsd  -0x8(%rcx,%rsi,1),%xmm1
  mov    0x110(%rsp),%rcx
  subsd  %xmm0,%xmm1
  movsd  0x10(%rsp),%xmm0
  divsd  %xmm7,%xmm0
  movsd  %xmm1,(%rcx)
  mulsd  (%rax),%xmm5
  mov    0xe8(%rsp),%rax
  movapd %xmm5,%xmm1
  addsd  -0x8(%rax,%rsi,1),%xmm1
  mov    0x118(%rsp),%rax
  subsd  %xmm0,%xmm1
  movsd  %xmm1,(%rax)
  call   <free@plt>
  mov    0xa8(%rsp),%rdi
  call   <free@plt>
  mov    0x100(%rsp),%rbp
  mov    0x108(%rsp),%rbx
  nopl   0x0(%rax)
L176:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbx,%rbp
  jne    L176
  mov    0xb0(%rsp),%rdi
  xor    %ebx,%ebx
  call   <free@plt>
  mov    0xb8(%rsp),%rdi
  call   <free@plt>
  mov    0x98(%rsp),%eax
  test   %eax,%eax
  jle    L71
  mov    0x50(%rsp),%rbp
  mov    0x38(%rsp),%r12
  mov    0x40(%rsp),%r13
  mov    0x80(%rsp),%r14
  nop
L97:
  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,%r14
  jne    L97
L71:
  mov    0x50(%rsp),%rdi
  call   <free@plt>
  mov    0x38(%rsp),%rdi
  call   <free@plt>
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%rdi
  call   <free@plt>
  mov    0xe8(%rsp),%rdi
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <free@plt>
L98:
  push   0xa8(%rsp)
  xor    %edx,%edx
  mov    %r14,%rdi
  push   0xc0(%rsp)
  push   0xc0(%rsp)
  mov    0xb4(%rsp),%eax
  push   %rax
  mov    0xc4(%rsp),%r9d
  mov    $0x1,%eax
  movsd  0xe8(%rsp),%xmm0
  mov    0x98(%rsp),%r8d
  mov    0xc0(%rsp),%ecx
  mov    0xb8(%rsp),%esi
  call   <neiK@plt>
  add    $0x20,%rsp
  jmp    L317
L211:
  pxor   %xmm5,%xmm5
  cvtsi2sd %eax,%xmm5
  movsd  %xmm5,0xf0(%rsp)
  jmp    L135
L217:
  movsd  D56(%rip),%xmm7
  movl   $0x0,0x10(%rsp)
  mov    $0x4,%r15d
  movq   $0x8,0x8(%rsp)
  movsd  %xmm7,0xc8(%rsp)
  jmp    L43
L172:
  pxor   %xmm5,%xmm5
  movsd  %xmm5,0x10(%rsp)
  movsd  %xmm5,0x8(%rsp)
  jmp    L125
L14:
  mov    $0x1,%eax
  jmp    L46
```

tool_calls: name: parse_data
arguments: tag: D53
type_infered: byte[16]
name: parse_data
arguments: tag: D11
type_infered: byte[16]
name: parse_data
arguments: tag: D1
type_infered: f64
name: parse_data
arguments: tag: D56
type_infered: f64
name: parse_data
arguments: tag: D27
type_infered: qword

tool: {"D53": [0x01,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x03,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: {"D11": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

tool: D1: 0.5

tool: D56: 4

tool: D27: 9223372036854775807

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