user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<kmeans_it>:
  endbr64
  push   %r15
  movslq %r8d,%r15
  push   %r14
  push   %r13
  mov    %r9,%r13
  push   %r12
  movslq %ecx,%r12
  push   %rbp
  push   %rbx
  sub    $0x88,%rsp
  mov    %rdi,0x60(%rsp)
  lea    0x0(,%r12,4),%rdi
  mov    %edx,0x70(%rsp)
  mov    %ecx,0x40(%rsp)
  mov    %esi,0x74(%rsp)
  mov    %r15d,0x68(%rsp)
  mov    %r12,0x78(%rsp)
  call   <malloc@plt>
  mov    $0x4,%esi
  mov    %r15,%rdi
  mov    %r15,0x18(%rsp)
  mov    %rax,%r14
  call   <calloc@plt>
  lea    0x0(,%r15,8),%rdi
  mov    %rax,0x48(%rsp)
  call   <malloc@plt>
  mov    %rax,0x50(%rsp)
  test   %r15d,%r15d
  jle    L51
  mov    %rax,%rcx
  mov    %rax,%rbp
  mov    %r15d,%eax
  lea    (%rcx,%rax,8),%rbx
  nopl   0x0(%rax,%rax,1)
L18:
  mov    $0x4,%esi
  mov    %r12,%rdi
  add    $0x8,%rbp
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  cmp    %rbp,%rbx
  jne    L18
  mov    0x74(%rsp),%esi
  test   %esi,%esi
  jle    L229
L56:
  mov    0x70(%rsp),%ecx
  mov    0x74(%rsp),%ebx
  movl   $0x0,0x24(%rsp)
  mov    0x40(%rsp),%eax
  movl   $0x0,0x6c(%rsp)
  imul   %ecx,%ebx
  mov    %ecx,0x44(%rsp)
  sub    $0x1,%eax
  lea    0x4(,%rax,4),%rax
  movslq %ebx,%rbx
  mov    %rax,0x10(%rsp)
  add    %r14,%rax
  shl    $0x2,%rbx
  mov    %rax,0x58(%rsp)
  mov    %rbx,0x8(%rsp)
  nopl   (%rax)
L5:
  mov    0x70(%rsp),%eax
  test   %eax,%eax
  jle    L183
  mov    0x44(%rsp),%ecx
  sub    %eax,%ecx
  mov    %ecx,0x28(%rsp)
  cs nopw 0x0(%rax,%rax,1)
L1:
  mov    0x40(%rsp),%r8d
  test   %r8d,%r8d
  jle    L246
  mov    0x60(%rsp),%rax
  movslq 0x28(%rsp),%rsi
  mov    0x58(%rsp),%rdi
  mov    0x8(%rsp),%rbx
  lea    (%rax,%rsi,4),%rdx
  mov    %r14,%rax
  nopl   0x0(%rax)
L151:
  mov    (%rdx),%ecx
  add    $0x4,%rax
  add    %rbx,%rdx
  mov    %ecx,-0x4(%rax)
  cmp    %rax,%rdi
  jne    L151
  mov    0x68(%rsp),%eax
  test   %eax,%eax
  jle    L192
L132:
  mov    0x40(%rsp),%r12d
  mov    0x0(%r13),%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  mov    $0x1,%r15d
  mov    %r13,%rbp
  mov    %r12d,%edx
  mov    %r15,%r13
  mov    %r12d,%r15d
  call   <sqd_distance@plt>
  movl   $0x0,0x24(%rsp)
  mov    %eax,%ebx
  jmp    L226
  xchg   %ax,%ax
L210:
  cmp    %eax,%ebx
  jg     L76
L168:
  add    $0x1,%r13
L226:
  mov    %r13d,%r12d
  cmp    %r13,0x18(%rsp)
  je     L122
  mov    0x0(%rbp,%r13,8),%rsi
  xor    %eax,%eax
  mov    %r15d,%edx
  mov    %r14,%rdi
  call   <sqd_distance@plt>
  test   %ebx,%ebx
  jns    L210
L76:
  mov    %r12d,0x24(%rsp)
  mov    %eax,%ebx
  jmp    L168
  nopl   0x0(%rax)
L122:
  movslq 0x24(%rsp),%rax
  mov    0x48(%rsp),%rcx
  mov    %rbp,%r13
  mov    0x40(%rsp),%r9d
  movslq 0x28(%rsp),%rsi
  lea    (%rcx,%rax,4),%rcx
  mov    (%rcx),%edi
  mov    %rcx,0x30(%rsp)
  mov    %edi,0x2c(%rsp)
  test   %r9d,%r9d
  jle    L144
