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

```asm
<qsort_r>:
  endbr64
  push   %r15
  mov    %rsi,%rax
  push   %r14
  push   %r13
  push   %r12
  mov    %r8,%r12
  push   %rbp
  mov    %rcx,%rbp
  push   %rbx
  mov    %rdx,%rbx
  mov    %rsi,%rdx
  imul   %rbx,%rdx
  sub    $0x48,%rsp
  add    %rdi,%rdx
  mov    %rdi,0x30(%rsp)
  mov    %rbx,%rdi
  neg    %rdi
  mov    %rdx,0x28(%rsp)
  mov    %rdi,0x10(%rsp)
  cmp    $0x9,%rsi
  jbe    L104
L42:
  lea    -0x1(%rax),%r13
  shr    %rax
  mov    0x30(%rsp),%rdi
  mov    %r12,%rdx
  imul   %rbx,%rax
  imul   %rbx,%r13
  lea    (%rdi,%rbx,1),%r14
  lea    (%rdi,%rax,1),%r15
  mov    0x10(%rsp),%rax
  add    %rdi,%r13
  mov    %r15,%rsi
  mov    %r14,%rdi
  add    %r13,%rax
  mov    %rax,0x8(%rsp)
  call   *%rbp
  test   %eax,%eax
  jle    L49
  mov    %r14,%rax
  mov    %r15,%r14
  mov    %rax,%r15
L49:
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdx
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jle    L34
  mov    0x8(%rsp),%r15
  mov    %r12,%rdx
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   *%rbp
  test   %eax,%eax
  cmovg  %r14,%r15
L34:
  cmp    %r13,%r15
  je     L270
  mov    %rbx,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
L270:
  mov    0x30(%rsp),%r14
  cmp    %r14,%r13
  jbe    L83
  mov    %r13,0x8(%rsp)
  mov    %r13,%r15
  mov    %r14,0x18(%rsp)
  jmp    L113
  nopw   0x0(%rax,%rax,1)
L138:
  add    %rbx,0x18(%rsp)
L158:
  add    %rbx,%r14
  cmp    %r15,%r14
  jae    L262
L113:
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   *%rbp
  test   %eax,%eax
  jg     L237
  jne    L158
  cmp    0x18(%rsp),%r14
  jbe    L138
  mov    0x18(%rsp),%rdi
  mov    %rbx,%rdx
  mov    %r14,%rsi
  call   <sort_r_swap@plt>
  jmp    L138
  nop
L46:
  js     L195
L237:
  cmp    %r14,%r15
  jbe    L262
L112:
  add    0x10(%rsp),%r15
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jne    L46
  mov    0x10(%rsp),%rax
  add    %rax,0x8(%rsp)
  mov    0x8(%rsp),%rcx
  cmp    %rcx,%r15
  jae    L237
  mov    %rbx,%rdx
  mov    %rcx,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
  cmp    %r14,%r15
  ja     L112
  cs nopw 0x0(%rax,%rax,1)
L262:
  mov    0x8(%rsp),%rax
  mov    0x18(%rsp),%esi
  sub    0x30(%rsp),%esi
  sub    %r15,%rax
  mov    %rax,%r13
  mov    %eax,%r9d
  mov    0x28(%rsp),%rax
  sub    %r13,%rax
  mov    %rax,0x20(%rsp)
L99:
  mov    0x30(%rsp),%r14
  mov    %r15,%rcx
  sub    0x18(%rsp),%rcx
  mov    %r9d,0x3c(%rsp)
  mov    %ecx,%edx
  mov    %rcx,0x18(%rsp)
  mov    %r14,%rdi
  call   <sort_r_swap_blocks@plt>
  mov    0x3c(%rsp),%esi
  mov    0x28(%rsp),%edx
  mov    %r15,%rdi
  sub    0x8(%rsp),%edx
  call   <sort_r_swap_blocks@plt>
  mov    0x18(%rsp),%rax
  xor    %edx,%edx
  mov    %r14,%rdi
  mov    %r12,%r8
  mov    %rbp,%rcx
  div    %rbx
  mov    %rbx,%rdx
  mov    %rax,%rsi
  call   <qsort_r>
  mov    %r13,%rax
  xor    %edx,%edx
  mov    0x20(%rsp),%rdi
  div    %rbx
  mov    %rax,%rdx
  imul   %rbx,%rdx
  add    %rdi,%rdx
  mov    %rdx,0x28(%rsp)
  cmp    $0x9,%rax
  jbe    L209
  mov    %rdi,0x30(%rsp)
  jmp    L42
  nopw   0x0(%rax,%rax,1)
L195:
  cmp    %r14,%r15
  ja     L244
L131:
  add    %rbx,%r14
  cmp    %r14,%r15
  ja     L113
  jmp    L262
  xchg   %ax,%ax
L244:
  mov    %rbx,%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <sort_r_swap@plt>
  jmp    L131
L104:
  mov    0x30(%rsp),%rax
  mov    %rax,0x20(%rsp)
L209:
  mov    0x20(%rsp),%rax
  lea    (%rax,%rbx,1),%r13
  cmp    0x28(%rsp),%r13
  jae    L19
  nopw   0x0(%rax,%rax,1)
L95:
  mov    %r13,%rsi
  jmp    L94
  nopl   (%rax)
L254:
  mov    %rsi,%r14
  mov    %r12,%r8
  mov    %rbp,%rcx
  mov    %rbx,%rdx
  sub    %rbx,%r14
  mov    %r14,%rdi
  call   <sort_r_cmpswap@plt>
  test   %rax,%rax
  je     L16
  mov    %r14,%rsi
L94:
  cmp    0x20(%rsp),%rsi
  ja     L254
L16:
  add    %rbx,%r13
  cmp    0x28(%rsp),%r13
  jb     L95
L19:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L83:
  mov    0x28(%rsp),%rax
  mov    %r13,0x8(%rsp)
  mov    %r13,%r15
  xor    %r9d,%r9d
  xor    %r13d,%r13d
  xor    %esi,%esi
  mov    %rax,0x20(%rsp)
  mov    0x30(%rsp),%rax
  mov    %rax,0x18(%rsp)
  jmp    L99
```

