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

```asm
<countSort>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  movslq %edx,%r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  lea    0x0(,%r13,4),%edi
  sub    $0x18,%rsp
  call   <malloc@plt>
  test   %rax,%rax
  jne    L67
L125:
  add    $0x18,%rsp
  mov    $0xffffffff,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L67:
  lea    0x0(,%r12,4),%r8d
  mov    %rax,%rbp
  mov    %r8d,%edi
  mov    %r8d,0xc(%rsp)
  call   <malloc@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L104
  test   %r13d,%r13d
  mov    0xc(%rsp),%r8d
  mov    %r13,%r14
  jle    L37
  lea    0x0(,%r13,4),%rdx
  xor    %esi,%esi
  mov    %rbp,%rdi
  mov    %r8d,0xc(%rsp)
  call   <memset@plt>
  mov    0xc(%rsp),%r8d
L37:
  test   %r12d,%r12d
  jle    L126
  lea    -0x1(%r12),%edx
  mov    %rbx,%rax
  mov    %rdx,%r13
  lea    0x4(%rbx,%rdx,4),%rsi
  xchg   %ax,%ax
L62:
  movslq (%rax),%rdx
  add    $0x4,%rax
  addl   $0x1,0x0(%rbp,%rdx,4)
  cmp    %rax,%rsi
  jne    L62
  cmp    $0x1,%r14d
  jle    L131
L38:
  lea    0x4(%rbp),%rax
  mov    $0x1,%edx
L29:
  add    $0x1,%edx
  mov    -0x4(%rax),%esi
  add    %esi,(%rax)
  add    $0x4,%rax
  cmp    %edx,%r14d
  jg     L29
  test   %r13d,%r13d
  js     L120
L131:
  movslq %r13d,%rax
  nopl   0x0(%rax)
L9:
  movslq (%rbx,%rax,4),%rdx
  sub    $0x1,%rax
  mov    %rdx,%rcx
  lea    0x0(%rbp,%rdx,4),%rdx
  movslq (%rdx),%rsi
  mov    %ecx,-0x4(%r15,%rsi,4)
  subl   $0x1,(%rdx)
  test   %eax,%eax
  jns    L9
L120:
  mov    %r8d,%edx
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  xor    %eax,%eax
  lea    D2(%rip),%rdi
  call   <printf@plt>
  test   %r12d,%r12d
  jle    L10
  mov    %r13d,%r13d
  lea    D1(%rip),%rbp
  lea    0x4(%rbx,%r13,4),%r12
  nop
L36:
  mov    (%rbx),%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x4,%rbx
  call   <printf@plt>
  cmp    %r12,%rbx
  jne    L36
L10:
  add    $0x18,%rsp
  mov    $0xa,%edi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <putchar@plt>
  nopl   (%rax)
L104:
  mov    %rbp,%rdi
  call   <free@plt>
  jmp    L125
  nopl   (%rax)
L126:
  lea    -0x1(%r12),%r13d
  cmp    $0x1,%r14d
  jg     L38
  mov    %r8d,%edx
  mov    %r15,%rsi
  mov    %rbx,%rdi
  call   <memcpy@plt>
  mov    %rbp,%rdi
  call   <free@plt>
  mov    %r15,%rdi
  call   <free@plt>
  lea    D2(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L10
```

tool_calls: name: read_data
arguments: data_tag: D2
type_infered: string
name: read_data
arguments: data_tag: D1
type_infered: string

tool: D2: Count sort 

tool: D1: %3d

assistant: ```c
int countSort(int *data, int size, int k) {
  int *counts, *temp;
  int i, j;
  if ((counts = (int *)malloc(k * sizeof(int))) == NULL)
    return -1;
  if ((temp = (int *)malloc(size * sizeof(int))) == NULL) {
    free(counts);
    return -1;
  }
  for (i = 0; i < k; i++)
    counts[i] = 0;
  for (j = 0; j < size; j++)
    counts[data[j]] = counts[data[j]] + 1;
  for (i = 1; i < k; i++)
    counts[i] = counts[i] + counts[i - 1];
  for (j = size - 1; j >= 0; j--) {
    temp[counts[data[j]] - 1] = data[j];
    counts[data[j]] = counts[data[j]] - 1;
  }
  memcpy(data, temp, size * sizeof(int));
  free(counts);
  free(temp);
  printf("Count sort ");
  for (i = 0; i < size; i++) {
    printf("%3d", data[i]);
  }
  printf("\n");
}
```