user: Please show me the C implementation that matches the assembly code listed below:

```asm
<SortArray>:
  endbr64
  push   %r15
  mov    %rdx,%r15
  push   %r14
  movslq %esi,%r14
  mov    $0x4,%esi
  push   %r13
  mov    %rcx,%r13
  push   %r12
  mov    %rdi,%r12
  lea    0x1(%r8),%edi
  push   %rbp
  mov    %r8d,%ebp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,0x8(%rsp)
  call   <calloc@plt>
  test   %ebp,%ebp
  mov    0x8(%rsp),%edi
  mov    %rax,%rbx
  js     L96
  lea    0x4(%r13),%rdx
  sub    %rdx,%rax
  cmp    $0x8,%rax
  jbe    L105
  cmp    $0x2,%ebp
  jbe    L105
  mov    %edi,%edx
  mov    %r13,%rcx
  mov    %rbx,%rax
  shr    $0x2,%edx
  sub    %rbx,%rcx
  shl    $0x4,%rdx
  add    %rbx,%rdx
  nopl   0x0(%rax)
L11:
  movdqu (%rax,%rcx,1),%xmm0
  add    $0x10,%rax
  movups %xmm0,-0x10(%rax)
  cmp    %rdx,%rax
  jne    L11
  mov    %edi,%eax
  movslq %ebp,%rcx
  and    $0xfffffffc,%eax
  and    $0x3,%edi
  je     L130
  movslq %eax,%rsi
  mov    0x0(%r13,%rsi,4),%edi
  lea    0x0(,%rsi,4),%rdx
  mov    %edi,(%rbx,%rsi,4)
  lea    0x1(%rax),%esi
  cmp    %esi,%ebp
  jl     L130
  mov    0x4(%r13,%rdx,1),%esi
  add    $0x2,%eax
  mov    %esi,0x4(%rbx,%rdx,1)
  cmp    %eax,%ebp
  jl     L130
  mov    0x8(%r13,%rdx,1),%eax
  mov    %eax,0x8(%rbx,%rdx,1)
L130:
  xor    %edi,%edi
  cmp    %r14d,0x0(%r13,%rcx,4)
  sete   %dil
  call   <assert@plt>
  mov    $0x4,%esi
  mov    %r14d,%edi
  call   <calloc@plt>
  mov    %rax,%r8
  test   %r14d,%r14d
  jle    L50
  mov    (%r12),%rdi
  xor    %eax,%eax
  nopl   0x0(%rax)
L90:
  movslq (%r15,%rax,4),%rdx
  lea    0x0(%r13,%rdx,4),%rcx
  movslq (%rcx),%rdx
  lea    0x1(%rdx),%esi
  mov    %esi,(%rcx)
  mov    (%rdi,%rax,4),%ecx
  add    $0x1,%rax
  mov    %ecx,(%r8,%rdx,4)
  cmp    %r14,%rax
  jne    L90
L92:
  mov    %r8,0x8(%rsp)
  call   <free@plt>
  mov    0x8(%rsp),%r8
L66:
  mov    %r8,(%r12)
  mov    %r13,%rdi
  mov    %ebp,%esi
  xor    %r12d,%r12d
  sub    %rbx,%r13
  call   <EndIndex2BeginIndex@plt>
  test   %ebp,%ebp
  js     L78
  nopl   0x0(%rax,%rax,1)
L140:
  mov    (%rbx),%eax
  xor    %edi,%edi
  cmp    %eax,0x0(%r13,%rbx,1)
  sete   %dil
  add    $0x1,%r12d
  add    $0x4,%rbx
  call   <assert@plt>
  cmp    %r12d,%ebp
  jge    L140
L78:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L50:
  mov    (%r12),%rdi
  test   %rdi,%rdi
  je     L66
  jmp    L92
  nopl   0x0(%rax,%rax,1)
L105:
  movslq %ebp,%rcx
  mov    %r13,%rsi
  mov    %rbx,%rax
  lea    0x4(%rbx,%rcx,4),%rdi
  sub    %rbx,%rsi
  nopl   0x0(%rax)
L131:
  mov    (%rsi,%rax,1),%edx
  add    $0x4,%rax
  mov    %edx,-0x4(%rax)
  cmp    %rdi,%rax
  jne    L131
  jmp    L130
  nopl   0x0(%rax)
L96:
  movslq %ebp,%rcx
  jmp    L130
```

assistant: ```c
void SortArray(int **a, int na, int *key, int *index, int ni) {
  int i;
  int *newa;
  int *aux;
  aux = (int *)calloc(ni + 1, sizeof(int));
  for (i = 0; i <= ni; i++)
    aux[i] = index[i];
  assert(index[ni] == na);
  newa = (int *)calloc(na, sizeof(int));
  for (i = 0; i < na; i++)
    newa[index[key[i]]++] = (*a)[i];
  if (*a != NULL)
    free(*a);
  *a = newa;
  EndIndex2BeginIndex(index, ni);
  for (i = 0; i <= ni; i++)
    assert(aux[i] == index[i]);
}
```