user: 请将以下的汇编代码转换成C语言代码：

```asm
<compute_centroids_uint8>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  mov    %ecx,-0x48(%rbp)
  mov    %r8d,-0x4c(%rbp)
  mov    -0x4c(%rbp),%eax
  imul   -0x48(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x4c(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x4c(%rbp),%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x2c(%rbp)
  jmp    L82
L88:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x1c(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L74
L33:
  mov    -0x1c(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x2c(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%eax
  add    %ecx,%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    %eax,%esi
  mov    -0x1c(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%eax
  add    %ecx,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x10(%rbp),%rax
  add    %rcx,%rax
  add    %esi,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x28(%rbp)
L74:
  mov    -0x28(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  jl     L33
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  add    $0x1,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x2c(%rbp)
L82:
  mov    -0x2c(%rbp),%eax
  cmp    -0x44(%rbp),%eax
  jl     L88
  movl   $0x0,-0x24(%rbp)
  jmp    L14
L68:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L42
  movl   $0x0,-0x20(%rbp)
  jmp    L57
L73:
  mov    -0x24(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%esi
  cltd
  idiv   %esi
  mov    %eax,%ecx
  mov    -0x24(%rbp),%eax
  imul   -0x48(%rbp),%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movslq %ecx,%rax
  mov    %rax,(%rdx)
  addl   $0x1,-0x20(%rbp)
L57:
  mov    -0x20(%rbp),%eax
  cmp    -0x48(%rbp),%eax
  jl     L73
L42:
  addl   $0x1,-0x24(%rbp)
L14:
  mov    -0x24(%rbp),%eax
  cmp    -0x4c(%rbp),%eax
  jl     L68
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  leave
  ret
```

assistant: ```c
uint8_t *compute_centroids_uint8(uint8_t *space, int *cluster_map, int points, int dim, int k) {
  uint8_t *centroids = malloc(k * dim * sizeof(uint8_t));
  uint32_t *sums = calloc(k * dim, sizeof(uint32_t));
  int *cluster_points = calloc(k, sizeof(int));
  for (int i = 0; i < points; ++i) {
    int n = cluster_map[i];
    for (int j = 0; j < dim; ++j)
      sums[n * dim + j] = sums[n * dim + j] + (uint32_t)space[i * dim + j];
    ++cluster_points[n];
  }
  for (int n = 0; n < k; ++n) {
    if (cluster_points[n]) {
      for (int i = 0; i < dim; ++i)
        centroids[n * dim + i] = (uint8_t)(sums[n * dim + i] / cluster_points[n]);
    }
  }
  free(sums);
  free(cluster_points);
  return centroids;
}
```