user: Translate the below assembly code into C programming language:

```asm
<sorter_grail_common_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %ecx,-0x40(%rbp)
  cmpl   $0xf,-0x3c(%rbp)
  jg     L131
  mov    -0x3c(%rbp),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <sorter_binary_insertion_sort@plt>
  jmp    L212
L131:
  movl   $0x1,-0x2c(%rbp)
  jmp    L101
L28:
  shll   -0x2c(%rbp)
L101:
  mov    -0x2c(%rbp),%eax
  imul   %eax,%eax
  cmp    %eax,-0x3c(%rbp)
  jg     L28
  mov    -0x3c(%rbp),%eax
  sub    $0x1,%eax
  cltd
  idivl  -0x2c(%rbp)
  add    $0x1,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x28(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  add    %eax,%edx
  mov    -0x3c(%rbp),%ecx
  mov    -0x38(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <sorter_grail_find_keys@plt>
  mov    %eax,-0x10(%rbp)
  movl   $0x1,-0x18(%rbp)
  mov    -0x28(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  add    %edx,%eax
  cmp    %eax,-0x10(%rbp)
  jge    L236
  cmpl   $0x3,-0x10(%rbp)
  jg     L140
  mov    -0x3c(%rbp),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <sorter_grail_lazy_stable_sort@plt>
  jmp    L212
L140:
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x28(%rbp)
  jmp    L181
L147:
  mov    -0x28(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x28(%rbp)
L181:
  mov    -0x28(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jg     L147
  movl   $0x0,-0x18(%rbp)
  movl   $0x0,-0x2c(%rbp)
L236:
  mov    -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  je     L219
  mov    -0x2c(%rbp),%eax
  jmp    L186
L219:
  mov    -0x28(%rbp),%eax
L186:
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  je     L183
  mov    -0x3c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x40(%rbp),%esi
  mov    -0x48(%rbp),%rcx
  mov    -0x24(%rbp),%edx
  mov    %esi,%r8d
  mov    %eax,%esi
  call   <sorter_grail_build_blocks@plt>
  jmp    L22
L183:
  mov    -0x3c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x38(%rbp),%rdx
  lea    (%rcx,%rdx,1),%rdi
  mov    -0x24(%rbp),%edx
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    %eax,%esi
  call   <sorter_grail_build_blocks@plt>
  jmp    L22
L5:
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x18(%rbp)
  jne    L62
  cmpl   $0x4,-0x28(%rbp)
  jle    L72
  mov    -0x28(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  imul   -0x28(%rbp),%eax
  cmp    %eax,-0x24(%rbp)
  jg     L72
  mov    -0x28(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x20(%rbp)
  movl   $0x1,-0x14(%rbp)
  jmp    L62
L72:
  movl   $0x1,-0x1c(%rbp)
  mov    -0x24(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%eax
  cltq
  imul   %rdx,%rax
  mov    %rax,%rdx
  shr    $0x3f,%rdx
  add    %rdx,%rax
  sar    %rax
  mov    %rax,-0x8(%rbp)
  jmp    L188
L220:
  shll   -0x1c(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x7(%rax),%rdx
  test   %rax,%rax
  cmovs  %rdx,%rax
  sar    $0x3,%rax
  mov    %rax,-0x8(%rbp)
L188:
  mov    -0x1c(%rbp),%eax
  cmp    -0x28(%rbp),%eax
  jge    L175
  cmpq   $0x0,-0x8(%rbp)
  jne    L220
L175:
  mov    -0x24(%rbp),%eax
  add    %eax,%eax
  cltd
  idivl  -0x1c(%rbp)
  mov    %eax,-0x20(%rbp)
L62:
  cmpl   $0x0,-0x14(%rbp)
  je     L120
  mov    -0x20(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jg     L120
  mov    -0x48(%rbp),%rsi
  jmp    L84
L120:
  mov    $0x0,%esi
L84:
  mov    -0x3c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x38(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x14(%rbp),%r9d
  mov    -0x20(%rbp),%r8d
  mov    -0x24(%rbp),%ecx
  mov    -0x38(%rbp),%rax
  sub    $0x8,%rsp
  push   %rsi
  mov    %rdi,%rsi
  mov    %rax,%rdi
  call   <sorter_grail_combine_blocks@plt>
  add    $0x10,%rsp
L22:
  mov    -0x3c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  shll   -0x24(%rbp)
  cmp    %eax,-0x24(%rbp)
  jl     L5
  mov    -0xc(%rbp),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <sorter_binary_insertion_sort@plt>
  mov    -0x3c(%rbp),%eax
  sub    -0xc(%rbp),%eax
  mov    %eax,%edx
  mov    -0xc(%rbp),%ecx
  mov    -0x38(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <sorter_grail_merge_without_buffer@plt>
L212:
  leave
  ret
```

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