user: Please show me the C implementation that matches the assembly code listed below:

```asm
<form_flat_clusters_from_monotonic_criterion>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  movslq %ecx,%rdi
  pxor   %xmm1,%xmm1
  push   %r14
  mov    %rdi,%rax
  cvtsi2sd %edi,%xmm1
  pxor   %xmm2,%xmm2
  push   %r13
  shr    $0x3,%rax
  push   %r12
  cvtsi2sd %rax,%xmm2
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  mulsd  D0(%rip),%xmm1
  mov    %rdx,0x20(%rsp)
  ucomisd %xmm2,%xmm1
  jp     L62
  mov    %eax,%r13d
  jne    L62
L215:
  shl    $0x2,%rdi
  movslq %r13d,%r13
  movsd  %xmm0,0x28(%rsp)
  call   <malloc@plt>
  mov    $0x1,%esi
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <calloc@plt>
  mov    $0x1,%esi
  mov    %r13,%rdi
  mov    %rax,0x10(%rsp)
  call   <calloc@plt>
  lea    -0x2(%rbx,%rbx,1),%r9d
  mov    %rbp,(%rsp)
  xor    %esi,%esi
  mov    %rax,0x18(%rsp)
  movsd  0x28(%rsp),%xmm0
  mov    $0xffffffff,%r10d
  xor    %r11d,%r11d
  mov    %r9d,(%r12)
  movl   $0x0,0xc(%rsp)
  nopl   (%rax)
L55:
  mov    %r9d,%eax
  mov    (%rsp),%rcx
  sub    %ebx,%eax
  lea    0x0(,%rax,4),%edx
  movslq %edx,%rdx
  lea    (%r15,%rdx,8),%rdx
  cvttsd2si (%rdx),%edi
  cvttsd2si 0x8(%rdx),%r8d
  movslq %eax,%rdx
  movsd  (%rcx,%rdx,8),%xmm1
  cmp    $0xffffffff,%r10d
  je     L135
L37:
  cmp    %edi,%ebx
  jg     L202
  mov    %rdx,%r13
  mov    %eax,%ecx
  shr    $0x3,%r13
  add    0x10(%rsp),%r13
  not    %ecx
  movzbl 0x0(%r13),%ebp
  and    $0x7,%ecx
  bt     %ecx,%ebp
  mov    %ebp,%r14d
  jae    L100
L202:
  cmp    %r8d,%ebx
  jg     L2
  shr    $0x3,%rdx
  add    0x18(%rsp),%rdx
  not    %eax
  movzbl (%rdx),%r13d
  mov    %eax,%ecx
  and    $0x7,%ecx
  movzbl %r13b,%eax
  bt     %ecx,%eax
  jae    L119
L2:
  cmp    %r9d,%ebx
  jg     L0
  cmp    %edi,%ebx
  jle    L204
  mov    0x20(%rsp),%rax
  movslq %edi,%rdi
  lea    (%rax,%rdi,4),%rax
  cmp    $0xffffffff,%r10d
  je     L14
  mov    0xc(%rsp),%edi
  mov    %edi,(%rax)
  cmp    %r8d,%ebx
  jg     L213
L183:
  cmp    %esi,%r10d
  mov    $0xffffffff,%eax
  cmove  %eax,%r10d
L0:
  sub    $0x1,%esi
  jb     L146
L172:
  movslq %esi,%r11
  mov    (%r12,%r11,4),%r9d
  jmp    L55
  nopl   0x0(%rax)
L204:
  cmp    %r8d,%ebx
  jle    L183
  cmp    $0xffffffff,%r10d
  je     L136
L213:
  mov    0x20(%rsp),%rax
  mov    0xc(%rsp),%edi
  movslq %r8d,%r8
  mov    %edi,(%rax,%r8,4)
  jmp    L183
  nopl   0x0(%rax)
L135:
  comisd %xmm1,%xmm0
  jb     L37
  addl   $0x1,0xc(%rsp)
  mov    %esi,%r10d
  jmp    L37
  nopw   0x0(%rax,%rax,1)
L100:
  mov    $0x1,%eax
  mov    %edi,0x4(%r12,%r11,4)
  add    $0x1,%esi
  shl    %cl,%eax
  or     %eax,%r14d
  mov    %r14b,0x0(%r13)
  jmp    L172
  nopl   0x0(%rax,%rax,1)
L119:
  mov    $0x1,%eax
  mov    %r8d,0x4(%r12,%r11,4)
  add    $0x1,%esi
  shl    %cl,%eax
  or     %eax,%r13d
  mov    %r13b,(%rdx)
  jmp    L172
  nopw   0x0(%rax,%rax,1)
L146:
  mov    %r12,%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    0x18(%rsp),%rdi
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free@plt>
  nopw   0x0(%rax,%rax,1)
L62:
  lea    0x1(%rax),%r13d
  jmp    L215
  nopl   0x0(%rax)
L14:
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%edi
  mov    %edi,(%rax)
  cmp    %r8d,%ebx
  jle    L0
L136:
  addl   $0x1,0xc(%rsp)
  mov    0x20(%rsp),%rdi
  movslq %r8d,%r8
  mov    0xc(%rsp),%eax
  mov    %eax,(%rdi,%r8,4)
  jmp    L0
```

