user: What would the C source look like for the assembly code provided here?

```asm
<sorter_grail_common_sort>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r14
  mov    %esi,%ebp
  mov    %rdx,0x8(%rsp)
  mov    %ecx,0x10(%rsp)
  mov    $0x1,%ebx
  cmp    $0xf,%esi
  jle    L23
L28:
  add    %ebx,%ebx
  mov    %ebx,%eax
  imul   %ebx,%eax
  cmp    %ebp,%eax
  jl     L28
  lea    -0x1(%rbp),%eax
  cltd
  idiv   %ebx
  lea    0x1(%rax),%r13d
  lea    0x0(%r13,%rbx,1),%r15d
  mov    %r15d,0x14(%rsp)
  mov    %r15d,%edx
  mov    %ebp,%esi
  mov    %r14,%rdi
  call   <sorter_grail_find_keys@plt>
  mov    %eax,0x1c(%rsp)
  cmp    %eax,%r15d
  jle    L124
  cmp    $0x3,%eax
  jle    L41
  mov    0x1c(%rsp),%edx
  cmp    %ebx,%eax
  jge    L153
L53:
  mov    %ebx,%eax
  shr    $0x1f,%eax
  add    %ebx,%eax
  sar    %eax
  mov    %eax,%ebx
  cmp    %eax,%edx
  jl     L53
L153:
  mov    %ebp,%esi
  sub    %ebx,%esi
  movslq %ebx,%rax
  lea    (%r14,%rax,4),%rdi
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    %ebx,%edx
  call   <sorter_grail_build_blocks@plt>
  mov    %ebx,0x14(%rsp)
  mov    %ebx,%r8d
  mov    %ebx,%r13d
  mov    $0x0,%r15d
  mov    $0x0,%ebx
  jmp    L38
L23:
  call   <sorter_binary_insertion_sort@plt>
  jmp    L66
L41:
  mov    %ebp,%esi
  mov    %r14,%rdi
  call   <sorter_grail_lazy_stable_sort@plt>
  jmp    L66
L2:
  mov    $0x1,%esi
  jmp    L112
L160:
  mov    %ebx,%r8d
  mov    $0x1,%r9d
  cmp    0x10(%rsp),%ebx
  mov    $0x0,%edx
  cmovle 0x8(%rsp),%rdx
L165:
  sub    $0x8,%rsp
  push   %rdx
  mov    %r12d,%ecx
  mov    %ebp,%edx
  mov    0x10(%rsp),%rsi
  mov    %r14,%rdi
  call   <sorter_grail_combine_blocks@plt>
  lea    (%r12,%r12,1),%edx
  mov    %r12d,%r8d
  add    $0x10,%rsp
  cmp    %ebp,%edx
  jge    L135
  mov    %edx,%r12d
L9:
  test   %r15d,%r15d
  jne    L160
  cmp    $0x4,%r13d
  jle    L93
  cmp    %r12d,0x18(%rsp)
  jge    L160
L93:
  movslq %r12d,%rax
  movslq 0x1c(%rsp),%rdx
  imul   %rdx,%rax
  mov    %rax,%rdx
  shr    $0x3f,%rdx
  add    %rdx,%rax
  sar    %rax
  mov    %rax,%rdx
  cmp    $0x1,%r13d
  jle    L2
  test   %rax,%rax
  je     L2
  mov    $0x1,%esi
L106:
  add    %esi,%esi
  lea    0x7(%rdx),%rax
  test   %rdx,%rdx
  cmovns %rdx,%rax
  sar    $0x3,%rax
  mov    %rax,%rdx
  cmp    %r13d,%esi
  jge    L112
  test   %rax,%rax
  jne    L106
L112:
  shl    $0x2,%r8d
  mov    %r8d,%eax
  cltd
  idiv   %esi
  mov    %eax,%r8d
  mov    %r15d,%r9d
  mov    $0x0,%edx
  jmp    L165
L135:
  mov    0x14(%rsp),%ebx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <sorter_binary_insertion_sort@plt>
  mov    %ebp,%edx
  mov    %ebx,%esi
  mov    %r14,%rdi
  call   <sorter_grail_merge_without_buffer@plt>
L66:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L124:
  mov    %ebp,%esi
  mov    0x14(%rsp),%eax
  sub    %eax,%esi
  cltq
  lea    (%r14,%rax,4),%rdi
  mov    0x10(%rsp),%r8d
  mov    0x8(%rsp),%rcx
  mov    %ebx,%edx
  call   <sorter_grail_build_blocks@plt>
  mov    %ebx,%r8d
  mov    $0x1,%r15d
L38:
  mov    0x14(%rsp),%edi
  sub    %edi,%ebp
  lea    (%r8,%r8,1),%r12d
  cmp    %r12d,%ebp
  jle    L135
  lea    0x7(%r13),%eax
  test   %r13d,%r13d
  cmovns %r13d,%eax
  sar    $0x3,%eax
  imul   %r13d,%eax
  mov    %eax,0x18(%rsp)
  mov    %r13d,%eax
  shr    $0x1f,%eax
  add    %r13d,%eax
  sar    %eax
  test   %r15d,%r15d
  cmove  %eax,%ebx
  movslq %edi,%rax
  lea    (%r14,%rax,4),%rax
  mov    %rax,(%rsp)
  jmp    L9
```

assistant: ```c
void sorter_grail_common_sort(int64_t *arr, int Len, int64_t *extbuf, int LExtBuf) {
  int lblock, nkeys, findkeys, ptr, cbuf, lb, nk;
  int havebuf, chavebuf;
  long long s;
  if (Len < 16) {
    sorter_binary_insertion_sort(arr, Len);
    return;
  }
  lblock = 1;
  while (lblock * lblock < Len) {
    lblock *= 2;
  }
  nkeys = (Len - 1) / lblock + 1;
  findkeys = sorter_grail_find_keys(arr, Len, nkeys + lblock);
  havebuf = 1;
  if (findkeys < nkeys + lblock) {
    if (findkeys < 4) {
      sorter_grail_lazy_stable_sort(arr, Len);
      return;
    }
    nkeys = lblock;
    while (nkeys > findkeys) {
      nkeys /= 2;
    }
    havebuf = 0;
    lblock = 0;
  }
  ptr = lblock + nkeys;
  cbuf = havebuf ? lblock : nkeys;
  if (havebuf) {
    sorter_grail_build_blocks(arr + ptr, Len - ptr, cbuf, extbuf, LExtBuf);
  } else {
    sorter_grail_build_blocks(arr + ptr, Len - ptr, cbuf, NULL, 0);
  }
  while (Len - ptr > (cbuf *= 2)) {
    lb = lblock;
    chavebuf = havebuf;
    if (!havebuf) {
      if (nkeys > 4 && nkeys / 8 * nkeys >= cbuf) {
        lb = nkeys / 2;
        chavebuf = 1;
      } else {
        nk = 1;
        s = (long long)cbuf * findkeys / 2;
        while (nk < nkeys && s != 0) {
          nk *= 2;
          s /= 8;
        }
        lb = (2 * cbuf) / nk;
      }
    }
    sorter_grail_combine_blocks(arr, arr + ptr, Len - ptr, cbuf, lb, chavebuf, chavebuf && lb <= LExtBuf ? extbuf : NULL);
  }
  sorter_binary_insertion_sort(arr, ptr);
  sorter_grail_merge_without_buffer(arr, ptr, Len - ptr);
}
```