user: Converte this assembly snippet into its equivalent C code:

```asm
<redc>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xb8,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %esi,0x60(%rsp)
  mov    %edx,%r14d
  mov    %ecx,%r15d
  mov    %ecx,0x70(%rsp)
  mov    %r8,0x38(%rsp)
  mov    %r9,0xa0(%rsp)
  lea    0x1(%rcx),%edi
  movslq %edi,%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,0x48(%rsp)
  add    $0x1,%ebx
  movslq %ebx,%rbx
  shl    $0x3,%rbx
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,0x50(%rsp)
  pxor   %xmm2,%xmm2
  cvtsi2sd %r15d,%xmm2
  pxor   %xmm7,%xmm7
  cvtsi2sd %r14d,%xmm7
  movsd  %xmm7,0x80(%rsp)
  movapd %xmm2,%xmm0
  mulsd  D10(%rip),%xmm0
  mov    $0x1,%eax
  movsd  D10(%rip),%xmm3
  comisd %xmm0,%xmm7
  jbe    L266
L51:
  add    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2sd %eax,%xmm1
  movapd %xmm1,%xmm0
  mulsd  %xmm3,%xmm0
  mulsd  %xmm1,%xmm0
  mulsd  %xmm2,%xmm0
  movsd  0x80(%rsp),%xmm7
  comisd %xmm0,%xmm7
  ja     L51
  mov    %eax,0x64(%rsp)
L178:
  movsd  D46(%rip),%xmm0
  divsd  %xmm1,%xmm0
  movsd  %xmm0,0x88(%rsp)
  mov    0x64(%rsp),%esi
  lea    0x3(%rsi),%eax
  test   %esi,%esi
  cmovns %esi,%eax
  sar    $0x2,%eax
  mov    %eax,0x40(%rsp)
  lea    -0x5(%r14),%eax
  mov    %eax,0x24(%rsp)
  mov    0x60(%rsp),%ebp
  movslq %ebp,%rax
  mov    %rax,0x8(%rsp)
  sub    $0x8,%rbx
  mov    %rbx,0x10(%rsp)
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  mov    %rbx,%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x28(%rsp)
  mov    %ebp,%esi
  test   %ebp,%ebp
  jle    L277
  lea    -0x4(%r14),%eax
  cltq
  lea    0x0(,%rax,4),%rbp
  lea    0x10(%rbp),%rcx
  mov    %rcx,(%rsp)
  mov    %esi,%r13d
  mov    $0x0,%ebx
  mov    %r12,0x30(%rsp)
  mov    0x18(%rsp),%r12
  mov    %r14d,0x58(%rsp)
  mov    %rdi,%r14
L245:
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,(%r15,%rbx,8)
  mov    (%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,(%r12,%rbx,8)
  mov    %rbp,%rdi
  call   <malloc@plt>
  mov    %rax,(%r14,%rbx,8)
  add    $0x1,%rbx
  cmp    %r13,%rbx
  jne    L245
  mov    0x30(%rsp),%r12
  mov    0x58(%rsp),%r14d
L277:
  mov    0x64(%rsp),%ebx
  movslq %ebx,%r13
  lea    0x0(,%r13,8),%rdi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,0x68(%rsp)
  mov    %ebx,%esi
  test   %ebx,%ebx
  jle    L290
  shl    $0x2,%r13
  mov    %rax,%rbx
  mov    %esi,%eax
  lea    (%rdi,%rax,8),%rbp
L116:
  mov    %r13,%rdi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L116
L290:
  movslq %r14d,%rax
  mov    %rax,0xa8(%rsp)
  lea    0x0(,%rax,4),%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %rax,0x78(%rsp)
  mov    0x10(%rsp),%rdi
  call   <malloc@plt>
  mov    %rax,0x90(%rsp)
  mov    0x8(%rsp),%rdi
  shl    $0x2,%rdi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  mov    0x60(%rsp),%esi
  lea    -0x1(%rsi),%r8d
  mov    %r8d,0x74(%rsp)
  sub    $0x8,%rsp
  push   %rbx
  push   0x78(%rsp)
  mov    0x58(%rsp),%eax
  push   %rax
  mov    0x84(%rsp),%r9d
  mov    $0x0,%ecx
  mov    %r14d,%edx
  mov    %esi,%ebx
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <make_box2@plt>
  add    $0x20,%rsp
  test   %ebx,%ebx
  jle    L165
  mov    %ebx,%ebp
  mov    $0x0,%ebx
  mov    0x28(%rsp),%r13
  mov    %r14d,(%rsp)
  mov    0xa0(%rsp),%r14
L268:
  mov    (%r15,%rbx,8),%rcx
  movsd  (%r14,%rbx,8),%xmm0
  mov    (%r12,%rbx,8),%rdi
  mov    0x0(%r13,%rbx,8),%r9
  mov    0x18(%rsp),%rax
  mov    (%rax,%rbx,8),%r8
  mov    0x24(%rsp),%edx
  mov    (%rsp),%esi
  mov    $0x1,%eax
  call   <make_box1@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L268
  mov    (%rsp),%r14d
L165:
  test   %r14d,%r14d
  jle    L209
  mov    %r14d,%eax
  mov    %rax,0x98(%rsp)
  mov    0x70(%rsp),%eax
  lea    -0x1(%rax),%eax
  mov    0x48(%rsp),%rsi
  lea    0x8(%rsi,%rax,4),%rbp
  movq   $0x0,0x40(%rsp)
  pxor   %xmm2,%xmm2
  movsd  %xmm2,0x8(%rsp)
  jmp    L125
L266:
  movl   $0x1,0x64(%rsp)
  movsd  D38(%rip),%xmm1
  jmp    L178
L279:
  add    $0x4,%rax
  cmp    %rbp,%rax
  je     L243
L124:
  movslq (%rax),%rbx
  movapd %xmm1,%xmm0
  subsd  (%rcx,%rbx,8),%xmm0
  andpd  D43(%rip),%xmm0
  comisd (%rdx),%xmm0
  jbe    L279
  movsd  %xmm0,(%rdx)
  jmp    L279
L243:
  movsd  (%rdx),%xmm0
  movsd  (%rsp),%xmm4
  comisd %xmm4,%xmm0
  cmova  %esi,%r14d
  maxsd  %xmm4,%xmm0
  movsd  %xmm0,(%rsp)
  add    $0x1,%rdi
  add    $0x8,%r8
  cmp    %r13,%rdi
  je     L78
L91:
  mov    %edi,%esi
  mov    %r8,%rdx
  movq   $0x0,(%r8)
  test   %r9d,%r9d
  jle    L243
  movsd  (%r11,%rdi,8),%xmm1
  mov    (%r12,%rdi,8),%rcx
  lea    0x4(%r10),%rax
  jmp    L124
L78:
  mov    $0x0,%ebx
  mov    %rbp,0x58(%rsp)
  mov    0xa0(%rsp),%rbp
  jmp    L246
L172:
  cltq
  mov    0x38(%rsp),%rsi
  movsd  0x8(%rsp),%xmm6
  addsd  (%rsi,%rax,8),%xmm6
  movsd  %xmm6,0x8(%rsp)
L224:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L106
L246:
  mov    (%r15,%rbx,8),%rcx
  movsd  0x0(%rbp,%rbx,8),%xmm0
  mov    (%r12,%rbx,8),%rdi
  mov    0x28(%rsp),%rax
  mov    (%rax,%rbx,8),%r9
  mov    0x18(%rsp),%rax
  mov    (%rax,%rbx,8),%r8
  movsd  (%rsp),%xmm1
  mov    0x24(%rsp),%edx
  mov    0x10(%rsp),%esi
  mov    $0x2,%eax
  call   <neiE1@plt>
  mov    0x30(%rsp),%rsi
  mov    %eax,(%rsi,%rbx,4)
  cmp    %ebx,%r14d
  je     L172
  cltq
  mov    0x38(%rsp),%rsi
  movsd  0x8(%rsp),%xmm5
  addsd  0x8(%rsi,%rax,8),%xmm5
  movsd  %xmm5,0x8(%rsp)
  jmp    L224
L106:
  mov    0x58(%rsp),%rbp
L252:
  addq   $0x1,0x40(%rsp)
  mov    0x40(%rsp),%rax
  cmp    0x98(%rsp),%rax
  je     L132
L125:
  mov    0x40(%rsp),%rax
  mov    %eax,0x10(%rsp)
  lea    0x0(,%rax,8),%rcx
  mov    0x60(%rsp),%esi
  mov    %esi,%r13d
  mov    $0x0,%eax
  test   %esi,%esi
  jle    L186
  mov    0x50(%rsp),%rsi
L164:
  mov    (%r12,%rax,8),%rdx
  movsd  (%rdx,%rcx,1),%xmm0
  movsd  %xmm0,(%rsi,%rax,8)
  add    $0x1,%rax
  cmp    %r13,%rax
  jne    L164
  push   0x48(%rsp)
  push   0x80(%rsp)
  push   0x78(%rsp)
  mov    0x88(%rsp),%ebx
  push   %rbx
  movsd  0xa8(%rsp),%xmm0
  mov    0x84(%rsp),%r9d
  mov    0x30(%rsp),%r8d
  mov    0x94(%rsp),%ecx
  mov    $0x0,%edx
  mov    0x80(%rsp),%esi
  mov    %r12,%rdi
  mov    $0x1,%eax
  call   <neiK@plt>
  mov    0xb0(%rsp),%r8
  add    $0x20,%rsp
  mov    $0x0,%edi
  mov    $0xffffffff,%r14d
  pxor   %xmm3,%xmm3
  movsd  %xmm3,(%rsp)
  mov    0x48(%rsp),%r10
  mov    0x50(%rsp),%r11
  mov    %ebx,%r9d
  jmp    L91
L209:
  pxor   %xmm2,%xmm2
  movsd  %xmm2,0x8(%rsp)
L132:
  pxor   %xmm1,%xmm1
  cvtsi2sdl 0x74(%rsp),%xmm1
  mov    0x38(%rsp),%rsi
  mov    0xa8(%rsp),%rax
  mulsd  (%rsi,%rax,8),%xmm1
  movslq 0x70(%rsp),%rax
  addsd  (%rsi,%rax,8),%xmm1
  movsd  0x8(%rsp),%xmm0
  divsd  0x80(%rsp),%xmm0
  subsd  %xmm0,%xmm1
  mov    0xf0(%rsp),%rax
  movsd  %xmm1,(%rax)
  mov    0x50(%rsp),%rdi
  call   <free@plt>
  mov    0x48(%rsp),%rdi
  call   <free@plt>
  mov    0x64(%rsp),%eax
  test   %eax,%eax
  jle    L210
  mov    0x68(%rsp),%rsi
  mov    %rsi,%rbx
  mov    %eax,%eax
  lea    (%rsi,%rax,8),%rbp
L111:
  mov    (%rbx),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L111
L210:
  mov    0x68(%rsp),%rdi
  call   <free@plt>
  mov    0x78(%rsp),%rdi
  call   <free@plt>
  mov    0x60(%rsp),%eax
  test   %eax,%eax
  jle    L200
  mov    %eax,%ebp
  mov    $0x0,%ebx
  mov    0x18(%rsp),%r12
  mov    0x28(%rsp),%r13
L241:
  mov    (%r15,%rbx,8),%rdi
  call   <free@plt>
  mov    (%r12,%rbx,8),%rdi
  call   <free@plt>
  mov    0x0(%r13,%rbx,8),%rdi
  call   <free@plt>
  add    $0x1,%rbx
  cmp    %rbx,%rbp
  jne    L241
L200:
  mov    %r15,%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rdi
  call   <free@plt>
  mov    0x90(%rsp),%rdi
  call   <free@plt>
  mov    0x30(%rsp),%rdi
  call   <free@plt>
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L186:
  push   0x48(%rsp)
  push   0x80(%rsp)
  push   0x78(%rsp)
  mov    0x88(%rsp),%eax
  push   %rax
  movsd  0xa8(%rsp),%xmm0
  mov    0x84(%rsp),%r9d
  mov    0x60(%rsp),%r8d
  mov    0x94(%rsp),%ecx
  mov    $0x0,%edx
  mov    0x80(%rsp),%esi
  mov    %r12,%rdi
  mov    $0x1,%eax
  call   <neiK@plt>
  add    $0x20,%rsp
  jmp    L252
```

tool_calls: name: parse_data
arguments: tag: D10
type_guessed: f64
name: parse_data
arguments: tag: D46
type_guessed: f64
name: parse_data
arguments: tag: D38
type_guessed: f32[2]
name: parse_data
arguments: tag: D43
type_guessed: qword[2]

tool: D10: 0.5

tool: D46: 4

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

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

assistant: ```c
void redc(double **x, int dim, int N, int K, double *psi, double *scal, double *mic) {
  int i, k, *n1;
  double *xc, dx;
  double *eps, Eps;
  int maxdim;
  double dxy1;
  int *nn;
  int d;
  int BOX, BOX1;
  int **box, *lis;
  int **box1;
  int **lis1;
  int **mxi;
  double epsilon;
  int inveps;
  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));
  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 = 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++) {
      n1[d] = neiE1(x[d], i, scal[d], BOX1, Eps, box1[d], lis1[d], mxi[d]);
      if (d == maxdim) {
        dxy1 += psi[n1[d]];
      } else {
        dxy1 += psi[n1[d] + 1];
      }
    }
  }
  dxy1 /= N;
  *mic = (dim - 1) * psi[N] + psi[K] - dxy1;
  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);
}
```