L234:
  mov    0x50(%rsp),%rdx
  lea    0x0(%r13,%rax,8),%r9
  mov    %r13,0x38(%rsp)
  xor    %r15d,%r15d
  mov    %r14,%r13
  mov    %r9,%r14
  mov    (%rdx,%rax,8),%rbp
  mov    0xc8(%rsp),%rax
  mov    %rbp,%rbx
  mov    0x2c(%rsp),%ebp
  lea    (%rax,%rsi,4),%r12
  cs nopw 0x0(%rax,%rax,1)
L154:
  mov    (%r14),%rax
  mov    0x0(%r13,%r15,1),%esi
  pxor   %xmm0,%xmm0
  mov    %ebp,%edi
  cvtss2sd (%rbx,%r15,1),%xmm0
  mov    (%rax,%r15,1),%eax
  mov    %eax,(%r12)
  mov    $0x1,%eax
  call   <mean_it@plt>
  pxor   %xmm0,%xmm0
  add    0x8(%rsp),%r12
  cvtsi2ss %eax,%xmm0
  movss  %xmm0,(%rbx,%r15,1)
  add    $0x4,%r15
  cmp    %r15,0x10(%rsp)
  jne    L154
  mov    %r13,%r14
  mov    0x38(%rsp),%r13
L144:
  mov    0x2c(%rsp),%ebp
  mov    0x30(%rsp),%rax
  addl   $0x1,0x28(%rsp)
  add    $0x1,%ebp
  mov    %ebp,(%rax)
  mov    0x28(%rsp),%eax
  cmp    0x44(%rsp),%eax
  jne    L1
L183:
  addl   $0x1,0x6c(%rsp)
  mov    0x70(%rsp),%edi
  mov    0x6c(%rsp),%eax
  add    %edi,0x44(%rsp)
  cmp    %eax,0x74(%rsp)
  jg     L5
  mov    0x68(%rsp),%edi
  test   %edi,%edi
  jle    L123
L229:
  xor    %ebx,%ebx
  xor    %r12d,%r12d
  mov    %r14,0x8(%rsp)
  mov    0x50(%rsp),%rbp
  mov    %rbx,%r14
  mov    0x40(%rsp),%r15d
  mov    %r12d,%ebx
  mov    0x78(%rsp),%r12
  nopl   0x0(%rax,%rax,1)
L177:
  mov    0x0(%rbp,%r14,8),%rdi
  test   %r15d,%r15d
  jle    L134
  mov    0x0(%r13,%r14,8),%rcx
  xor    %eax,%eax
  nopl   0x0(%rax)
L17:
  cvttss2si (%rdi,%rax,4),%edx
  cmp    %edx,(%rcx,%rax,4)
  je     L207
  mov    %edx,(%rcx,%rax,4)
  mov    $0x1,%ebx
L207:
  add    $0x1,%rax
  cmp    %rax,%r12
  jne    L17
L134:
  call   <free@plt>
  add    $0x1,%r14
  cmp    %r14d,0x68(%rsp)
  jg     L177
  mov    0x8(%rsp),%r14
  mov    %ebx,%r12d
L155:
  mov    0x50(%rsp),%rdi
  call   <free@plt>
  mov    %r14,%rdi
  call   <free@plt>
  add    $0x88,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L246:
  mov    0x68(%rsp),%edx
  test   %edx,%edx
  jg     L132
  movslq 0x24(%rsp),%rax
  mov    0x48(%rsp),%rcx
  lea    (%rcx,%rax,4),%rax
  mov    %rax,0x30(%rsp)
  mov    (%rax),%eax
  mov    %eax,0x2c(%rsp)
  jmp    L144
  nopw   0x0(%rax,%rax,1)
L192:
  mov    0x48(%rsp),%rcx
  movslq 0x24(%rsp),%rax
  lea    (%rcx,%rax,4),%rdi
  mov    (%rdi),%ecx
  mov    %rdi,0x30(%rsp)
  mov    %ecx,0x2c(%rsp)
  jmp    L234
L51:
  mov    0x74(%rsp),%ecx
  test   %ecx,%ecx
  jg     L56
L123:
  xor    %r12d,%r12d
  jmp    L155
```

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;
}
```