user: 请从给定的汇编指令推导出C源代码：

```asm
<dqselect>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  mov    %edi,-0x1c(%rbp)
  mov    %rsi,-0x28(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  mov    $0x0,%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x20(%rbp),%eax
  cmp    %edx,%eax
  cmovg  %edx,%eax
  mov    %eax,-0x20(%rbp)
  jmp    L62
L139:
  mov    $0x0,%r13d
  mov    -0x1c(%rbp),%eax
  lea    -0x1(%rax),%r12d
  mov    %r12d,%ebx
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movapd %xmm1,%xmm6
  jmp    L1
L33:
  add    $0x1,%r13d
L158:
  movslq %r13d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movapd %xmm6,%xmm2
  comisd %xmm2,%xmm0
  jb     L98
  cmp    %ebx,%r13d
  jl     L33
L98:
  movslq %r13d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movapd %xmm6,%xmm3
  comisd %xmm0,%xmm3
  jbe    L125
  movslq %r13d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    %r13d,%ebx
L125:
  jmp    L124
L55:
  sub    $0x1,%r12d
L124:
  movslq %r12d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movapd %xmm6,%xmm4
  comisd %xmm0,%xmm4
  jb     L40
  cmp    %ebx,%r12d
  jg     L55
L40:
  movslq %r12d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movapd %xmm6,%xmm5
  comisd %xmm5,%xmm0
  ja     L16
  jmp    L1
L16:
  movslq %r12d,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    %r12d,%ebx
L1:
  cmp    %r12d,%r13d
  jl     L158
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movapd %xmm6,%xmm0
  movsd  %xmm0,(%rax)
  cmp    -0x20(%rbp),%ebx
  jne    L64
  jmp    L77
L64:
  cmp    -0x20(%rbp),%ebx
  jle    L152
  mov    %ebx,-0x1c(%rbp)
  jmp    L62
L152:
  add    $0x1,%ebx
  sub    %ebx,-0x1c(%rbp)
  movslq %ebx,%rax
  shl    $0x3,%rax
  add    %rax,-0x28(%rbp)
  sub    %ebx,-0x20(%rbp)
L62:
  cmpl   $0x1,-0x1c(%rbp)
  jg     L139
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
L77:
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
```

assistant: ```c
double dqselect(int n, double A[], int k) {
  register int i, j, p;
  register double val;
  k = ((k) > (0) ? (k) : (0));
  k = ((k) < (n - 1) ? (k) : (n - 1));
  while (n > 1) {
    i = 0;
    j = n - 1;
    p = j;
    val = A[p];
    while (i < j) {
      for (; A[i] >= val && i < p; i++)
        ;
      if (A[i] < val) {
        A[p] = A[i];
        p = i;
      }
      for (; A[j] <= val && j > p; j--)
        ;
      if (A[j] > val) {
        A[p] = A[j];
        p = j;
      }
    }
    A[p] = val;
    if (p == k)
      return val;
    else if (p > k)
      n = p;
    else {
      p++;
      n -= p;
      A += p;
      k -= p;
    }
  }
  return A[0];
}
```