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

```asm
<kmeans_enhanced>:
  endbr64
  push   %r15
  mov    %rsi,%r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  mov    %rcx,%rbx
  sub    $0x38,%rsp
  mov    (%rcx),%ecx
  mov    (%rdx),%edx
  mov    0x70(%rsp),%rsi
  mov    0x78(%rsp),%rbp
  mov    %r8,0x10(%rsp)
  mov    (%r8),%r8d
  mov    %rdi,0x20(%rsp)
  mov    %rsi,0x28(%rsp)
  mov    (%r15),%esi
  mov    %r9,0x18(%rsp)
  call   <clusters_init@plt>
  mov    %rax,%r13
  mov    0x18(%rsp),%rax
  mov    (%rax),%esi
  test   %esi,%esi
  jle    L106
  xor    %r14d,%r14d
  mov    %r12,(%rsp)
  mov    %rbx,0x8(%rsp)
  mov    %r14d,%r12d
  mov    0x20(%rsp),%rbx
  mov    %rbp,%r14
  mov    %r13,%rbp
  mov    0x28(%rsp),%r13
  jmp    L52
  nopl   0x0(%rax,%rax,1)
L62:
  test   %eax,%eax
  je     L38
L52:
  sub    $0x8,%rsp
  mov    (%r15),%esi
  mov    %rbx,%rdi
  mov    %rbp,%r9
  push   %r12
  add    $0x1,%r12d
  push   %r14
  mov    0x0(%r13),%eax
  push   %rax
  mov    0x30(%rsp),%rax
  mov    (%rax),%r8d
  mov    0x28(%rsp),%rax
  mov    (%rax),%ecx
  mov    0x20(%rsp),%rax
  mov    (%rax),%edx
  call   <kmeans_enhanced_it@plt>
  mov    0x38(%rsp),%rdi
  add    $0x20,%rsp
  cmp    %r12d,(%rdi)
  jg     L62
L38:
  mov    (%rsp),%r12
  mov    0x8(%rsp),%rbx
  mov    %rbp,%r13
  mov    %r14,%rbp
L106:
  mov    (%r15),%edx
  test   %edx,%edx
  jle    L27
  mov    (%r12),%esi
  xor    %r8d,%r8d
  nopl   0x0(%rax,%rax,1)
L10:
  mov    %esi,%r10d
  xor    %edi,%edi
  test   %esi,%esi
  jle    L5
  nopl   0x0(%rax)
L75:
  mov    %esi,%eax
  mov    (%rbx),%ecx
  imul   %r8d,%eax
  add    %edi,%eax
  cltq
  movslq 0x0(%rbp,%rax,4),%rax
  test   %ecx,%ecx
  jle    L9
  mov    0x0(%r13,%rax,8),%r9
  xor    %ecx,%ecx
  jmp    L63
  xchg   %ax,%ax
L85:
  mov    (%r15),%edx
L63:
  imul   %r10d,%edx
  mov    %r8d,%eax
  mov    (%r9,%rcx,4),%esi
  imul   %r10d,%eax
  imul   %ecx,%edx
  add    $0x1,%rcx
  add    %edi,%eax
  add    %edx,%eax
  cltq
  mov    %esi,0x0(%rbp,%rax,4)
  cmp    %ecx,(%rbx)
  mov    (%r12),%r10d
  jg     L85
  mov    (%r15),%edx
  mov    %r10d,%esi
L9:
  add    $0x1,%edi
  cmp    %esi,%edi
  jl     L75
L5:
  add    $0x1,%r8d
  cmp    %edx,%r8d
  jl     L10
L27:
  mov    0x10(%rsp),%rax
  mov    %r13,%rdi
  mov    (%rax),%esi
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1080 <clusters_destroy@plt>
```

assistant: ```c
void kmeans_enhanced(int *image, int *width, int *height, int *depth, int *k, int *maxit, int *mean_colors, int *ret) {
  int **clusters;
  int i = 0, j = 0, d = 0;
  int changed = 1;
  clusters = clusters_init(image, *width, *height, *depth, *k);
  i = 0;
  while (i < *maxit && changed) {
    changed = kmeans_enhanced_it(image, *width, *height, *depth, *k, clusters, *mean_colors, ret, i);
    i++;
  }
  for (i = 0; i < *width; i++) {
    for (j = 0; j < *height; j++) {
      int cluster = ret[((*height) * (i) + (j) + (*width) * (*height) * (0))];
      for (d = 0; d < *depth; d++) {
        ret[((*height) * (i) + (j) + (*width) * (*height) * (d))] = (*mean_colors) ? clusters[cluster][d] : clusters[cluster][d];
      }
    }
  }
  clusters = clusters_destroy(clusters, *k);
}
```