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

```asm
<keySort>:
  endbr64
  push   %r15
  movslq %edx,%r15
  push   %r14
  mov    %r15,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  mov    %rdi,%r12
  lea    0x0(,%r15,4),%edi
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <malloc@plt>
  lea    0x0(,%r13,4),%edi
  mov    %rax,%rbx
  call   <malloc@plt>
  mov    %rax,%rbp
  test   %r15d,%r15d
  jle    L95
  lea    0x0(,%r15,4),%rdx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
L95:
  test   %r13d,%r13d
  jle    L39
  lea    -0x1(%r13),%edx
  lea    0x4(%r12),%rdi
  mov    %r12,%rax
  mov    %rdx,%r8
  lea    (%rdi,%rdx,4),%rcx
  nopl   0x0(%rax)
L109:
  movslq (%rax),%rdx
  add    $0x4,%rax
  addl   $0x1,0x4(%rbx,%rdx,4)
  cmp    %rax,%rcx
  jne    L109
  cmp    $0x1,%r14d
  jle    L4
L53:
  lea    -0x2(%r14),%ecx
  mov    (%rbx),%edx
  lea    0x4(%rbx),%rax
  lea    0x8(%rbx,%rcx,4),%rcx
  xchg   %ax,%ax
L20:
  add    (%rax),%edx
  add    $0x4,%rax
  mov    %edx,-0x4(%rax)
  cmp    %rax,%rcx
  jne    L20
  test   %r13d,%r13d
  jle    L0
  lea    -0x1(%r13),%r8d
  lea    0x4(%r12),%rdi
L4:
  mov    %r8d,%r9d
  mov    %r12,%rax
  shl    $0x2,%r9
  add    %r9,%rdi
  nopl   (%rax)
L61:
  movslq (%rax),%rdx
  add    $0x4,%rax
  lea    (%rbx,%rdx,4),%rcx
  movslq (%rcx),%rdx
  lea    0x1(%rdx),%esi
  mov    %esi,(%rcx)
  mov    -0x4(%rax),%ecx
  mov    %ecx,0x0(%rbp,%rdx,4)
  cmp    %rax,%rdi
  jne    L61
  lea    0x4(%rbp),%rdx
  mov    %r12,%rax
  sub    %rdx,%rax
  cmp    $0x8,%rax
  jbe    L137
  cmp    $0x2,%r8d
  jbe    L137
  mov    %r13d,%edx
  mov    %r12,%rcx
  mov    %rbp,%rax
  shr    $0x2,%edx
  sub    %rbp,%rcx
  shl    $0x4,%rdx
  add    %rbp,%rdx
  nop
L99:
  movdqu (%rax),%xmm0
  movups %xmm0,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rdx
  jne    L99
  mov    %r13d,%eax
  and    $0xfffffffc,%eax
  test   $0x3,%r13b
  je     L0
  mov    %eax,%ecx
  mov    0x0(%rbp,%rcx,4),%esi
  lea    0x0(,%rcx,4),%rdx
  mov    %esi,(%r12,%rcx,4)
  lea    0x1(%rax),%ecx
  cmp    %ecx,%r13d
  jle    L0
  mov    0x4(%rbp,%rdx,1),%ecx
  add    $0x2,%eax
  mov    %ecx,0x4(%r12,%rdx,1)
  cmp    %eax,%r13d
  jle    L0
  mov    0x8(%rbp,%rdx,1),%eax
  mov    %eax,0x8(%r12,%rdx,1)
L0:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L137:
  lea    0x4(%rbp,%r9,1),%rdx
  sub    %rbp,%r12
  nopl   0x0(%rax,%rax,1)
L155:
  mov    0x0(%rbp),%eax
  mov    %eax,(%r12,%rbp,1)
  add    $0x4,%rbp
  cmp    %rdx,%rbp
  jne    L155
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L39:
  cmp    $0x1,%r14d
  jg     L53
  jmp    L0
```

assistant: ```c
void keySort(int *nums, int size, int keySize) {
  int *array = (int *)malloc(sizeof(int) * keySize);
  int *nums1 = (int *)malloc(sizeof(int) * size);
  for (int i = 0; i < keySize; i++)
    array[i] = 0;
  for (int i = 0; i < size; i++)
    array[nums[i] + 1]++;
  for (int i = 0; i < keySize - 1; i++)
    array[i + 1] += array[i];
  for (int i = 0; i < size; i++)
    nums1[array[nums[i]]++] = nums[i];
  for (int i = 0; i < size; i++)
    nums[i] = nums1[i];
}
```