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

```asm
<radix_sort>:
  endbr64
  push   %r15
  pxor   %xmm0,%xmm0
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edx,%ebx
  sub    $0xb8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0xa8(%rsp)
  xor    %eax,%eax
  movaps %xmm0,0x50(%rsp)
  movq   $0x0,0x70(%rsp)
  movq   $0x0,0xa0(%rsp)
  movaps %xmm0,0x60(%rsp)
  movaps %xmm0,0x80(%rsp)
  movaps %xmm0,0x90(%rsp)
  test   %esi,%esi
  jle    L196
  mov    %esi,%r12d
  mov    %rdi,%rbp
  mov    %rdi,%rsi
  lea    -0x1(%r12),%eax
  lea    0x4(%rdi,%rax,4),%r10
  mov    %rax,%r13
  xor    %edi,%edi
  nopl   (%rax)
L142:
  mov    (%rsi),%eax
  cltd
  idiv   %ebx
  movslq %eax,%rdx
  mov    %eax,%ecx
  imul   $0x66666667,%rdx,%rdx
  sar    $0x1f,%ecx
  sar    $0x22,%rdx
  sub    %ecx,%edx
  lea    (%rdx,%rdx,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  cltq
  addl   $0x1,0x50(%rsp,%rax,4)
  addl   $0x1,0x80(%rsp,%rax,4)
  xor    %eax,%eax
  test   %edx,%edx
  setg   %al
  add    $0x4,%rsi
  add    %eax,%edi
  cmp    %rsi,%r10
  jne    L142
  test   %edi,%edi
  je     L196
  mov    0x50(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x38(%rsp)
  mov    0x54(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%r15
  mov    0x58(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,%r14
  mov    0x5c(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x8(%rsp)
  mov    0x60(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x10(%rsp)
  mov    0x64(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x18(%rsp)
  mov    0x68(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  mov    0x6c(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x28(%rsp)
  mov    0x70(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    %rax,0x30(%rsp)
  mov    0x74(%rsp),%eax
  lea    0x0(,%rax,4),%edi
  call   <malloc@plt>
  mov    0x38(%rsp),%r10
  movslq %r13d,%rcx
  lea    D7(%rip),%rdi
  mov    %rax,%r8
  nopw   0x0(%rax,%rax,1)
L73:
  mov    0x0(%rbp,%rcx,4),%esi
  mov    %esi,%eax
  cltd
  idiv   %ebx
  movslq %eax,%rdx
  mov    %eax,%r9d
  imul   $0x66666667,%rdx,%rdx
  sar    $0x1f,%r9d
  sar    $0x22,%rdx
  sub    %r9d,%edx
  lea    (%rdx,%rdx,4),%r9d
  add    %r9d,%r9d
  sub    %r9d,%eax
  movslq %eax,%r9
  mov    0x50(%rsp,%r9,4),%eax
  sub    $0x1,%eax
  mov    %eax,0x50(%rsp,%r9,4)
  cmp    $0x9,%r9d
  ja     L227
  mov    %r9d,%edx
  cltq
  movslq (%rdi,%rdx,4),%rdx
  add    %rdi,%rdx
  notrack jmp *%rdx
  mov    %esi,(%r8,%rax,4)
L227:
  sub    $0x1,%rcx
  test   %ecx,%ecx
  jns    L73
  nopl   0x0(%rax)
L199:
  lea    0x4c(%rsp),%r13
  mov    %r10,%rdi
  mov    %rbp,%rsi
  mov    %r8,0x38(%rsp)
  mov    0x80(%rsp),%ecx
  mov    %r13,%rdx
  movl   $0x0,0x4c(%rsp)
  call   <copy@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  mov    0x84(%rsp),%ecx
  call   <copy@plt>
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %r14,%rdi
  mov    0x88(%rsp),%ecx
  call   <copy@plt>
  mov    0x8(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x8c(%rsp),%ecx
  call   <copy@plt>
  mov    0x10(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x90(%rsp),%ecx
  call   <copy@plt>
  mov    0x18(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x94(%rsp),%ecx
  call   <copy@plt>
  mov    0x20(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x98(%rsp),%ecx
  call   <copy@plt>
  mov    0x28(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0x9c(%rsp),%ecx
  call   <copy@plt>
  mov    0x30(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0xa0(%rsp),%ecx
  call   <copy@plt>
  mov    0x38(%rsp),%rdi
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    0xa4(%rsp),%ecx
  call   <copy@plt>
  mov    %r12d,%esi
  mov    %rbp,%rdi
  call   <print@plt>
  lea    (%rbx,%rbx,4),%edx
  mov    %r12d,%esi
  mov    %rbp,%rdi
  add    %edx,%edx
  call   <radix_sort>
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  add    $0xb8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
  mov    0x30(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  mov    0x28(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  mov    0x20(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  mov    0x18(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  mov    0x10(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  mov    0x8(%rsp),%rdx
  sub    $0x1,%rcx
  mov    %esi,(%rdx,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   0x0(%rax)
  sub    $0x1,%rcx
  mov    %esi,(%r14,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   (%rax)
  sub    $0x1,%rcx
  mov    %esi,(%r15,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   (%rax)
  sub    $0x1,%rcx
  mov    %esi,(%r10,%rax,4)
  test   %ecx,%ecx
  jns    L73
  jmp    L199
  nopl   (%rax)
L196:
  mov    0xa8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L50
  add    $0xb8,%rsp
  mov    %ebx,%esi
  lea    D17(%rip),%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10a0 <printf@plt>
L50:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D17
type: string

tool: D17: last radix is %d


assistant: ```c
void radix_sort(int v[], int length, int radix) {
  int size = 0;
  int count[10] = {0};
  int bak[10] = {0};
  int index;
  for (int i = 0; i < length; i++) {
    index = v[i] / radix % 10;
    count[index]++;
    bak[index]++;
    if (index > 0) {
      size++;
    }
  }
  if (!size) {
    printf("last radix is %d\n", radix);
    return;
  }
  int *a0 = malloc(sizeof(int) * count[0]);
  int *a1 = malloc(sizeof(int) * count[1]);
  int *a2 = malloc(sizeof(int) * count[2]);
  int *a3 = malloc(sizeof(int) * count[3]);
  int *a4 = malloc(sizeof(int) * count[4]);
  int *a5 = malloc(sizeof(int) * count[5]);
  int *a6 = malloc(sizeof(int) * count[6]);
  int *a7 = malloc(sizeof(int) * count[7]);
  int *a8 = malloc(sizeof(int) * count[8]);
  int *a9 = malloc(sizeof(int) * count[9]);
  for (int i = length - 1; i >= 0; --i) {
    index = v[i] / radix % 10;
    count[index]--;
    switch (index) {
    case 0:
      a0[count[index]] = v[i];
      break;
    case 1:
      a1[count[index]] = v[i];
      break;
    case 2:
      a2[count[index]] = v[i];
      break;
    case 3:
      a3[count[index]] = v[i];
      break;
    case 4:
      a4[count[index]] = v[i];
      break;
    case 5:
      a5[count[index]] = v[i];
      break;
    case 6:
      a6[count[index]] = v[i];
      break;
    case 7:
      a7[count[index]] = v[i];
      break;
    case 8:
      a8[count[index]] = v[i];
      break;
    case 9:
      a9[count[index]] = v[i];
      break;
    }
  }
  int pos = 0;
  copy(a0, v, &pos, bak[0]);
  copy(a1, v, &pos, bak[1]);
  copy(a2, v, &pos, bak[2]);
  copy(a3, v, &pos, bak[3]);
  copy(a4, v, &pos, bak[4]);
  copy(a5, v, &pos, bak[5]);
  copy(a6, v, &pos, bak[6]);
  copy(a7, v, &pos, bak[7]);
  copy(a8, v, &pos, bak[8]);
  copy(a9, v, &pos, bak[9]);
  print(v, length);
  radix_sort(v, length, radix * 10);
}
```