user: Translate the below assembly code into C programming language:

```asm
<_topnsel_quicksort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x2c(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x30(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x2c(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jne    L68
  mov    -0x2c(%rbp),%eax
  jmp    L118
L68:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L121
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  jg     L121
  addl   $0x1,-0x18(%rbp)
  jmp    L68
L121:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L95
L117:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L104
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  jl     L104
  subl   $0x1,-0x14(%rbp)
  jmp    L117
L104:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L34
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rax,(%rdx)
  jmp    L68
L95:
  nop
  jmp    L44
L34:
  nop
L44:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  jle    L6
  subl   $0x1,-0x18(%rbp)
L6:
  mov    -0x18(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  je     L14
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rax,(%rdx)
L14:
  mov    -0x18(%rbp),%eax
L118:
  pop    %rbp
  ret
```

assistant: ```c
int _topnsel_quicksort(long *data, int startidx, int endidx) {
  long pivot = data[startidx];
  int p = startidx + 1;
  int q = endidx;
  long swapbuf;
  if (startidx == endidx)
    return startidx;
  while (1) {
    while (1) {
      if (p == q || data[p] < pivot)
        break;
      p++;
    }
    if (p == q)
      break;
    while (1) {
      if (p == q || data[q] > pivot)
        break;
      q--;
    }
    if (p == q)
      break;
    swapbuf = data[p];
    data[p] = data[q];
    data[q] = swapbuf;
  }
  if (data[p] < pivot)
    p--;
  if (p != startidx) {
    swapbuf = data[p];
    data[p] = data[startidx];
    data[startidx] = swapbuf;
  }
  return p;
}
```