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

```asm
<sorter_grail_build_blocks>:
  endbr64
  push   %r15
  mov    %r8d,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x38,%rsp
  cmp    %edx,%r8d
  mov    %esi,0x10(%rsp)
  cmovg  %edx,%eax
  mov    %edx,0x14(%rsp)
  mov    %rcx,0x18(%rsp)
  nopl   0x0(%rax,%rax,1)
L10:
  lea    -0x1(%rax),%edx
  mov    %eax,%ecx
  and    %edx,%eax
  jne    L10
  mov    %ecx,0x28(%rsp)
  test   %ecx,%ecx
  jne    L253
  cmpl   $0x1,0x10(%rsp)
  lea    -0x10(%rbx),%r14
  jle    L70
  mov    0x10(%rsp),%eax
  mov    %r14,%rbp
  mov    $0x1,%r13d
  lea    -0x2(%rax),%r12d
  and    $0xfffffffe,%r12d
  add    $0x3,%r12d
  nopl   0x0(%rax)
L104:
  mov    0x18(%rbp),%rax
  xor    %r15d,%r15d
  cmp    %rax,0x10(%rbp)
  mov    %rbp,%rdi
  setg   %r15b
  lea    -0x1(%r13,%r15,1),%eax
  cltq
  lea    (%rbx,%rax,8),%rsi
  call   <sorter_grail_swap1@plt>
  mov    %r13d,%eax
  lea    0x8(%rbp),%rdi
  add    $0x2,%r13d
  sub    %r15d,%eax
  add    $0x10,%rbp
  cltq
  lea    (%rbx,%rax,8),%rsi
  call   <sorter_grail_swap1@plt>
  cmp    %r12d,%r13d
  jne    L104
L70:
  testb  $0x1,0x10(%rsp)
  jne    L83
L244:
  mov    %r14,0x8(%rsp)
  mov    $0x2,%ebx
L25:
  cmp    0x14(%rsp),%ebx
  jge    L210
  nopl   0x0(%rax,%rax,1)
L237:
  mov    0x10(%rsp),%eax
  mov    %ebx,%r15d
  add    %ebx,%ebx
  sub    %ebx,%eax
  mov    %eax,0x4(%rsp)
  js     L21
  mov    %r15d,%r13d
  movslq %ebx,%rbp
  mov    0x8(%rsp),%r12
  xor    %r14d,%r14d
  neg    %r13d
  shl    $0x3,%rbp
  nopw   0x0(%rax,%rax,1)
L154:
  mov    %r12,%rdi
  mov    %r13d,%ecx
  mov    %r15d,%edx
  mov    %r15d,%esi
  call   <sorter_grail_merge_left@plt>
  add    %ebx,%r14d
  add    %rbp,%r12
  cmp    %r14d,0x4(%rsp)
  jge    L154
  mov    0x10(%rsp),%edx
  movslq %r14d,%rax
  sub    %r14d,%edx
L195:
  movslq %r15d,%rbp
  cmp    %edx,%r15d
  jge    L142
  mov    0x8(%rsp),%rsi
  mov    %r15d,%ecx
  sub    %r15d,%edx
  neg    %ecx
  lea    (%rsi,%rax,8),%rdi
  mov    %r15d,%esi
  call   <sorter_grail_merge_left@plt>
L158:
  shl    $0x3,%rbp
  sub    %rbp,0x8(%rsp)
  cmp    0x14(%rsp),%ebx
  jl     L237
L210:
  mov    0x10(%rsp),%eax
  mov    0x14(%rsp),%ecx
  cltd
  lea    (%rcx,%rcx,1),%r12d
  idiv   %r12d
  mov    0x10(%rsp),%eax
  sub    %edx,%eax
  mov    %edx,%esi
  movslq %eax,%rbp
  mov    0x8(%rsp),%rax
  mov    %rbp,%rbx
  lea    (%rax,%rbp,8),%rdi
  cmp    %edx,%ecx
  jl     L227
  mov    %ecx,%edx
  call   <sorter_grail_rotate@plt>
L124:
  test   %ebx,%ebx
  jle    L141
  movslq %r12d,%rax
  mov    %r12d,%r13d
  mov    0x14(%rsp),%r14d
  sub    %rax,%rbp
  neg    %r13d
  mov    0x8(%rsp),%rax
  movslq %r13d,%r13
  shl    $0x3,%r13
  lea    (%rax,%rbp,8),%rbp
  nopl   0x0(%rax,%rax,1)
L19:
  mov    %rbp,%rdi
  mov    %r14d,%ecx
  mov    %r14d,%edx
  mov    %r14d,%esi
  call   <sorter_grail_merge_right@plt>
  sub    %r12d,%ebx
  add    %r13,%rbp
  test   %ebx,%ebx
  jg     L19
L141:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L142:
  mov    0x8(%rsp),%rcx
  sub    %rbp,%rax
  mov    %r15d,%esi
  lea    (%rcx,%rax,8),%rdi
  call   <sorter_grail_rotate@plt>
  jmp    L158
  nopl   0x0(%rax)
L21:
  mov    0x10(%rsp),%edx
  xor    %eax,%eax
  jmp    L195
L83:
  movslq 0x10(%rsp),%rax
  shl    $0x3,%rax
  lea    -0x18(%rbx,%rax,1),%rsi
  lea    -0x8(%rbx,%rax,1),%rdi
  call   <sorter_grail_swap1@plt>
  jmp    L244
L227:
  mov    0x14(%rsp),%eax
  sub    %eax,%esi
  mov    %eax,%ecx
  mov    %esi,%edx
  mov    %eax,%esi
  call   <sorter_grail_merge_right@plt>
  jmp    L124
L253:
  movslq 0x28(%rsp),%rax
  mov    0x18(%rsp),%rdi
  mov    %rbx,%rsi
  lea    0x0(,%rax,8),%edx
  shl    $0x3,%rax
  sub    %rax,%rsi
  mov    %edx,0x2c(%rsp)
  call   <memcpy@plt>
  cmpl   $0x1,0x10(%rsp)
  mov    0x10(%rsp),%esi
  mov    $0x1,%eax
  jle    L132
  nopw   0x0(%rax,%rax,1)
L156:
  mov    (%rbx,%rax,8),%rdi
  xor    %ecx,%ecx
  cmp    %rdi,-0x8(%rbx,%rax,8)
  setg   %cl
  lea    -0x1(%rcx,%rax,1),%edx
  movslq %edx,%rdx
  mov    (%rbx,%rdx,8),%rdx
  mov    %rdx,-0x18(%rbx,%rax,8)
  mov    %eax,%edx
  sub    %ecx,%edx
  movslq %edx,%rdx
  mov    (%rbx,%rdx,8),%rdx
  mov    %rdx,-0x10(%rbx,%rax,8)
  add    $0x2,%rax
  cmp    %eax,%esi
  jg     L156
L132:
  movslq 0x10(%rsp),%rax
  mov    %rax,%rdi
  shl    $0x3,%rax
  and    $0x1,%edi
  mov    %rax,0x20(%rsp)
  jne    L34
L274:
  lea    -0x10(%rbx),%rax
  cmpl   $0x2,0x28(%rsp)
  mov    $0x2,%ebx
  mov    %rax,0x8(%rsp)
  jle    L302
  nopl   0x0(%rax)
L119:
  mov    0x10(%rsp),%eax
  mov    %ebx,%r15d
  add    %ebx,%ebx
  sub    %ebx,%eax
  mov    %eax,0x4(%rsp)
  js     L230
  mov    %r15d,%r13d
  movslq %ebx,%rbp
  mov    0x8(%rsp),%r12
  xor    %r14d,%r14d
  neg    %r13d
  shl    $0x3,%rbp
  mov    %r13d,%eax
  mov    %rbp,%r13
  mov    %r15d,%ebp
  mov    %eax,%r15d
  cs nopw 0x0(%rax,%rax,1)
L22:
  mov    %r12,%rdi
  mov    %r15d,%ecx
  mov    %ebp,%edx
  mov    %ebp,%esi
  call   <sorter_grail_merge_left_with_x_buf@plt>
  add    %ebx,%r14d
  add    %r13,%r12
  cmp    %r14d,0x4(%rsp)
  jge    L22
  mov    0x10(%rsp),%edx
  mov    %ebp,%r15d
  sub    %r14d,%edx
L287:
  cmp    %edx,%r15d
  jge    L50
  mov    0x8(%rsp),%rax
  mov    %r15d,%ecx
  movslq %r14d,%r8
  sub    %r15d,%edx
  neg    %ecx
  mov    %r15d,%esi
  lea    (%rax,%r8,8),%rdi
  call   <sorter_grail_merge_left_with_x_buf@plt>
L23:
  movslq %r15d,%rsi
L24:
  shl    $0x3,%rsi
  sub    %rsi,0x8(%rsp)
  cmp    0x28(%rsp),%ebx
  jl     L119
L302:
  mov    0x2c(%rsp),%edx
  mov    0x18(%rsp),%rsi
  mov    0x20(%rsp),%rdi
  add    0x8(%rsp),%rdi
  call   <memcpy@plt>
  jmp    L25
  nopw   0x0(%rax,%rax,1)
L50:
  cmp    %r14d,0x10(%rsp)
  jle    L23
  mov    0x10(%rsp),%edi
  mov    0x8(%rsp),%rsi
  movslq %r14d,%rcx
  lea    -0x1(%rdi),%edx
  lea    (%rsi,%rcx,8),%rax
  sub    %r14d,%edx
  add    %rcx,%rdx
  lea    0x8(%rsi,%rdx,8),%rdi
  movslq %r15d,%rsi
  mov    %rsi,%rcx
  neg    %rcx
  shl    $0x3,%rcx
  nopw   0x0(%rax,%rax,1)
L113:
  mov    (%rax),%rdx
  add    $0x8,%rax
  mov    %rdx,-0x8(%rax,%rcx,1)
  cmp    %rax,%rdi
  jne    L113
  jmp    L24
L230:
  mov    0x10(%rsp),%edx
  xor    %r14d,%r14d
  jmp    L287
L34:
  mov    0x20(%rsp),%rsi
  mov    -0x8(%rbx,%rsi,1),%rax
  mov    %rax,-0x18(%rbx,%rsi,1)
  jmp    L274
```

