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

```asm
<convert_ij2slap_w>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rsi,%r12
  mov    %ecx,%esi
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x28,%rsp
  mov    %r8,(%rsp)
  mov    %r9,0x8(%rsp)
  call   <find_max@plt>
  mov    %r13d,%esi
  mov    %r12,%rdi
  mov    %eax,%ebp
  call   <find_max@plt>
  add    $0x1,%ebp
  add    $0x1,%eax
  cmp    %eax,%ebp
  cmovae %ebp,%eax
  lea    0x1(%rax),%r11d
  mov    %eax,%r15d
  lea    0x0(,%r11,4),%edx
  mov    %r11d,0x1c(%rsp)
  mov    %edx,%edi
  mov    %edx,0x14(%rsp)
  call   <malloc@plt>
  mov    (%rsp),%rcx
  mov    0x14(%rsp),%edx
  mov    %rax,(%rcx)
  lea    -0x4(%rdx),%r9d
  mov    %r9d,%edi
  mov    %r9d,0x14(%rsp)
  mov    %edx,0x18(%rsp)
  call   <malloc@plt>
  lea    0x0(,%r13,4),%edi
  mov    %rax,%rbp
  call   <malloc@plt>
  mov    0x8(%rsp),%rdx
  lea    0x0(,%r13,8),%edi
  mov    %rax,(%rdx)
  call   <malloc@plt>
  mov    0x60(%rsp),%rdx
  mov    (%rsp),%rcx
  xor    %esi,%esi
  mov    %rax,(%rdx)
  mov    (%rcx),%rdi
  mov    0x18(%rsp),%edx
  call   <memset@plt>
  mov    0x1c(%rsp),%r11d
  mov    0x14(%rsp),%r9d
  test   %r11d,%r11d
  je     L12
  mov    (%rsp),%rcx
  mov    %r11d,%edx
  xor    %esi,%esi
  shl    $0x2,%rdx
  mov    (%rcx),%rdi
  call   <memset@plt>
  mov    0x14(%rsp),%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    (%rsp),%rcx
  mov    (%rcx),%rdx
  movl   $0x0,(%rdx)
  test   %r13d,%r13d
  je     L79
L89:
  lea    -0x1(%r13),%esi
  mov    %rbx,%rax
  lea    0x4(%rbx,%rsi,4),%rdi
  nopl   0x0(%rax)
L81:
  mov    (%rax),%esi
  add    $0x4,%rax
  add    $0x1,%esi
  addl   $0x1,(%rdx,%rsi,4)
  cmp    %rdi,%rax
  jne    L81
  test   %r15d,%r15d
  je     L98
  mov    (%rdx),%eax
L53:
  add    %eax,0x4(%rdx)
  cmp    $0x1,%r15d
  jbe    L41
L67:
  mov    $0x2,%eax
  nopw   0x0(%rax,%rax,1)
L93:
  mov    %eax,%esi
  lea    -0x1(%rax),%edi
  add    $0x1,%eax
  mov    (%rdx,%rdi,4),%edi
  add    %edi,(%rdx,%rsi,4)
  cmp    %eax,%r15d
  jae    L93
L41:
  test   %r13d,%r13d
  je     L36
L98:
  mov    0x8(%rsp),%rax
  mov    (%rax),%r9
  mov    0x60(%rsp),%rax
  mov    (%rax),%r11
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L66:
  mov    (%rbx,%rax,4),%edi
  movsd  (%r14,%rax,8),%xmm0
  mov    0x0(%rbp,%rdi,4),%esi
  add    (%rdx,%rdi,4),%esi
  mov    (%r12,%rax,4),%edi
  mov    %edi,(%r9,%rsi,4)
  movsd  %xmm0,(%r11,%rsi,8)
  mov    (%rbx,%rax,4),%esi
  add    $0x1,%rax
  addl   $0x1,0x0(%rbp,%rsi,4)
  cmp    %eax,%r13d
  ja     L66
L36:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x28,%rsp
  mov    %r15d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L12:
  mov    %r9d,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    (%rsp),%rax
  mov    (%rax),%rdx
  movl   $0x0,(%rdx)
  test   %r13d,%r13d
  jne    L89
  jmp    L67
  nopl   0x0(%rax,%rax,1)
L79:
  xor    %eax,%eax
  test   %r15d,%r15d
  jne    L53
  jmp    L36
```

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