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

```asm
<kmeans_it>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x50(%rsp)
  mov    %esi,0x5c(%rsp)
  mov    %edx,0x38(%rsp)
  mov    %ecx,0x18(%rsp)
  mov    %r8d,%r15d
  mov    %r8d,0x24(%rsp)
  mov    %r9,0x30(%rsp)
  movslq %ecx,%rbp
  lea    0x0(,%rbp,4),%rdi
  call   <malloc@plt>
  mov    %rax,%r14
  movslq %r15d,%rbx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <calloc@plt>
  mov    %rax,0x28(%rsp)
  lea    0x0(,%rbx,8),%rdi
  call   <malloc@plt>
  mov    %rax,0x40(%rsp)
  test   %r15d,%r15d
  jle    L193
  mov    %rax,%rcx
  mov    %rax,%rbx
  mov    %r15d,%eax
  lea    (%rcx,%rax,8),%r12
L219:
  mov    $0x4,%esi
  mov    %rbp,%rdi
  call   <calloc@plt>
  mov    %rax,(%rbx)
  add    $0x8,%rbx
  cmp    %r12,%rbx
  jne    L219
  cmpl   $0x0,0x5c(%rsp)
  jle    L169
L22:
  mov    0x5c(%rsp),%eax
  imul   0x38(%rsp),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,(%rsp)
  mov    0x18(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x4(,%rax,4),%rax
  mov    %rax,0x10(%rsp)
  add    %r14,%rax
  mov    %rax,0x48(%rsp)
  movl   $0x0,0x3c(%rsp)
  movl   $0x0,0x1c(%rsp)
  movl   $0x0,0x58(%rsp)
  jmp    L100
L292:
  mov    %r12d,0x1c(%rsp)
  mov    %eax,%ebp
L298:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L32
L227:
  mov    %ebx,%r12d
  mov    (%r15,%rbx,8),%rsi
  mov    0x18(%rsp),%edx
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <sqd_distance@plt>
  test   %ebp,%ebp
  js     L292
  cmp    %ebp,%eax
  jge    L298
  jmp    L292
L32:
  cmpl   $0x0,0x18(%rsp)
  jle    L263
L256:
  movslq 0x1c(%rsp),%rax
  lea    0x0(,%rax,8),%r13
  mov    0x30(%rsp),%rcx
  lea    (%rcx,%r13,1),%r15
  mov    0x28(%rsp),%rcx
  lea    (%rcx,%rax,4),%rax
  mov    %rax,0x8(%rsp)
  add    0x40(%rsp),%r13
  movslq 0x20(%rsp),%rax
  mov    0xa8(%rsp),%rdi
  lea    (%rdi,%rax,4),%rbp
  mov    $0x0,%ebx
L120:
  mov    (%r15),%rax
  mov    (%rax,%rbx,1),%eax
  mov    %eax,0x0(%rbp)
  mov    %rbx,%r12
  add    0x0(%r13),%r12
  mov    (%r14,%rbx,1),%esi
  pxor   %xmm0,%xmm0
  cvtss2sd (%r12),%xmm0
  mov    0x8(%rsp),%rax
  mov    (%rax),%edi
  mov    $0x1,%eax
  call   <mean_it@plt>
  pxor   %xmm0,%xmm0
  cvtsi2ss %eax,%xmm0
  movss  %xmm0,(%r12)
  add    $0x4,%rbx
  add    (%rsp),%rbp
  cmp    0x10(%rsp),%rbx
  jne    L120
L263:
  movslq 0x1c(%rsp),%rax
  mov    0x28(%rsp),%rcx
  addl   $0x1,(%rcx,%rax,4)
  addl   $0x1,0x20(%rsp)
  mov    0x20(%rsp),%edi
  mov    0x38(%rsp),%eax
  add    0x3c(%rsp),%eax
  cmp    %eax,%edi
  je     L188
L126:
  cmpl   $0x0,0x18(%rsp)
  jle    L123
  movslq 0x20(%rsp),%rax
  mov    0x50(%rsp),%rcx
  lea    (%rcx,%rax,4),%rdx
  mov    %r14,%rax
  mov    0x48(%rsp),%rsi
L178:
  mov    (%rdx),%ecx
  mov    %ecx,(%rax)
  add    (%rsp),%rdx
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L178
  cmpl   $0x0,0x24(%rsp)
  jle    L256
L244:
  mov    0x24(%rsp),%r13d
  mov    $0x0,%ebx
  mov    $0xffffffff,%ebp
  mov    0x30(%rsp),%r15
  jmp    L227
L188:
  addl   $0x1,0x58(%rsp)
  mov    0x58(%rsp),%eax
  mov    0x38(%rsp),%edi
  add    %edi,0x3c(%rsp)
  cmp    %eax,0x5c(%rsp)
  jle    L233
L100:
  mov    0x3c(%rsp),%eax
  mov    %eax,0x20(%rsp)
  cmpl   $0x0,0x38(%rsp)
  jg     L126
  jmp    L188
L233:
  mov    $0x0,%r12d
  cmpl   $0x0,0x24(%rsp)
  jle    L192
L169:
  mov    0x30(%rsp),%rbx
  mov    0x18(%rsp),%eax
  lea    -0x1(%rax),%eax
  lea    0x4(,%rax,4),%rbp
  mov    $0x0,%r15d
  mov    $0x0,%r12d
  mov    $0x1,%r13d
  mov    %r14,(%rsp)
  mov    0x40(%rsp),%r14
  jmp    L214
L281:
  add    $0x4,%rax
  cmp    %rbp,%rax
  je     L112
L182:
  mov    %rax,%rdx
  add    (%rbx),%rdx
  cvttss2si (%rsi,%rax,1),%ecx
  cmp    %ecx,(%rdx)
  je     L281
  mov    %ecx,(%rdx)
  mov    %r13d,%r12d
  jmp    L281
L112:
  mov    (%r14,%r15,8),%rdi
  call   <free@plt>
  add    $0x1,%r15
  add    $0x8,%rbx
  cmp    %r15d,0x24(%rsp)
  jle    L68
L214:
  cmpl   $0x0,0x18(%rsp)
  jle    L112
  mov    (%r14,%r15,8),%rsi
  mov    $0x0,%eax
  jmp    L182
L68:
  mov    (%rsp),%r14
L192:
  mov    0x40(%rsp),%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r12d,%eax
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L193:
  mov    $0x0,%r12d
  cmpl   $0x0,0x5c(%rsp)
  jg     L22
  jmp    L192
L123:
  cmpl   $0x0,0x24(%rsp)
  jg     L244
  jmp    L263
```

