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

```asm
<qst>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,%r13
  mov    %ecx,0x28(%rsp)
  mov    %r8d,0x24(%rsp)
  mov    %r9d,0x2c(%rsp)
  mov    %esi,%r14d
  sub    %edi,%r14d
  movslq %ecx,%rax
  mov    %rax,0x8(%rsp)
  lea    -0x1(%rcx),%edi
  mov    %edi,0x20(%rsp)
  neg    %rax
  mov    %rax,%r15
  jmp    L3
L44:
  mov    %r14,%rbx
  jmp    L293
L147:
  mov    0x8(%rsp),%rax
  lea    (%rbx,%rax,1),%rsi
  jmp    L302
L85:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   *%r13
  test   %eax,%eax
  jle    L147
  mov    %r14,%rbp
  cmp    %r12,%r14
  ja     L270
  jmp    L183
L290:
  mov    0x8(%rsp),%rax
  lea    (%rbx,%rax,1),%rsi
  lea    0x0(%rbp,%r15,1),%r14
  cmp    %r12,%rbx
  je     L20
L54:
  mov    0x20(%rsp),%eax
  lea    0x1(%rbx,%rax,1),%rcx
L296:
  movzbl (%rbx),%eax
  add    $0x1,%rbx
  movzbl 0x0(%rbp),%edx
  mov    %dl,-0x1(%rbx)
  add    $0x1,%rbp
  mov    %al,-0x1(%rbp)
  cmp    %rcx,%rbx
  jne    L296
L302:
  mov    %rsi,%rbx
L309:
  cmp    %r12,%rbx
  jb     L85
  mov    %r14,%rbp
  cmp    %r12,%r14
  jbe    L91
L270:
  mov    %r14,%rbp
L188:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   *%r13
  test   %eax,%eax
  jg     L290
  add    %r15,%rbp
  cmp    %rbp,%r12
  jb     L188
L91:
  cmp    %r12,%rbx
  je     L208
L183:
  lea    0x0(%rbp,%r15,1),%r14
  mov    %rbx,%rsi
  mov    %r12,%rbp
  mov    %rbx,%r12
  jmp    L54
L20:
  mov    %rbp,%r12
  mov    %rbp,%r14
  jmp    L54
L208:
  mov    0x8(%rsp),%rax
  lea    (%r12,%rax,1),%rbp
  mov    %r12,%rax
  sub    0x10(%rsp),%rax
  mov    %eax,%r14d
  mov    0x18(%rsp),%rbx
  sub    %rbp,%rbx
  cmp    %ebx,%eax
  jg     L216
  cmp    0x24(%rsp),%eax
  jge    L241
  mov    %ebx,%r14d
  mov    %rbp,0x10(%rsp)
L134:
  cmp    0x24(%rsp),%r14d
  jl     L40
L3:
  mov    %r14d,%eax
  mov    0x28(%rsp),%edi
  cltd
  idiv   %edi
  sar    %eax
  mov    %eax,%r12d
  imul   %edi,%r12d
  movslq %r12d,%r12
  mov    0x10(%rsp),%rax
  add    %rax,%r12
  cmp    0x2c(%rsp),%r14d
  jl     L37
  mov    %r12,%rsi
  mov    %rax,%r14
  mov    %rax,%rdi
  call   *%r13
  test   %eax,%eax
  jle    L104
  mov    0x18(%rsp),%rbx
  sub    0x8(%rsp),%rbx
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   *%r13
  test   %eax,%eax
  jle    L44
L49:
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   *%r13
  test   %eax,%eax
  jns    L37
  jmp    L293
L241:
  mov    0x2c(%rsp),%r9d
  mov    0x24(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    0x10(%rsp),%rdi
  call   <qst>
  mov    %ebx,%r14d
  mov    %rbp,0x10(%rsp)
  jmp    L3
L216:
  cmp    0x24(%rsp),%ebx
  jge    L259
  mov    %r12,0x18(%rsp)
  jmp    L134
L259:
  mov    0x2c(%rsp),%r9d
  mov    0x24(%rsp),%r8d
  mov    0x28(%rsp),%ecx
  mov    %r13,%rdx
  mov    0x18(%rsp),%rsi
  mov    %rbp,%rdi
  call   <qst>
  mov    %r12,0x18(%rsp)
  jmp    L3
L104:
  mov    0x18(%rsp),%rbx
  sub    0x8(%rsp),%rbx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   *%r13
  test   %eax,%eax
  jle    L37
  mov    0x10(%rsp),%r14
  cmp    %r12,%r14
  je     L49
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   *%r13
  test   %eax,%eax
  cmovns %r14,%rbx
L293:
  cmp    %r12,%rbx
  je     L37
  mov    0x20(%rsp),%eax
  lea    0x1(%r12,%rax,1),%rsi
  mov    %r12,%rax
L271:
  movzbl (%rax),%edx
  add    $0x1,%rax
  movzbl (%rbx),%ecx
  mov    %cl,-0x1(%rax)
  add    $0x1,%rbx
  mov    %dl,-0x1(%rbx)
  cmp    %rax,%rsi
  jne    L271
L37:
  mov    0x18(%rsp),%rax
  lea    (%rax,%r15,1),%r14
  mov    0x10(%rsp),%rbx
  jmp    L309
L40:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void qst(char *base, char *max, int (*qcmp)(void *, void *), int qsz, int thresh, int mthresh) {
  register char c, *i, *j, *jj;
  register int ii;
  char *mid, *tmp;
  int lo, hi;
  lo = max - base;
  do {
    mid = i = base + qsz * ((lo / qsz) >> 1);
    if (lo >= mthresh) {
      j = (qcmp((jj = base), i) > 0 ? jj : i);
      if (qcmp(j, (tmp = max - qsz)) > 0) {
        j = (j == jj ? i : jj);
        if (qcmp(j, tmp) < 0)
          j = tmp;
      }
      if (j != i) {
        ii = qsz;
        do {
          c = *i;
          *i++ = *j;
          *j++ = c;
        } while (--ii);
      }
    }
    for (i = base, j = max - qsz;;) {
      while (i < mid && qcmp(i, mid) <= 0)
        i += qsz;
      while (j > mid) {
        if (qcmp(mid, j) <= 0) {
          j -= qsz;
          continue;
        }
        tmp = i + qsz;
        if (i == mid) {
          mid = jj = j;
        } else {
          jj = j;
          j -= qsz;
        }
        goto swap;
      }
      if (i == mid) {
        break;
      } else {
        jj = mid;
        tmp = mid = i;
        j -= qsz;
      }
    swap:
      ii = qsz;
      do {
        c = *i;
        *i++ = *jj;
        *jj++ = c;
      } while (--ii);
      i = tmp;
    }
    i = (j = mid) + qsz;
    if ((lo = j - base) <= (hi = max - i)) {
      if (lo >= thresh)
        qst(base, j, qcmp, qsz, thresh, mthresh);
      base = i;
      lo = hi;
    } else {
      if (hi >= thresh)
        qst(i, max, qcmp, qsz, thresh, mthresh);
      max = j;
    }
  } while (lo >= thresh);
}
```