user: Demonstrate the C code that generates the assembly output below:

```asm
<bead_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L40
L95:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x10(%rbp)
  jge    L66
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x10(%rbp)
L66:
  addl   $0x1,-0x18(%rbp)
L40:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L95
  mov    -0x10(%rbp),%eax
  imul   -0x2c(%rbp),%eax
  mov    %eax,%esi
  mov    $0x1,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L65
L75:
  movl   $0x0,-0x14(%rbp)
  jmp    L14
L98:
  mov    -0x18(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x1,(%rax)
  addl   $0x1,-0x14(%rbp)
L14:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  cmp    %eax,-0x14(%rbp)
  jl     L98
  addl   $0x1,-0x18(%rbp)
L65:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L75
  movl   $0x0,-0x14(%rbp)
  jmp    L169
L159:
  movl   $0x0,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  jmp    L46
L106:
  mov    -0x18(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  add    %eax,-0xc(%rbp)
  mov    -0x18(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  addl   $0x1,-0x18(%rbp)
L46:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L106
  mov    -0x2c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  jmp    L67
L108:
  mov    -0x18(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x1,(%rax)
  addl   $0x1,-0x18(%rbp)
L67:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L108
  addl   $0x1,-0x14(%rbp)
L169:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L159
  movl   $0x0,-0x18(%rbp)
  jmp    L157
L54:
  movl   $0x0,-0x14(%rbp)
  jmp    L36
L126:
  addl   $0x1,-0x14(%rbp)
L36:
  mov    -0x14(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jge    L118
  mov    -0x18(%rbp),%eax
  imul   -0x10(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L126
L118:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x18(%rbp)
L157:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L54
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  nop
  leave
  ret
```

assistant: ```c
void bead_sort(int *a, int len) {
  int i, j, max, sum;
  unsigned char *beads;
  max = a[0];
  for (i = 1; i < len; i++)
    if (a[i] > max)
      max = a[i];
  beads = calloc(1, max * len);
  for (i = 0; i < len; i++)
    for (j = 0; j < a[i]; j++)
      beads[i * max + j] = 1;
  for (j = 0; j < max; j++) {
    for (sum = i = 0; i < len; i++) {
      sum += beads[i * max + j];
      beads[i * max + j] = 0;
    }
    for (i = len - sum; i < len; i++)
      beads[i * max + j] = 1;
  }
  for (i = 0; i < len; i++) {
    for (j = 0; j < max && beads[i * max + j]; j++)
      ;
    a[i] = j;
  }
  free(beads);
}
```