tool_calls: name: read_data
arguments: tag: D0
type_guessed: byte[8]

tool: {"D0": [0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x3f]}

assistant: ```c
void form_flat_clusters_from_monotonic_criterion(const double *Z, const double *mono_crit, int *T, double cutoff, int n) {
  int *curNode;
  int ndid, lid, rid, k, ms, nc;
  unsigned char *lvisited, *rvisited;
  double max_crit;
  const double *Zrow;
  const int bff = (((((double)(n)) / (double)(sizeof(unsigned char) * 8)) == ((double)(((n)) / ((sizeof(unsigned char) * 8)))) ? (((n)) / ((sizeof(unsigned char) * 8))) : (((n)) / ((sizeof(unsigned char) * 8)) + 1)));
  curNode = (int *)malloc(n * sizeof(int));
  lvisited = (unsigned char *)malloc(bff);
  rvisited = (unsigned char *)malloc(bff);
  nc = 0;
  ms = -1;
  k = 0;
  curNode[k] = (n * 2) - 2;
  bzero(lvisited, bff);
  bzero(rvisited, bff);
  ms = -1;
  while (k >= 0) {
    ndid = curNode[k];
    Zrow = Z + ((ndid - n) * 4);
    lid = (int)Zrow[0];
    rid = (int)Zrow[1];
    max_crit = mono_crit[ndid - n];
    ;
    if (ms == -1 && max_crit <= cutoff) {
      ;
      ms = k;
      nc++;
    }
    if (lid >= n && !(((lvisited)[(ndid - n) / (sizeof(unsigned char) * 8)] >> (((sizeof(unsigned char) * 8) - 1) - ((ndid - n) % (sizeof(unsigned char) * 8)))) & 0x1)) {
      ((lvisited)[(ndid - n) / (sizeof(unsigned char) * 8)] |= ((0x1) << (((sizeof(unsigned char) * 8) - 1) - ((ndid - n) % (sizeof(unsigned char) * 8)))));
      curNode[k + 1] = lid;
      k++;
      continue;
    }
    if (rid >= n && !(((rvisited)[(ndid - n) / (sizeof(unsigned char) * 8)] >> (((sizeof(unsigned char) * 8) - 1) - ((ndid - n) % (sizeof(unsigned char) * 8)))) & 0x1)) {
      ((rvisited)[(ndid - n) / (sizeof(unsigned char) * 8)] |= ((0x1) << (((sizeof(unsigned char) * 8) - 1) - ((ndid - n) % (sizeof(unsigned char) * 8)))));
      curNode[k + 1] = rid;
      k++;
      continue;
    }
    if (ndid >= n) {
      if (lid < n) {
        if (ms == -1) {
          nc++;
          T[lid] = nc;
        } else {
          T[lid] = nc;
        }
      }
      if (rid < n) {
        if (ms == -1) {
          nc++;
          T[rid] = nc;
        } else {
          T[rid] = nc;
        }
      }
      if (ms == k) {
        ms = -1;
      }
    }
    k--;
  }
  free(curNode);
  free(lvisited);
  free(rvisited);
}
```