user: What would the C source look like for the assembly code provided here?

```asm
<ksmall_dbl>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  je     L62
  cmpq   $0x0,-0x50(%rbp)
  je     L62
  cmpq   $0x0,-0x40(%rbp)
  je     L62
  mov    -0x48(%rbp),%rax
  cmp    -0x40(%rbp),%rax
  jae    L62
  mov    $0x1,%eax
  jmp    L123
L62:
  mov    $0x0,%eax
L123:
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x2,-0x40(%rbp)
  ja     L97
  cmpq   $0x1,-0x40(%rbp)
  ja     L28
  mov    -0x38(%rbp),%rax
  movsd  (%rax),%xmm0
  jmp    L20
L28:
  cmpq   $0x0,-0x48(%rbp)
  je     L218
  mov    -0x38(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L246
  mov    -0x38(%rbp),%rax
  movsd  (%rax),%xmm0
  jmp    L20
L246:
  mov    -0x38(%rbp),%rax
  movsd  0x8(%rax),%xmm0
  jmp    L20
L218:
  mov    -0x38(%rbp),%rax
  movsd  (%rax),%xmm0
  mov    -0x38(%rbp),%rax
  add    $0x8,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L238
  mov    -0x38(%rbp),%rax
  movsd  0x8(%rax),%xmm0
  jmp    L20
L238:
  mov    -0x38(%rbp),%rax
  movsd  (%rax),%xmm0
  jmp    L20
L97:
  mov    -0x50(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  je     L105
  mov    -0x40(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rcx
  mov    -0x50(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L105:
  movq   $0x0,-0x30(%rbp)
  mov    -0x40(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x28(%rbp)
  jmp    L13
L199:
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  shr    %rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  comisd %xmm1,%xmm0
  jbe    L145
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
L145:
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd -0x10(%rbp),%xmm0
  jbe    L134
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x10(%rbp)
  jmp    L263
L134:
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x10(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jbe    L263
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x10(%rbp)
L263:
  nop
L175:
  addq   $0x1,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x10(%rbp),%xmm0
  comisd %xmm1,%xmm0
  ja     L175
  nop
L55:
  subq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd -0x10(%rbp),%xmm0
  ja     L55
  mov    -0x20(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L183
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  lea    0x0(,%rax,8),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x18(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  jmp    L263
L183:
  nop
  mov    -0x20(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  jbe    L154
  mov    -0x20(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x28(%rbp)
  jmp    L13
L154:
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,-0x30(%rbp)
L13:
  mov    -0x30(%rbp),%rax
  cmp    -0x28(%rbp),%rax
  jb     L199
  mov    -0x48(%rbp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
L20:
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  leave
  ret
```

assistant: ```c
double ksmall_dbl(double *data, size_t n, size_t k, double *buf) {
  size_t a, b, l, r;
  double p, x;
  assert(data && buf && (n > 0) && (k < n));
  if (n <= 2) {
    if (n <= 1)
      return data[0];
    if (k > 0)
      return (data[0] > data[1]) ? data[0] : data[1];
    else
      return (data[0] > data[1]) ? data[1] : data[0];
  }
  if (buf != data)
    memcpy(buf, data, n * sizeof(double));
  a = 0;
  b = n - 1;
  while (a < b) {
    l = a;
    r = b;
    p = buf[(l + r) / 2];
    if (buf[l] > buf[r]) {
      x = buf[l];
      buf[l] = buf[r];
      buf[r] = x;
    }
    if (p < buf[l])
      p = buf[l];
    else if (p > buf[r])
      p = buf[r];
    while (1) {
      while (buf[++l] < p)
        ;
      while (buf[--r] > p)
        ;
      if (l >= r)
        break;
      x = buf[l];
      buf[l] = buf[r];
      buf[r] = x;
    }
    if (l > k)
      b = l - 1;
    else
      a = r + 1;
  }
  return buf[k];
}
```