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

```asm
<countingSort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    %rsp,%rax
  mov    %rax,%rsi
  mov    -0x38(%rbp),%eax
  add    $0x1,%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0x18(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r10
  mov    $0x0,%r11d
  movslq %eax,%rdx
  mov    %rdx,%r8
  mov    $0x0,%r9d
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    $0x10,%eax
  sub    $0x1,%rax
  add    %rdx,%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L74:
  cmp    %rdx,%rsp
  je     L72
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L74
L72:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L101
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L101:
  mov    %rsp,%rax
  add    $0x3,%rax
  shr    $0x2,%rax
  shl    $0x2,%rax
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x1c(%rbp)
  jmp    L13
L102:
  mov    -0x10(%rbp),%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  movl   $0x0,(%rax,%rdx,4)
  addl   $0x1,-0x1c(%rbp)
L13:
  mov    -0x38(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jge    L102
  movl   $0x0,-0x1c(%rbp)
  jmp    L49
L51:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x10(%rbp),%rdx
  movslq %eax,%rcx
  mov    (%rdx,%rcx,4),%edx
  lea    0x1(%rdx),%ecx
  mov    -0x10(%rbp),%rdx
  cltq
  mov    %ecx,(%rdx,%rax,4)
  addl   $0x1,-0x1c(%rbp)
L49:
  mov    -0x1c(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jl     L51
  movl   $0x1,-0x1c(%rbp)
  jmp    L18
L112:
  mov    -0x10(%rbp),%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%ecx
  mov    -0x1c(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x10(%rbp),%rax
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  add    %eax,%ecx
  mov    -0x10(%rbp),%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  mov    %ecx,(%rax,%rdx,4)
  addl   $0x1,-0x1c(%rbp)
L18:
  mov    -0x38(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jge    L112
  mov    -0x34(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L53
L14:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rax
  movslq %edx,%rdx
  mov    (%rax,%rdx,4),%eax
  cltq
  shl    $0x2,%rax
  lea    -0x4(%rax),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    -0x10(%rbp),%rdx
  movslq %eax,%rcx
  mov    (%rdx,%rcx,4),%edx
  lea    -0x1(%rdx),%ecx
  mov    -0x10(%rbp),%rdx
  cltq
  mov    %ecx,(%rdx,%rax,4)
  subl   $0x1,-0x1c(%rbp)
L53:
  cmpl   $0x0,-0x1c(%rbp)
  jns    L14
  nop
  mov    %rsi,%rsp
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L39
  call   <__stack_chk_fail@plt>
L39:
  leave
  ret
```

assistant: ```c
void countingSort(int *array, int *sorted, int size, int max) {
  int maxArray[max + 1], i = 0;
  for (i = 0; i < max + 1; i++) {
    maxArray[i] = 0;
  }
  for (i = 0; i < size; i++) {
    maxArray[array[i]]++;
  }
  for (i = 1; i < max + 1; i++) {
    maxArray[i] = maxArray[i] + maxArray[i - 1];
  }
  for (i = size - 1; i >= 0; i--) {
    sorted[maxArray[array[i]] - 1] = array[i];
    maxArray[array[i]]--;
  }
  return;
}
```