user: 请将以下的汇编代码转换成C语言代码:

```asm
<stable_grail_build_blocks>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%rbp
  mov    %esi,0x1c(%rsp)
  mov    %edx,0x20(%rsp)
  mov    %rcx,0x28(%rsp)
  cmp    %edx,%r8d
  cmovg  %edx,%r8d
  mov    %r8d,%eax
L253:
  mov    %eax,%ecx
  lea    -0x1(%rax),%edx
  and    %edx,%eax
  jne    L253
  mov    %eax,0x24(%rsp)
  mov    %ecx,0x30(%rsp)
  test   %ecx,%ecx
  jne    L180
  cmpl   $0x1,0x1c(%rsp)
  jle    L272
  lea    -0x10(%rbp),%rbx
  mov    0x1c(%rsp),%eax
  lea    -0x2(%rax),%r14d
  and    $0xfffffffe,%r14d
  add    $0x3,%r14d
  mov    $0x1,%r12d
L119:
  mov    0x10(%rbx),%rdx
  mov    0x18(%rbx),%rax
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  setg   %r13b
  movzbl %r13b,%r13d
  lea    -0x1(%r12,%r13,1),%eax
  cltq
  lea    0x0(%rbp,%rax,8),%rsi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap1@plt>
  mov    %r12d,%eax
  sub    %r13d,%eax
  cltq
  lea    0x0(%rbp,%rax,8),%rsi
  lea    0x8(%rbx),%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap1@plt>
  add    $0x2,%r12d
  add    $0x10,%rbx
  cmp    %r14d,%r12d
  jne    L119
L272:
  testb  $0x1,0x1c(%rsp)
  jne    L124
L186:
  lea    -0x10(%rbp),%rax
  mov    %rax,0x10(%rsp)
  mov    $0x2,%r13d
L94:
  cmp    %r13d,0x20(%rsp)
  jg     L237
L207:
  mov    0x20(%rsp),%edi
  lea    (%rdi,%rdi,1),%r12d
  mov    0x1c(%rsp),%eax
  cltd
  idiv   %r12d
  mov    %edx,%esi
  mov    0x1c(%rsp),%eax
  sub    %edx,%eax
  mov    %eax,%ebx
  mov    %edi,%edx
  cmp    %esi,%edi
  jl     L23
  cltq
  mov    0x10(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  mov    $0x0,%eax
  call   <stable_grail_rotate@plt>
L89:
  test   %ebx,%ebx
  jle    L243
  mov    %r12d,%r13d
  neg    %r13d
  movslq %r13d,%r13
  shl    $0x3,%r13
  movslq %ebx,%rax
  movslq %r12d,%rdx
  sub    %rdx,%rax
  mov    0x10(%rsp),%rdi
  lea    (%rdi,%rax,8),%rbp
  mov    0x20(%rsp),%r14d
L136:
  sub    %r12d,%ebx
  mov    %r14d,%ecx
  mov    %r14d,%edx
  mov    %r14d,%esi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <stable_grail_merge_right@plt>
  add    %r13,%rbp
  test   %ebx,%ebx
  jg     L136
L243:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L180:
  movslq 0x30(%rsp),%rax
  lea    0x0(,%rax,8),%rdx
  mov    %rdx,0x38(%rsp)
  mov    %rbp,%rsi
  sub    %rdx,%rsi
  mov    0x28(%rsp),%rdi
  call   <memcpy@plt>
  mov    0x1c(%rsp),%esi
  cmp    $0x1,%esi
  jle    L284
  mov    $0x1,%eax
L228:
  mov    -0x8(%rbp,%rax,8),%rcx
  mov    0x0(%rbp,%rax,8),%rdx
  mov    (%rdx),%edi
  cmp    %edi,(%rcx)
  setg   %cl
  movzbl %cl,%ecx
  lea    -0x1(%rcx,%rax,1),%edx
  movslq %edx,%rdx
  mov    0x0(%rbp,%rdx,8),%rdx
  mov    %rdx,-0x18(%rbp,%rax,8)
  mov    %eax,%edx
  sub    %ecx,%edx
  movslq %edx,%rdx
  mov    0x0(%rbp,%rdx,8),%rdx
  mov    %rdx,-0x10(%rbp,%rax,8)
  add    $0x2,%rax
  cmp    %eax,%esi
  jg     L228
L284:
  mov    0x1c(%rsp),%eax
  test   $0x1,%al
  je     L256
  cltq
  shl    $0x3,%rax
  mov    -0x8(%rbp,%rax,1),%rdx
  mov    %rdx,-0x18(%rbp,%rax,1)
L256:
  lea    -0x10(%rbp),%rax
  mov    %rax,0x10(%rsp)
  cmpl   $0x2,0x30(%rsp)
  jle    L18
  mov    $0x2,%r13d
  mov    0x1c(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x34(%rsp)
  jmp    L262
L38:
  mov    0x24(%rsp),%ebx
  jmp    L161
L261:
  cmp    %ebx,%eax
  jle    L216
  movslq %ebx,%rcx
  mov    0x10(%rsp),%rsi
  lea    (%rsi,%rcx,8),%rax
  mov    0x34(%rsp),%edx
  sub    %ebx,%edx
  add    %rcx,%rdx
  lea    0x8(%rsi,%rdx,8),%rsi
  movslq %ebp,%rcx
  neg    %rcx
  shl    $0x3,%rcx
L267:
  mov    (%rax),%rdx
  mov    %rdx,(%rax,%rcx,1)
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L267
L216:
  movslq %ebp,%rbp
  shl    $0x3,%rbp
  sub    %rbp,0x10(%rsp)
  cmp    0x30(%rsp),%r13d
  jge    L66
L262:
  mov    %r13d,%ebp
  add    %r13d,%r13d
  mov    0x1c(%rsp),%r14d
  sub    %r13d,%r14d
  js     L38
  movslq %r13d,%rax
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  mov    0x10(%rsp),%r12
  mov    0x24(%rsp),%ebx
  mov    %ebp,%r15d
  neg    %r15d
L201:
  mov    %r15d,%ecx
  mov    %ebp,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <stable_grail_merge_left_with_x_buf@plt>
  add    %r13d,%ebx
  add    0x8(%rsp),%r12
  cmp    %ebx,%r14d
  jge    L201
L161:
  mov    0x1c(%rsp),%eax
  mov    %eax,%edx
  sub    %ebx,%edx
  cmp    %ebp,%edx
  jle    L261
  mov    %ebp,%ecx
  neg    %ecx
  sub    %ebp,%edx
  movslq %ebx,%rbx
  mov    0x10(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  mov    $0x0,%eax
  call   <stable_grail_merge_left_with_x_buf@plt>
  jmp    L216
L18:
  mov    $0x2,%r13d
L66:
  movslq 0x1c(%rsp),%rax
  mov    0x10(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  mov    0x38(%rsp),%rdx
  mov    0x28(%rsp),%rsi
  call   <memcpy@plt>
  jmp    L94
L124:
  movslq 0x1c(%rsp),%rax
  shl    $0x3,%rax
  lea    -0x18(%rbp,%rax,1),%rsi
  lea    -0x8(%rbp,%rax,1),%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap1@plt>
  jmp    L186
L7:
  mov    0x24(%rsp),%ebx
  jmp    L85
L169:
  movslq %ebx,%rbx
  movslq %ebp,%rax
  sub    %rax,%rbx
  mov    0x10(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  mov    $0x0,%eax
  call   <stable_grail_rotate@plt>
L281:
  movslq %ebp,%rbp
  shl    $0x3,%rbp
  sub    %rbp,0x10(%rsp)
  cmp    0x20(%rsp),%r13d
  jge    L207
L237:
  mov    %r13d,%ebp
  add    %r13d,%r13d
  mov    0x1c(%rsp),%r14d
  sub    %r13d,%r14d
  js     L7
  movslq %r13d,%rax
  shl    $0x3,%rax
  mov    %rax,0x8(%rsp)
  mov    0x10(%rsp),%r12
  mov    0x24(%rsp),%ebx
  mov    %ebp,%r15d
  neg    %r15d
L175:
  mov    %r15d,%ecx
  mov    %ebp,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <stable_grail_merge_left@plt>
  add    %r13d,%ebx
  add    0x8(%rsp),%r12
  cmp    %ebx,%r14d
  jge    L175
L85:
  mov    0x1c(%rsp),%edx
  sub    %ebx,%edx
  cmp    %ebp,%edx
  jle    L169
  mov    %ebp,%ecx
  neg    %ecx
  sub    %ebp,%edx
  movslq %ebx,%rbx
  mov    0x10(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  mov    $0x0,%eax
  call   <stable_grail_merge_left@plt>
  jmp    L281
L23:
  mov    0x20(%rsp),%ecx
  sub    %ecx,%esi
  mov    %esi,%edx
  cltq
  mov    0x10(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  mov    %ecx,%esi
  mov    $0x0,%eax
  call   <stable_grail_merge_right@plt>
  jmp    L89
```

