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

```asm
<stable_grail_common_sort>:
  endbr64
  push   %r15
  mov    $0x1,%r9d
  push   %r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdx,0x8(%rsp)
  mov    %ecx,0x10(%rsp)
  cmp    $0xf,%esi
  jle    L76
L93:
  add    %r9d,%r9d
  mov    %r9d,%eax
  imul   %r9d,%eax
  cmp    %r12d,%eax
  jl     L93
  lea    -0x1(%r12),%eax
  mov    %r12d,%esi
  mov    %rbp,%rdi
  mov    %r9d,0x4(%rsp)
  cltd
  idiv   %r9d
  lea    0x1(%rax),%r15d
  lea    (%r15,%r9,1),%ecx
  mov    %ecx,%edx
  mov    %ecx,%ebx
  mov    %ecx,0x1c(%rsp)
  call   <stable_grail_find_keys@plt>
  mov    0x4(%rsp),%r9d
  cmp    %eax,%ebx
  mov    %eax,0x14(%rsp)
  jg     L147
  movslq %ebx,%rax
  mov    0x10(%rsp),%r8d
  mov    0x8(%rsp),%rcx
  sub    %ebx,%r12d
  mov    %r9d,%edx
  lea    0x0(%rbp,%rax,8),%rdi
  mov    %r12d,%esi
  call   <stable_grail_build_blocks@plt>
  mov    0x4(%rsp),%r9d
  movl   $0x1,0x4(%rsp)
  mov    %r9d,%eax
L54:
  lea    (%r9,%r9,1),%r13d
  cmp    %r12d,%r13d
  jge    L103
  mov    %r15d,%edx
  mov    0x4(%rsp),%edi
  mov    %r15d,%ebx
  sar    $0x3,%edx
  sar    %ebx
  imul   %r15d,%edx
  test   %edi,%edi
  cmovne %eax,%ebx
  movslq 0x1c(%rsp),%rax
  lea    0x0(%rbp,%rax,8),%r14
  mov    %r15d,%eax
  mov    %edx,0x18(%rsp)
  mov    %r13d,%r15d
  mov    %eax,%r13d
  jmp    L99
  nopw   0x0(%rax,%rax,1)
L46:
  cmp    %r15d,0x18(%rsp)
  jl     L50
L110:
  xor    %edx,%edx
  cmp    0x10(%rsp),%ebx
  cmovle 0x8(%rsp),%rdx
  mov    %ebx,%r8d
  mov    $0x1,%r9d
L42:
  sub    $0x8,%rsp
  mov    %r15d,%ecx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  push   %rdx
  mov    %r12d,%edx
  call   <stable_grail_combine_blocks@plt>
  lea    (%r15,%r15,1),%eax
  pop    %rdx
  mov    %r15d,%r9d
  pop    %rcx
  cmp    %r12d,%eax
  jge    L103
  mov    %eax,%r15d
L99:
  mov    0x4(%rsp),%esi
  test   %esi,%esi
  jne    L110
  cmp    $0x4,%r13d
  jg     L46
L50:
  movslq 0x14(%rsp),%rdx
  movslq %r15d,%rax
  mov    $0x1,%edi
  imul   %rdx,%rax
  mov    %rax,%rdx
  shr    $0x3f,%rdx
  add    %rax,%rdx
  sar    %rdx
  je     L77
  cmp    $0x1,%r13d
  jle    L77
  nopl   0x0(%rax,%rax,1)
L98:
  add    %edi,%edi
  lea    0x7(%rdx),%rax
  test   %rdx,%rdx
  cmovs  %rax,%rdx
  sar    $0x3,%rdx
  cmp    %r13d,%edi
  jge    L77
  test   %rdx,%rdx
  jne    L98
L77:
  lea    0x0(,%r9,4),%eax
  xor    %r9d,%r9d
  cltd
  idiv   %edi
  xor    %edx,%edx
  mov    %eax,%r8d
  jmp    L42
  nopl   0x0(%rax,%rax,1)
L147:
  mov    0x14(%rsp),%eax
  cmp    $0x3,%eax
  jle    L62
  cmp    %r9d,%eax
  jge    L91
  mov    0x14(%rsp),%eax
  xchg   %ax,%ax
L133:
  sar    %r9d
  cmp    %r9d,%eax
  jl     L133
L91:
  sub    %r9d,%r12d
  movslq %r9d,%rax
  mov    %r9d,%edx
  xor    %r8d,%r8d
  lea    0x0(%rbp,%rax,8),%rdi
  xor    %ecx,%ecx
  mov    %r12d,%esi
  mov    %r9d,0x4(%rsp)
  call   <stable_grail_build_blocks@plt>
  mov    0x4(%rsp),%r9d
  xor    %eax,%eax
  movl   $0x0,0x4(%rsp)
  mov    %r9d,0x1c(%rsp)
  mov    %r9d,%r15d
  jmp    L54
  nopl   0x0(%rax)
L103:
  mov    0x1c(%rsp),%ebx
  mov    %rbp,%rdi
  mov    %ebx,%esi
  call   <stable_binary_insertion_sort@plt>
  add    $0x28,%rsp
  mov    %r12d,%edx
  mov    %ebx,%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10f0 <stable_grail_merge_without_buffer@plt>
  nopl   0x0(%rax)
L76:
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10d0 <stable_binary_insertion_sort@plt>
L62:
  add    $0x28,%rsp
  mov    %r12d,%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <stable_grail_lazy_stable_sort@plt>
```

assistant: ```c
void stable_grail_common_sort(int **arr, int Len, int **extbuf, int LExtBuf) {
  int lblock, nkeys, findkeys, ptr, cbuf, lb, nk;
  int havebuf, chavebuf;
  long long s;
  if (Len < 16) {
    stable_binary_insertion_sort(arr, Len);
    return;
  }
  lblock = 1;
  while (lblock * lblock < Len) {
    lblock *= 2;
  }
  nkeys = (Len - 1) / lblock + 1;
  findkeys = stable_grail_find_keys(arr, Len, nkeys + lblock);
  havebuf = 1;
  if (findkeys < nkeys + lblock) {
    if (findkeys < 4) {
      stable_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) {
    stable_grail_build_blocks(arr + ptr, Len - ptr, cbuf, extbuf, LExtBuf);
  } else {
    stable_grail_build_blocks(arr + ptr, Len - ptr, cbuf, 0, 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;
      }
    }
    stable_grail_combine_blocks(arr, arr + ptr, Len - ptr, cbuf, lb, chavebuf, chavebuf && lb <= LExtBuf ? extbuf : 0);
  }
  stable_binary_insertion_sort(arr, ptr);
  stable_grail_merge_without_buffer(arr, ptr, Len - ptr);
}
```