assistant: ```c
void sorter_grail_build_blocks(int64_t *arr, int L, int K, int64_t *extbuf, int LExtBuf) {
  int m, u, h, p0, p1, rest, restk, p, kbuf;
  kbuf = K < LExtBuf ? K : LExtBuf;
  while (kbuf & (kbuf - 1)) {
    kbuf &= kbuf - 1;
  }
  if (kbuf) {
    memcpy(extbuf, arr - kbuf, kbuf * sizeof(int64_t));
    for (m = 1; m < L; m += 2) {
      u = 0;
      if (((*(arr + (m - 1))) - (*(arr + m))) > 0) {
        u = 1;
      }
      arr[m - 3] = arr[m - 1 + u];
      arr[m - 2] = arr[m - u];
    }
    if (L % 2) {
      arr[L - 3] = arr[L - 1];
    }
    arr -= 2;
    for (h = 2; h < kbuf; h *= 2) {
      p0 = 0;
      p1 = L - 2 * h;
      while (p0 <= p1) {
        sorter_grail_merge_left_with_x_buf(arr + p0, h, h, -h);
        p0 += 2 * h;
      }
      rest = L - p0;
      if (rest > h) {
        sorter_grail_merge_left_with_x_buf(arr + p0, h, rest - h, -h);
      } else {
        for (; p0 < L; p0++) {
          arr[p0 - h] = arr[p0];
        }
      }
      arr -= h;
    }
    memcpy(arr + L, extbuf, kbuf * sizeof(int64_t));
  } else {
    for (m = 1; m < L; m += 2) {
      u = 0;
      if (((*(arr + (m - 1))) - (*(arr + m))) > 0) {
        u = 1;
      }
      sorter_grail_swap1(arr + (m - 3), arr + (m - 1 + u));
      sorter_grail_swap1(arr + (m - 2), arr + (m - u));
    }
    if (L % 2) {
      sorter_grail_swap1(arr + (L - 1), arr + (L - 3));
    }
    arr -= 2;
    h = 2;
  }
  for (; h < K; h *= 2) {
    p0 = 0;
    p1 = L - 2 * h;
    while (p0 <= p1) {
      sorter_grail_merge_left(arr + p0, h, h, -h);
      p0 += 2 * h;
    }
    rest = L - p0;
    if (rest > h) {
      sorter_grail_merge_left(arr + p0, h, rest - h, -h);
    } else {
      sorter_grail_rotate(arr + p0 - h, h, rest);
    }
    arr -= h;
  }
  restk = L % (2 * K);
  p = L - restk;
  if (restk <= K) {
    sorter_grail_rotate(arr + p, restk, K);
  } else {
    sorter_grail_merge_right(arr + p, K, restk - K, K);
  }
  while (p > 0) {
    p -= 2 * K;
    sorter_grail_merge_right(arr + p, K, K, K);
  }
}
```