assistant: ```c
void stable_grail_build_blocks(int **arr, int L, int K, int **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(int *));
    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) {
        stable_grail_merge_left_with_x_buf(arr + p0, h, h, -h);
        p0 += 2 * h;
      }
      rest = L - p0;
      if (rest > h) {
        stable_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(int *));
  } else {
    for (m = 1; m < L; m += 2) {
      u = 0;
      if ((*(*(arr + (m - 1))) - *(*(arr + m))) > 0) {
        u = 1;
      }
      stable_grail_swap1(arr + (m - 3), arr + (m - 1 + u));
      stable_grail_swap1(arr + (m - 2), arr + (m - u));
    }
    if (L % 2) {
      stable_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) {
      stable_grail_merge_left(arr + p0, h, h, -h);
      p0 += 2 * h;
    }
    rest = L - p0;
    if (rest > h) {
      stable_grail_merge_left(arr + p0, h, rest - h, -h);
    } else {
      stable_grail_rotate(arr + p0 - h, h, rest);
    }
    arr -= h;
  }
  restk = L % (2 * K);
  p = L - restk;
  if (restk <= K) {
    stable_grail_rotate(arr + p, restk, K);
  } else {
    stable_grail_merge_right(arr + p, K, restk - K, K);
  }
  while (p > 0) {
    p -= 2 * K;
    stable_grail_merge_right(arr + p, K, K, K);
  }
}
```