user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<counting_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %esi,-0x5c(%rbp)
  mov    %edx,-0x60(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x30(%rbp)
  movq   $0x0,-0x28(%rbp)
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  movl   $0x0,-0x44(%rbp)
  jmp    L30
L2:
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltd
  idivl  -0x60(%rbp)
  mov    %eax,%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x40(%rbp),%ecx
  mov    %ecx,%eax
  shl    $0x2,%eax
  add    %ecx,%eax
  add    %eax,%eax
  sub    %eax,%edx
  mov    %edx,-0x40(%rbp)
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x30(%rbp,%rax,4),%eax
  lea    0x1(%rax),%edx
  mov    -0x40(%rbp),%eax
  cltq
  mov    %edx,-0x30(%rbp,%rax,4)
  addl   $0x1,-0x44(%rbp)
L30:
  mov    -0x44(%rbp),%eax
  cmp    -0x5c(%rbp),%eax
  jl     L2
  movl   $0x1,-0x44(%rbp)
  jmp    L21
L27:
  mov    -0x44(%rbp),%eax
  cltq
  mov    -0x30(%rbp,%rax,4),%edx
  mov    -0x44(%rbp),%eax
  sub    $0x1,%eax
  cltq
  mov    -0x30(%rbp,%rax,4),%eax
  add    %eax,%edx
  mov    -0x44(%rbp),%eax
  cltq
  mov    %edx,-0x30(%rbp,%rax,4)
  addl   $0x1,-0x44(%rbp)
L21:
  cmpl   $0x9,-0x44(%rbp)
  jle    L27
  mov    -0x5c(%rbp),%eax
  mov    $0x4,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x38(%rbp)
  mov    -0x5c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x44(%rbp)
  jmp    L26
L43:
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cltd
  idivl  -0x60(%rbp)
  mov    %eax,%edx
  movslq %edx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,-0x40(%rbp)
  mov    -0x40(%rbp),%ecx
  mov    %ecx,%eax
  shl    $0x2,%eax
  add    %ecx,%eax
  add    %eax,%eax
  sub    %eax,%edx
  mov    %edx,-0x40(%rbp)
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x30(%rbp,%rax,4),%eax
  lea    -0x1(%rax),%edx
  mov    -0x40(%rbp),%eax
  cltq
  mov    %edx,-0x30(%rbp,%rax,4)
  mov    -0x40(%rbp),%eax
  cltq
  mov    -0x30(%rbp,%rax,4),%eax
  mov    %eax,-0x3c(%rbp)
  mov    -0x44(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x58(%rbp),%rax
  add    %rdx,%rax
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0x44(%rbp)
L26:
  cmpl   $0x0,-0x44(%rbp)
  jns    L43
  mov    -0x58(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x38(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L32
  call   <__stack_chk_fail@plt>
L32:
  leave
  ret
```

assistant: ```c
int *counting_sort(int *vec, int length, int digit) {
  int vec_sum[10] = {0};
  int *vec_sort;
  int index, new_index;
  int i;
  for (i = 0; i < length; i++) {
    index = (vec[i] / digit) % 10;
    vec_sum[index]++;
  }
  for (i = 1; i < 10; i++)
    vec_sum[i] += vec_sum[i - 1];
  vec_sort = (int *)calloc(length, sizeof(int));
  for (i = length - 1; i >= 0; i--) {
    index = (vec[i] / digit) % 10;
    new_index = --vec_sum[index];
    vec_sort[new_index] = vec[i];
  }
  free(vec);
  return vec_sort;
}
```