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

```asm
<sorter_grail_build_blocks>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %edx,-0x40(%rbp)
  mov    %rcx,-0x48(%rbp)
  mov    %r8d,-0x4c(%rbp)
  mov    -0x4c(%rbp),%edx
  mov    -0x40(%rbp),%eax
  cmp    %eax,%edx
  cmovle %edx,%eax
  mov    %eax,-0x10(%rbp)
  jmp    L137
L86:
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  and    %eax,-0x10(%rbp)
L137:
  mov    -0x10(%rbp),%eax
  sub    $0x1,%eax
  and    -0x10(%rbp),%eax
  test   %eax,%eax
  jne    L86
  cmpl   $0x0,-0x10(%rbp)
  je     L135
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x3,%rax
  neg    %rax
  mov    %rax,%rcx
  mov    -0x38(%rbp),%rax
  add    %rax,%rcx
  mov    -0x48(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  movl   $0x1,-0x24(%rbp)
  jmp    L259
L155:
  movl   $0x0,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rdx
  sub    %rdx,%rax
  test   %rax,%rax
  jle    L139
  movl   $0x1,-0x20(%rbp)
L139:
  mov    -0x24(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x18(%rdx),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  mov    -0x24(%rbp),%eax
  sub    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x10(%rdx),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  addl   $0x2,-0x24(%rbp)
L259:
  mov    -0x24(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L155
  mov    -0x3c(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L219
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0x3c(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x18(%rdx),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
L219:
  subq   $0x10,-0x38(%rbp)
  movl   $0x2,-0x1c(%rbp)
  jmp    L285
L193:
  movl   $0x0,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x3c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L167
L224:
  mov    -0x1c(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x1c(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_left_with_x_buf@plt>
  mov    -0x1c(%rbp),%eax
  add    %eax,%eax
  add    %eax,-0x18(%rbp)
L167:
  mov    -0x18(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jle    L224
  mov    -0x3c(%rbp),%eax
  sub    -0x18(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L0
  mov    -0x1c(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rsi
  mov    -0x38(%rbp),%rax
  lea    (%rsi,%rax,1),%rdi
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_left_with_x_buf@plt>
  jmp    L200
L7:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%rax
  mov    %rax,(%rdx)
  addl   $0x1,-0x18(%rbp)
L0:
  mov    -0x18(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L7
L200:
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  neg    %rax
  add    %rax,-0x38(%rbp)
  shll   -0x1c(%rbp)
L285:
  mov    -0x1c(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L193
  mov    -0x10(%rbp),%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edx
  mov    -0x3c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x38(%rbp),%rax
  add    %rax,%rcx
  mov    -0x48(%rbp),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  jmp    L4
L135:
  movl   $0x1,-0x24(%rbp)
  jmp    L148
L152:
  movl   $0x0,-0x20(%rbp)
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x38(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rdx),%rdx
  sub    %rdx,%rax
  test   %rax,%rax
  jle    L236
  movl   $0x1,-0x20(%rbp)
L236:
  mov    -0x24(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x20(%rbp),%eax
  add    %edx,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x18(%rax),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sorter_grail_swap1@plt>
  mov    -0x24(%rbp),%eax
  sub    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x24(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x10(%rax),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sorter_grail_swap1@plt>
  addl   $0x2,-0x24(%rbp)
L148:
  mov    -0x24(%rbp),%eax
  cmp    -0x3c(%rbp),%eax
  jl     L152
  mov    -0x3c(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L34
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x18(%rax),%rdx
  mov    -0x38(%rbp),%rax
  add    %rax,%rdx
  mov    -0x3c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x38(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <sorter_grail_swap1@plt>
L34:
  subq   $0x10,-0x38(%rbp)
  movl   $0x2,-0x1c(%rbp)
  jmp    L4
L190:
  movl   $0x0,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x3c(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L57
L108:
  mov    -0x1c(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x1c(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_left@plt>
  mov    -0x1c(%rbp),%eax
  add    %eax,%eax
  add    %eax,-0x18(%rbp)
L57:
  mov    -0x18(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jle    L108
  mov    -0x3c(%rbp),%eax
  sub    -0x18(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jle    L264
  mov    -0x1c(%rbp),%eax
  neg    %eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rsi
  mov    -0x38(%rbp),%rax
  lea    (%rsi,%rax,1),%rdi
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_left@plt>
  jmp    L277
L264:
  mov    -0x18(%rbp),%eax
  cltq
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  mov    %rcx,%rdi
  call   <sorter_grail_rotate@plt>
L277:
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  neg    %rax
  add    %rax,-0x38(%rbp)
  shll   -0x1c(%rbp)
L4:
  mov    -0x1c(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jl     L190
  mov    -0x40(%rbp),%eax
  lea    (%rax,%rax,1),%ecx
  mov    -0x3c(%rbp),%eax
  cltd
  idiv   %ecx
  mov    %edx,-0x4(%rbp)
  mov    -0x3c(%rbp),%eax
  sub    -0x4(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x4(%rbp),%eax
  cmp    -0x40(%rbp),%eax
  jg     L143
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x40(%rbp),%edx
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  mov    %rcx,%rdi
  call   <sorter_grail_rotate@plt>
  jmp    L170
L143:
  mov    -0x4(%rbp),%eax
  sub    -0x40(%rbp),%eax
  mov    %eax,%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x38(%rbp),%rax
  lea    (%rcx,%rax,1),%rdi
  mov    -0x40(%rbp),%ecx
  mov    -0x40(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_right@plt>
  jmp    L170
L195:
  mov    -0x40(%rbp),%eax
  add    %eax,%eax
  sub    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x38(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x40(%rbp),%ecx
  mov    -0x40(%rbp),%edx
  mov    -0x40(%rbp),%eax
  mov    %eax,%esi
  call   <sorter_grail_merge_right@plt>
L170:
  cmpl   $0x0,-0x14(%rbp)
  jg     L195
  nop
  nop
  leave
  ret
```

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