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

```asm
<sort_r_simple>:
  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    L277
L168:
  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    L67
  mov    %r14,%rax
  mov    %r15,%r14
  mov    %rax,%r15
L67:
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdx
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jle    L155
  mov    0x8(%rsp),%r15
  mov    %r12,%rdx
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   *%rbp
  test   %eax,%eax
  cmovg  %r14,%r15
L155:
  cmp    %r13,%r15
  je     L127
  mov    %rbx,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
L127:
  mov    0x30(%rsp),%r14
  cmp    %r14,%r13
  jbe    L51
  mov    %r13,0x8(%rsp)
  mov    %r13,%r15
  mov    %r14,0x18(%rsp)
  jmp    L3
  nopw   0x0(%rax,%rax,1)
L0:
  add    %rbx,0x18(%rsp)
L108:
  add    %rbx,%r14
  cmp    %r15,%r14
  jae    L272
L3:
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   *%rbp
  test   %eax,%eax
  jg     L74
  jne    L108
  cmp    0x18(%rsp),%r14
  jbe    L0
  mov    0x18(%rsp),%rdi
  mov    %rbx,%rdx
  mov    %r14,%rsi
  call   <sort_r_swap@plt>
  jmp    L0
  nop
L121:
  js     L62
L74:
  cmp    %r14,%r15
  jbe    L272
L114:
  add    0x10(%rsp),%r15
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jne    L121
  mov    0x10(%rsp),%rax
  add    %rax,0x8(%rsp)
  mov    0x8(%rsp),%rcx
  cmp    %rcx,%r15
  jae    L74
  mov    %rbx,%rdx
  mov    %rcx,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
  cmp    %r14,%r15
  ja     L114
  cs nopw 0x0(%rax,%rax,1)
L272:
  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)
L166:
  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   <sort_r_simple>
  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    L64
  mov    %rdi,0x30(%rsp)
  jmp    L168
  nopw   0x0(%rax,%rax,1)
L62:
  cmp    %r14,%r15
  ja     L73
L70:
  add    %rbx,%r14
  cmp    %r14,%r15
  ja     L3
  jmp    L272
  xchg   %ax,%ax
L73:
  mov    %rbx,%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <sort_r_swap@plt>
  jmp    L70
L277:
  mov    0x30(%rsp),%rax
  mov    %rax,0x20(%rsp)
L64:
  mov    0x20(%rsp),%rax
  lea    (%rax,%rbx,1),%r13
  cmp    0x28(%rsp),%r13
  jae    L253
  nopw   0x0(%rax,%rax,1)
L238:
  mov    %r13,%rsi
  jmp    L148
  nopl   (%rax)
L10:
  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     L262
  mov    %r14,%rsi
L148:
  cmp    0x20(%rsp),%rsi
  ja     L10
L262:
  add    %rbx,%r13
  cmp    0x28(%rsp),%r13
  jb     L238
L253:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L51:
  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    L166
```

assistant: ```c
void sort_r_simple(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);
    sort_r_simple(b, (pl - ple) / w, w, compar, arg);
    sort_r_simple(end - (pre - pr), (pre - pr) / w, w, compar, arg);
  }
}
```