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

```asm
<mergecb>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    $0x1,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x50(%rsp)
  mov    %rdx,0x38(%rsp)
  mov    %ecx,0x58(%rsp)
  mov    %r8d,0x30(%rsp)
  movss  %xmm0,0x5c(%rsp)
  cmp    $0x1,%r8d
  je     L200
  mov    %rsi,%r15
  mov    %r8d,%edi
  mov    $0x4,%esi
  mov    %ecx,%ebx
  mov    %r9d,%r12d
  call   <calloc@plt>
  mov    %rax,0x40(%rsp)
  test   %ebx,%ebx
  jle    L61
  mov    0x58(%rsp),%edi
  mov    0x38(%rsp),%rcx
  mov    0x40(%rsp),%rsi
  lea    -0x1(%rdi),%edx
  mov    %rcx,%rax
  lea    0x1(%rcx,%rdx,1),%rcx
  nopw   0x0(%rax,%rax,1)
L97:
  movzbl (%rax),%edx
  add    $0x1,%rax
  addl   $0x1,(%rsi,%rdx,4)
  cmp    %rcx,%rax
  jne    L97
L61:
  mov    0x30(%rsp),%ebx
  mov    %ebx,%esi
  mov    %ebx,%edi
  call   <fmatrix@plt>
  mov    %rax,0x48(%rsp)
  cmp    $0x1,%ebx
  jle    L171
  mov    0x48(%rsp),%rax
  mov    0x30(%rsp),%ecx
  mov    $0x1,%r13d
  add    $0x8,%rax
  mov    %rax,0x18(%rsp)
  lea    -0x2(%rcx),%eax
  add    $0x2,%rax
  mov    %rax,0x28(%rsp)
  lea    -0x1(%rcx),%eax
  mov    %eax,0x34(%rsp)
  mov    %r15,%rax
  mov    %r13,%r15
  mov    %rax,%r13
  nopw   0x0(%rax,%rax,1)
L182:
  cmp    %r15d,0x30(%rsp)
  jle    L172
  mov    0x18(%rsp),%rax
  lea    0x0(,%r15,4),%r14
  mov    0x34(%rsp),%ebp
  lea    -0x8(%rax),%rcx
  sub    %r15d,%ebp
  mov    -0x8(%rax),%rbx
  mov    %rcx,0x10(%rsp)
  lea    -0x4(%r14),%rcx
  mov    %rcx,(%rsp)
  lea    0x1(%r15),%rcx
  add    %rcx,%rbp
  mov    %rcx,0x20(%rsp)
  lea    0x0(,%rbp,4),%rcx
  mov    %rcx,0x8(%rsp)
  mov    %r15,%rcx
  mov    %rax,%r15
  mov    %r12d,%eax
  mov    %rcx,%rbp
  mov    %r13,%r12
  mov    %eax,%r13d
  nop
L84:
  mov    (%r12,%r14,2),%rsi
  mov    -0x8(%r12,%rbp,8),%rdi
  mov    %r13d,%edx
  add    %r14,%rbx
  add    $0x8,%r15
  call   <distance2@plt>
  mov    0x10(%rsp),%rax
  mov    -0x8(%r15),%rdx
  movss  %xmm0,(%rbx)
  mov    (%rax),%rbx
  mov    (%rsp),%rax
  movss  (%rbx,%r14,1),%xmm0
  add    $0x4,%r14
  movss  %xmm0,(%rdx,%rax,1)
  cmp    0x8(%rsp),%r14
  jne    L84
  mov    %r13d,%eax
  mov    %r12,%r13
  mov    %eax,%r12d
L127:
  addq   $0x8,0x18(%rsp)
  mov    0x20(%rsp),%r15
  cmp    0x28(%rsp),%r15
  jne    L182
  mov    %r13,%r15
L171:
  movss  0x5c(%rsp),%xmm0
  pxor   %xmm1,%xmm1
  lea    0x5c(%rsp),%rbx
  comiss %xmm0,%xmm1
  ja     L5
L132:
  lea    D1(%rip),%rdi
  call   <printf@plt>
  push   $0x0
  mov    0x48(%rsp),%rbp
  mov    %r15,%rdx
  push   %rbp
  push   %r12
  push   %rbx
  mov    0x50(%rsp),%r14d
  mov    0x68(%rsp),%rbx
  mov    0x78(%rsp),%r8d
  mov    0x58(%rsp),%rcx
  mov    0x70(%rsp),%rsi
  mov    %r14d,%r9d
  mov    %rbx,%rdi
  call   <mergecb1@plt>
  mov    %rbx,%rdi
  add    $0x20,%rsp
  mov    %r14d,%esi
  mov    %eax,%r13d
  call   <free_fmatrix@plt>
  mov    %rbp,%rdi
  call   <free@plt>
L200:
  add    $0x68,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L172:
  lea    0x1(%r15),%rax
  mov    %rax,0x20(%rsp)
  jmp    L127
L5:
  mov    0x30(%rsp),%ebx
  mov    %r12d,%esi
  mov    %ebx,%edi
  call   <fmatrix@plt>
  mov    %rax,%rbp
  test   %ebx,%ebx
  jle    L33
  lea    0x0(,%rbx,8),%rax
  mov    %r15,%r9
  mov    %rbp,%rdi
  movslq %r12d,%rsi
  mov    %rax,(%rsp)
  lea    (%rax,%rbp,1),%r8
  sub    %rbp,%r9
  nopl   0x0(%rax,%rax,1)
L166:
  test   %r12d,%r12d
  jle    L80
  mov    (%r9,%rdi,1),%rcx
  mov    (%rdi),%rdx
  xor    %eax,%eax
  xchg   %ax,%ax
L160:
  movss  (%rcx,%rax,4),%xmm0
  movss  %xmm0,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L160
L80:
  add    $0x8,%rdi
  cmp    %r8,%rdi
  jne    L166
  mov    0x30(%rsp),%edi
  mov    $0x4,%esi
  call   <calloc@plt>
  mov    0x40(%rsp),%rdi
  mov    %rax,%r14
  mov    %r14,%rcx
  mov    %rdi,%rax
  lea    (%rdi,%rbx,4),%rsi
  sub    %rdi,%rcx
  nop
L17:
  mov    (%rax),%edx
  mov    %edx,(%rcx,%rax,1)
  add    $0x4,%rax
  cmp    %rax,%rsi
  jne    L17
  mov    0x30(%rsp),%edi
  mov    %edi,%esi
  call   <fmatrix@plt>
  mov    (%rsp),%r8
  mov    %rax,%r13
  mov    0x48(%rsp),%rax
  mov    %r13,%rdi
  add    %rax,%r8
  mov    %rax,%rsi
  sub    %rax,%rdi
  nopl   0x0(%rax)
L75:
  mov    (%rsi),%rcx
  mov    (%rdi,%rsi,1),%rdx
  xor    %eax,%eax
  nopl   0x0(%rax)
L67:
  movss  (%rcx,%rax,4),%xmm0
  movss  %xmm0,(%rdx,%rax,4)
  add    $0x1,%rax
  cmp    %rbx,%rax
  jne    L67
  add    $0x8,%rsi
  cmp    %rsi,%r8
  jne    L75
L69:
  cmp    $0x3,%r12d
  je     L175
  cmp    $0x1,%r12d
  jne    L195
  movl   $0x44480000,0x5c(%rsp)
L195:
  push   $0x1
  mov    %rbp,%rdx
  mov    %r13,%rdi
  push   %r14
  push   %r12
  lea    0x74(%rsp),%rbx
  push   %rbx
  mov    0x50(%rsp),%r9d
  mov    0x78(%rsp),%r8d
  mov    0x58(%rsp),%rcx
  mov    0x70(%rsp),%rsi
  call   <mergecb1@plt>
  mov    0x50(%rsp),%esi
  add    $0x20,%rsp
  mov    %rbp,%rdi
  call   <free_fmatrix@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    0x30(%rsp),%esi
  mov    %r13,%rdi
  call   <free_fmatrix@plt>
  movss  0x5c(%rsp),%xmm0
  jmp    L132
L175:
  movl   $0x43c80000,0x5c(%rsp)
  jmp    L195
L33:
  mov    0x30(%rsp),%ebx
  mov    $0x4,%esi
  mov    %ebx,%edi
  call   <calloc@plt>
  mov    %ebx,%esi
  mov    %ebx,%edi
  mov    %rax,%r14
  call   <fmatrix@plt>
  mov    %rax,%r13
  jmp    L69
```

