user: Converte this assembly snippet into its equivalent C code:

```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    L99
L74:
  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    L61
  mov    %r14,%rax
  mov    %r15,%r14
  mov    %rax,%r15
L61:
  mov    0x8(%rsp),%rsi
  mov    %r12,%rdx
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jle    L227
  mov    0x8(%rsp),%r15
  mov    %r12,%rdx
  mov    %r14,%rdi
  mov    %r15,%rsi
  call   *%rbp
  test   %eax,%eax
  cmovg  %r14,%r15
L227:
  cmp    %r13,%r15
  je     L175
  mov    %rbx,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
L175:
  mov    0x30(%rsp),%r14
  cmp    %r14,%r13
  jbe    L11
  mov    %r13,0x8(%rsp)
  mov    %r13,%r15
  mov    %r14,0x18(%rsp)
  jmp    L105
  nopw   0x0(%rax,%rax,1)
L23:
  add    %rbx,0x18(%rsp)
L229:
  add    %rbx,%r14
  cmp    %r15,%r14
  jae    L157
L105:
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   *%rbp
  test   %eax,%eax
  jg     L62
  jne    L229
  cmp    0x18(%rsp),%r14
  jbe    L23
  mov    0x18(%rsp),%rdi
  mov    %rbx,%rdx
  mov    %r14,%rsi
  call   <sort_r_swap@plt>
  jmp    L23
  nop
L274:
  js     L172
L62:
  cmp    %r14,%r15
  jbe    L157
L272:
  add    0x10(%rsp),%r15
  mov    %r12,%rdx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   *%rbp
  test   %eax,%eax
  jne    L274
  mov    0x10(%rsp),%rax
  add    %rax,0x8(%rsp)
  mov    0x8(%rsp),%rcx
  cmp    %rcx,%r15
  jae    L62
  mov    %rbx,%rdx
  mov    %rcx,%rsi
  mov    %r15,%rdi
  call   <sort_r_swap@plt>
  cmp    %r14,%r15
  ja     L272
  cs nopw 0x0(%rax,%rax,1)
L157:
  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)
L100:
  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    L72
  mov    %rdi,0x30(%rsp)
  jmp    L74
  nopw   0x0(%rax,%rax,1)
L172:
  cmp    %r14,%r15
  ja     L71
L13:
  add    %rbx,%r14
  cmp    %r14,%r15
  ja     L105
  jmp    L157
  xchg   %ax,%ax
L71:
  mov    %rbx,%rdx
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <sort_r_swap@plt>
  jmp    L13
L99:
  mov    0x30(%rsp),%rax
  mov    %rax,0x20(%rsp)
L72:
  mov    0x20(%rsp),%rax
  lea    (%rax,%rbx,1),%r13
  cmp    0x28(%rsp),%r13
  jae    L24
  nopw   0x0(%rax,%rax,1)
L110:
  mov    %r13,%rsi
  jmp    L217
  nopl   (%rax)
L193:
  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     L48
  mov    %r14,%rsi
L217:
  cmp    0x20(%rsp),%rsi
  ja     L193
L48:
  add    %rbx,%r13
  cmp    0x28(%rsp),%r13
  jb     L110
L24:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L11:
  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    L100
```

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);
  }
}
```