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

```asm
<qselect>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  movl   $0x0,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  jmp    L0
L22:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  ja     L38
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x4(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  addl   $0x1,-0x8(%rbp)
  jmp    L71
L38:
  nop
L71:
  addl   $0x1,-0xc(%rbp)
L0:
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0xc(%rbp)
  jl     L22
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  cvttsd2si %xmm0,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0x4(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x20(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jne    L70
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  jmp    L58
L70:
  mov    -0x8(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  jle    L25
  mov    -0x20(%rbp),%edx
  mov    -0x8(%rbp),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <qselect>
  movq   %xmm0,%rax
  jmp    L58
L25:
  mov    -0x20(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    -0x8(%rbp),%ecx
  movslq %ecx,%rcx
  lea    0x0(,%rcx,8),%rsi
  mov    -0x18(%rbp),%rcx
  add    %rsi,%rcx
  mov    %eax,%esi
  mov    %rcx,%rdi
  call   <qselect>
  movq   %xmm0,%rax
L58:
  movq   %rax,%xmm0
  leave
  ret
```

assistant: ```c
double qselect(double *v, int len, int k) {
  int i, st, tmp;
  for (st = i = 0; i < len - 1; i++) {
    if (v[i] > v[len - 1])
      continue;
    tmp = v[i];
    v[i] = v[st];
    v[st] = tmp;
    st++;
  }
  tmp = v[len - 1];
  v[len - 1] = v[st];
  v[st] = tmp;
  return k == st ? v[st] : st > k ? qselect(v, st, k) : qselect(v + st, len - st, k - st);
}
```