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

```asm
<convert_ij2slap_w>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x3c(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %r9,-0x50(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <find_max@plt>
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x30(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <find_max@plt>
  add    $0x1,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x10(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jbe    L52
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x18(%rbp)
L52:
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x48(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x18(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x3c(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    -0x50(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x3c(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    0x10(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  movl   $0x0,-0x14(%rbp)
  jmp    L54
L24:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
  addl   $0x1,-0x14(%rbp)
L54:
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x14(%rbp)
  jb     L24
  mov    -0x18(%rbp),%eax
  lea    0x0(,%rax,4),%edx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  movl   $0x0,(%rax)
  movl   $0x0,-0x14(%rbp)
  jmp    L9
L42:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    $0x1,%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rsi
  mov    -0x28(%rbp),%rax
  add    %rsi,%rax
  mov    (%rax),%eax
  add    $0x1,%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x14(%rbp)
L9:
  mov    -0x14(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jb     L42
  movl   $0x1,-0x14(%rbp)
  jmp    L8
L84:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%ecx
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rsi
  mov    -0x14(%rbp),%eax
  shl    $0x2,%rax
  add    %rsi,%rax
  add    %ecx,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x14(%rbp)
L8:
  mov    -0x14(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jbe    L84
  movl   $0x0,-0x14(%rbp)
  jmp    L16
L47:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  shl    $0x2,%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x50(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0xc(%rbp),%eax
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    0x10(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0xc(%rbp),%eax
  shl    $0x3,%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  add    $0x1,%edx
  mov    %edx,(%rax)
  addl   $0x1,-0x14(%rbp)
L16:
  mov    -0x14(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jb     L47
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%eax
  leave
  ret
```

assistant: ```c
int convert_ij2slap_w(unsigned int *I, unsigned int *J, double *W, unsigned int K, unsigned int **r_slap, unsigned int **J_slap, double **w_slap) {
  unsigned int tmp, max;
  unsigned int N;
  unsigned int i, pos;
  unsigned int *p;
  max = find_max(I, K) + 1;
  tmp = find_max(J, K) + 1;
  if (tmp > max) {
    max = tmp;
  }
  *r_slap = malloc((max + 1) * sizeof(unsigned int));
  p = malloc(max * sizeof(unsigned int));
  *J_slap = malloc(K * sizeof(unsigned int));
  *w_slap = malloc(K * sizeof(double));
  memset(*r_slap, 0, (max + 1) * sizeof(unsigned int));
  for (i = 0; i < max + 1; i++)
    (*r_slap)[i] = 0;
  memset(p, 0, max * sizeof(unsigned int));
  (*r_slap)[0] = 0;
  for (i = 0; i < K; i++) {
    (*r_slap)[I[i] + 1] += 1;
  }
  for (i = 1; i <= max; i++) {
    (*r_slap)[i] += (*r_slap)[i - 1];
  }
  for (i = 0; i < K; i++) {
    pos = (*r_slap)[I[i]] + p[I[i]];
    (*J_slap)[pos] = J[i];
    (*w_slap)[pos] = W[i];
    p[I[i]] += 1;
  }
  free(p);
  return max;
}
```