assistant: ```c
int kmeans_it(int *image, int width, int height, int depth, int k, int **clusters, int mean_colors, int *ret) {
  int i = 0, j = 0, d = 0, ki = 0;
  int min_dist = -1, temp_dist = -1;
  int cluster = 0;
  int *pixel_it = malloc(depth * sizeof(int));
  int *pix_count = (int *)calloc(k, sizeof(int));
  int changed = 0;
  float **new_clusters = (float **)malloc(k * sizeof(float *));
  for (i = 0; i < k; i++) {
    new_clusters[i] = calloc(depth, sizeof(float));
  }
  for (i = 0; i < width; i++) {
    for (j = 0; j < height; j++) {
      int l = 0;
      min_dist = -1;
      for (l = 0; l < depth; l++) {
        pixel_it[l] = image[((height) * (i) + (j) + (width) * (height) * (l))];
      }
      for (ki = 0; ki < k; ki++) {
        temp_dist = sqd_distance(pixel_it, clusters[ki], depth);
        if (min_dist < 0 || temp_dist < min_dist) {
          min_dist = temp_dist;
          cluster = ki;
        }
      }
      for (l = 0; l < depth; l++) {
        ret[((height) * (i) + (j) + (width) * (height) * (l))] = (mean_colors) ? clusters[cluster][l] : clusters[cluster][l];
        new_clusters[cluster][l] = mean_it(new_clusters[cluster][l], pix_count[cluster], pixel_it[l]);
      }
      pix_count[cluster]++;
    }
  }
  for (i = 0; i < k; i++) {
    for (d = 0; d < depth; d++) {
      if (clusters[i][d] != (int)new_clusters[i][d]) {
        clusters[i][d] = (int)(new_clusters[i][d]);
        changed = 1;
      }
    }
    free(new_clusters[i]);
  }
  free(new_clusters);
  free(pixel_it);
  return changed;
}
```