tool_calls: name: retrieve_data
arguments: tag: D1
datatype: string

tool: D1: thresh %f 

assistant: ```c
int mergecb(float *B, float **cb, unsigned char *P, int npt, int N, float thresh, int dim) {
  int i, j, newN, *count, l, ei, *count2;
  float **dist, **dist2, **cb2;
  if (N == 1)
    return 1;
  count = (int *)calloc(N, sizeof(int));
  for (l = 0; l < npt; l++)
    count[P[l]]++;
  dist = (float **)fmatrix(N, N);
  ei = N - 1;
  for (i = 0; i < ei; i++) {
    for (j = i + 1; j < N; j++) {
      dist[i][j] = distance2(cb[i], cb[j], dim);
      dist[j][i] = dist[i][j];
    }
  }
  if (thresh < 0) {
    cb2 = (float **)fmatrix(N, dim);
    for (i = 0; i < N; i++)
      for (j = 0; j < dim; j++)
        cb2[i][j] = cb[i][j];
    count2 = (int *)calloc(N, sizeof(int));
    for (i = 0; i < N; i++)
      count2[i] = count[i];
    dist2 = (float **)fmatrix(N, N);
    for (i = 0; i < N; i++)
      for (j = 0; j < N; j++)
        dist2[i][j] = dist[i][j];
    if (dim == 3)
      thresh = 400;
    else if (dim == 1)
      thresh = 800;
    mergecb1(dist2, B, cb2, P, npt, N, &thresh, dim, count2, 1);
    free_fmatrix(cb2, N);
    free(count2);
    free_fmatrix(dist2, N);
  }
  printf("thresh %f ", thresh);
  newN = mergecb1(dist, B, cb, P, npt, N, &thresh, dim, count, 0);
  free_fmatrix(dist, N);
  free(count);
  return newN;
}
```