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

```asm
<svd_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    %rcx,-0x48(%rbp)
  mov    %r8,-0x50(%rbp)
  mov    -0x40(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x3c(%rbp),%eax
  cltq
  imul   %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x40(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x40(%rbp),%eax
  cltq
  imul   %rdx,%rax
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x40(%rbp),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x40(%rbp),%eax
  cltq
  shl    $0x2,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x28(%rbp)
  jmp    L56
L10:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x10(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x28(%rbp)
L56:
  mov    -0x28(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L10
  movl   $0x0,-0x28(%rbp)
  jmp    L8
L93:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x28(%rbp)
L8:
  mov    -0x3c(%rbp),%eax
  imul   -0x40(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jl     L93
  movl   $0x0,-0x28(%rbp)
  jmp    L104
L15:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x28(%rbp)
L104:
  mov    -0x40(%rbp),%eax
  imul   %eax,%eax
  cmp    %eax,-0x28(%rbp)
  jl     L15
  mov    -0x8(%rbp),%rdx
  mov    -0x40(%rbp),%ecx
  mov    -0x50(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sort1d@plt>
  movl   $0x0,-0x28(%rbp)
  jmp    L81
L62:
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x10(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  movl   $0x0,-0x24(%rbp)
  jmp    L46
L66:
  mov    -0x24(%rbp),%eax
  imul   -0x40(%rbp),%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x20(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  imul   -0x40(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%eax
  add    %ecx,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x24(%rbp)
L46:
  mov    -0x24(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L66
  movl   $0x0,-0x24(%rbp)
  jmp    L109
L83:
  mov    -0x24(%rbp),%eax
  imul   -0x40(%rbp),%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  imul   -0x40(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x28(%rbp),%eax
  add    %ecx,%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  movss  (%rdx),%xmm0
  movss  %xmm0,(%rax)
  addl   $0x1,-0x24(%rbp)
L109:
  mov    -0x24(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L83
  addl   $0x1,-0x28(%rbp)
L81:
  mov    -0x28(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L62
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

assistant: ```c
void svd_sort(float *U, int M, int N, float *V, float *q) {
  int i, j;
  float *UT, *VT, *qq;
  int *pos;
  UT = (float *)malloc(sizeof(float) * N * M);
  VT = (float *)malloc(sizeof(float) * N * N);
  qq = (float *)malloc(sizeof(float) * N);
  pos = (int *)malloc(sizeof(int) * N);
  for (i = 0; i < N; ++i) {
    qq[i] = q[i];
  }
  for (i = 0; i < M * N; ++i) {
    UT[i] = U[i];
  }
  for (i = 0; i < N * N; ++i) {
    VT[i] = V[i];
  }
  sort1d(q, N, pos);
  for (i = 0; i < N; ++i) {
    q[i] = qq[pos[i]];
    for (j = 0; j < M; ++j) {
      U[j * N + i] = UT[j * N + pos[i]];
    }
    for (j = 0; j < N; ++j) {
      V[j * N + i] = VT[j * N + pos[i]];
    }
  }
  free(UT);
  free(VT);
  free(qq);
  free(pos);
}
```