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

```asm
<transpose>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  lea    0x0(,%r12,8),%ebp
  push   %rbx
  mov    %rdi,%rbx
  lea    (%r12,%r12,1),%edi
  sub    $0x38,%rsp
  call   <allocate@plt>
  movslq %eax,%r13
  test   %r12d,%r12d
  jle    L37
  lea    -0x1(%r12),%eax
  mov    %rbx,%rcx
  lea    0x8(%rbx,%rax,8),%rsi
  jmp    L143
  cs nopw 0x0(%rax,%rax,1)
L96:
  add    $0x8,%rcx
  cmp    %rcx,%rsi
  je     L2
L143:
  mov    (%rcx),%rdx
  test   %rdx,%rdx
  je     L96
  movswq (%rdx),%rax
  test   %ax,%ax
  js     L96
  nopw   0x0(%rax,%rax,1)
L130:
  add    $0x2,%rdx
  addw   $0x1,0x0(%r13,%rax,2)
  movswq (%rdx),%rax
  test   %ax,%ax
  jns    L130
  add    $0x8,%rcx
  cmp    %rcx,%rsi
  jne    L143
L2:
  mov    %ebp,%edi
  xor    %eax,%eax
  lea    0x0(%r13,%r12,2),%r15
  call   <allocate@plt>
  mov    %ebp,%edi
  cltq
  mov    %rax,0x20(%rsp)
  xor    %eax,%eax
  call   <allocate@plt>
  mov    %r13,%rdx
  movslq %eax,%r14
  mov    0x20(%rsp),%rax
  mov    %r14,%rdi
  mov    %r14,0x28(%rsp)
  sub    %rax,%rdi
  mov    %rax,%rbp
  mov    %rdi,0x18(%rsp)
  nopl   0x0(%rax)
L51:
  movswl (%rdx),%eax
  mov    %eax,0xc(%rsp)
  test   %eax,%eax
  jle    L131
  lea    0x2(%rax,%rax,1),%edi
  xor    %eax,%eax
  mov    %rdx,0x10(%rsp)
  call   <allocate@plt>
  mov    0xc(%rsp),%ecx
  mov    0x18(%rsp),%rdi
  mov    $0xffffffff,%edx
  cltq
  movswq %cx,%rcx
  mov    %rax,0x0(%rbp)
  mov    %rax,(%rdi,%rbp,1)
  mov    %dx,(%rax,%rcx,2)
  mov    0x10(%rsp),%rdx
L131:
  add    $0x2,%rdx
  add    $0x8,%rbp
  cmp    %rdx,%r15
  jne    L51
  mov    %r13,%rdi
  call   <free@plt>
  xor    %edi,%edi
  jmp    L78
  nopl   0x0(%rax)
L35:
  add    $0x1,%rdi
  cmp    %r12,%rdi
  je     L75
L78:
  mov    (%rbx,%rdi,8),%rdx
  test   %rdx,%rdx
  je     L35
  movswq (%rdx),%rax
  test   %ax,%ax
  js     L35
  mov    %edi,%r9d
  xchg   %ax,%ax
L10:
  lea    (%r14,%rax,8),%rcx
  add    $0x2,%rdx
  mov    (%rcx),%rax
  lea    0x2(%rax),%rsi
  mov    %rsi,(%rcx)
  mov    %r9w,(%rax)
  movswq (%rdx),%rax
  test   %ax,%ax
  jns    L10
  add    $0x1,%rdi
  cmp    %r12,%rdi
  jne    L78
L75:
  mov    0x28(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L37:
  mov    %ebp,%edi
  xor    %eax,%eax
  call   <allocate@plt>
  mov    %ebp,%edi
  cltq
  mov    %rax,0x20(%rsp)
  xor    %eax,%eax
  call   <allocate@plt>
  mov    %r13,%rdi
  cltq
  mov    %rax,0x28(%rsp)
  call   <free@plt>
  jmp    L75
```

assistant: ```c
short **transpose(short int **R, int n) {
  register short **new_R;
  register short **temp_R;
  register short *nedges;
  register short *sp;
  register int i;
  register int k;
  nedges = ((short *)allocate((unsigned)((n) * sizeof(short))));
  for (i = 0; i < n; i++) {
    sp = R[i];
    if (sp) {
      while (*sp >= 0)
        nedges[*sp++]++;
    }
  }
  new_R = ((short **)allocate((unsigned)((n) * sizeof(short *))));
  temp_R = ((short **)allocate((unsigned)((n) * sizeof(short *))));
  for (i = 0; i < n; i++) {
    k = nedges[i];
    if (k > 0) {
      sp = ((short *)allocate((unsigned)((k + 1) * sizeof(short))));
      new_R[i] = sp;
      temp_R[i] = sp;
      sp[k] = -1;
    }
  }
  (free((char *)(nedges)));
  for (i = 0; i < n; i++) {
    sp = R[i];
    if (sp) {
      while (*sp >= 0)
        *temp_R[*sp++]++ = i;
    }
  }
  (free((char *)(temp_R)));
  return (new_R);
}
```