assistant: ```c
void qsort_r(void *base, size_t nel, size_t w, int (*compar)(const void *_a, const void *_b, void *_arg), void *arg) {
  char *b = (char *)base, *end = b + nel * w;
  if (nel < 10) {
    char *pi, *pj;
    for (pi = b + w; pi < end; pi += w) {
      for (pj = pi; pj > b && sort_r_cmpswap(pj - w, pj, w, compar, arg); pj -= w) {
      }
    }
  } else {
    int cmp;
    char *pl, *ple, *pr, *pre, *pivot;
    char *last = b + w * (nel - 1), *tmp;
    char *l[3];
    l[0] = b + w;
    l[1] = b + w * (nel / 2);
    l[2] = last - w;
    if (compar(l[0], l[1], arg) > 0) {
      ((tmp) = (l[0]), (l[0]) = (l[1]), (l[1]) = (tmp));
    }
    if (compar(l[1], l[2], arg) > 0) {
      ((tmp) = (l[1]), (l[1]) = (l[2]), (l[2]) = (tmp));
      if (compar(l[0], l[1], arg) > 0) {
        ((tmp) = (l[0]), (l[0]) = (l[1]), (l[1]) = (tmp));
      }
    }
    if (l[1] != last) {
      sort_r_swap(l[1], last, w);
    }
    pivot = last;
    ple = pl = b;
    pre = pr = last;
    while (pl < pr) {
      for (; pl < pr; pl += w) {
        cmp = compar(pl, pivot, arg);
        if (cmp > 0) {
          break;
        } else if (cmp == 0) {
          if (ple < pl) {
            sort_r_swap(ple, pl, w);
          }
          ple += w;
        }
      }
      if (pl >= pr) {
        break;
      }
      for (; pl < pr;) {
        pr -= w;
        cmp = compar(pr, pivot, arg);
        if (cmp == 0) {
          pre -= w;
          if (pr < pre) {
            sort_r_swap(pr, pre, w);
          }
        } else if (cmp < 0) {
          if (pl < pr) {
            sort_r_swap(pl, pr, w);
          }
          pl += w;
          break;
        }
      }
    }
    pl = pr;
    sort_r_swap_blocks(b, ple - b, pl - ple);
    sort_r_swap_blocks(pr, pre - pr, end - pre);
    qsort_r(b, (pl - ple) / w, w, compar, arg);
    qsort_r(end - (pre - pr), (pre - pr) / w, w, compar, arg);
  }
}
```