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

```asm
<stable_grail_build_blocks>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%rbp
  mov    %esi,0x10(%rsp)
  mov    %edx,0x14(%rsp)
  mov    %rcx,0x20(%rsp)
  cmp    %edx,%r8d
  cmovg  %edx,%r8d
  mov    %r8d,%eax
L176:
  mov    %eax,%ecx
  lea    -0x1(%rax),%edx
  and    %edx,%eax
  jne    L176
  mov    %eax,0x18(%rsp)
  mov    %ecx,0x1c(%rsp)
  test   %ecx,%ecx
  jne    L264
  cmpl   $0x1,0x10(%rsp)
  jle    L18
  lea    -0x10(%rbp),%rbx
  mov    0x10(%rsp),%eax
  lea    -0x2(%rax),%r14d
  and    $0xfffffffe,%r14d
  add    $0x3,%r14d
  mov    $0x1,%r12d
L303:
  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
  call   <stable_grail_swap1@plt>
  mov    %r12d,%eax
  sub    %r13d,%eax
  cltq
  lea    0x0(%rbp,%rax,8),%rsi
  lea    0x8(%rbx),%rdi
  call   <stable_grail_swap1@plt>
  add    $0x2,%r12d
  add    $0x10,%rbx
  cmp    %r14d,%r12d
  jne    L303
L18:
  testb  $0x1,0x10(%rsp)
  jne    L61
L172:
  lea    -0x10(%rbp),%rax
  mov    %rax,0x8(%rsp)
  mov    $0x2,%r13d
L197:
  cmp    %r13d,0x14(%rsp)
  jg     L215
L160:
  mov    0x14(%rsp),%edi
  lea    (%rdi,%rdi,1),%r12d
  mov    0x10(%rsp),%eax
  cltd
  idiv   %r12d
  mov    %edx,%esi
  mov    0x10(%rsp),%eax
  sub    %edx,%eax
  mov    %eax,%ebx
  mov    %edi,%edx
  cmp    %esi,%edi
  jl     L151
  cltq
  mov    0x8(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  call   <stable_grail_rotate@plt>
L212:
  test   %ebx,%ebx
  jle    L56
  mov    %r12d,%r13d
  neg    %r13d
  movslq %r13d,%r13
  shl    $0x3,%r13
  movslq %ebx,%rax
  movslq %r12d,%rdx
  sub    %rdx,%rax
  mov    0x8(%rsp),%rdi
  lea    (%rdi,%rax,8),%rbp
  mov    0x14(%rsp),%r14d
L155:
  sub    %r12d,%ebx
  mov    %r14d,%ecx
  mov    %r14d,%edx
  mov    %r14d,%esi
  mov    %rbp,%rdi
  call   <stable_grail_merge_right@plt>
  add    %r13,%rbp
  test   %ebx,%ebx
  jg     L155
L56:
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L264:
  mov    0x1c(%rsp),%edi
  movslq %edi,%rax
  lea    0x0(,%rdi,8),%edx
  mov    %edx,0x2c(%rsp)
  shl    $0x3,%rax
  mov    %rbp,%rsi
  sub    %rax,%rsi
  mov    0x20(%rsp),%rdi
  call   <memcpy@plt>
  mov    0x10(%rsp),%esi
  cmp    $0x1,%esi
  jle    L78
  mov    $0x1,%eax
L307:
  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     L307
L78:
  mov    0x10(%rsp),%eax
  test   $0x1,%al
  je     L252
  cltq
  shl    $0x3,%rax
  mov    -0x8(%rbp,%rax,1),%rdx
  mov    %rdx,-0x18(%rbp,%rax,1)
L252:
  lea    -0x10(%rbp),%rax
  mov    %rax,0x8(%rsp)
  cmpl   $0x2,0x1c(%rsp)
  jle    L304
  mov    $0x2,%r13d
  mov    0x10(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x28(%rsp)
  jmp    L75
L188:
  mov    0x18(%rsp),%ebx
  jmp    L270
L43:
  cmp    %ebx,%eax
  jle    L85
  movslq %ebx,%rcx
  mov    0x8(%rsp),%rsi
  lea    (%rsi,%rcx,8),%rax
  mov    0x28(%rsp),%edx
  sub    %ebx,%edx
  add    %rcx,%rdx
  lea    0x8(%rsi,%rdx,8),%rsi
  movslq %ebp,%rcx
  neg    %rcx
  shl    $0x3,%rcx
L231:
  mov    (%rax),%rdx
  mov    %rdx,(%rax,%rcx,1)
  add    $0x8,%rax
  cmp    %rsi,%rax
  jne    L231
L85:
  movslq %ebp,%rbp
  shl    $0x3,%rbp
  sub    %rbp,0x8(%rsp)
  cmp    0x1c(%rsp),%r13d
  jge    L106
L75:
  mov    %r13d,%ebp
  add    %r13d,%r13d
  mov    0x10(%rsp),%r14d
  sub    %r13d,%r14d
  js     L188
  movslq %r13d,%rax
  shl    $0x3,%rax
  mov    %rax,(%rsp)
  mov    0x8(%rsp),%r12
  mov    0x18(%rsp),%ebx
  mov    %ebp,%r15d
  neg    %r15d
L21:
  mov    %r15d,%ecx
  mov    %ebp,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <stable_grail_merge_left_with_x_buf@plt>
  add    %r13d,%ebx
  add    (%rsp),%r12
  cmp    %ebx,%r14d
  jge    L21
L270:
  mov    0x10(%rsp),%eax
  mov    %eax,%edx
  sub    %ebx,%edx
  cmp    %ebp,%edx
  jle    L43
  mov    %ebp,%ecx
  neg    %ecx
  sub    %ebp,%edx
  movslq %ebx,%rbx
  mov    0x8(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  call   <stable_grail_merge_left_with_x_buf@plt>
  jmp    L85
L304:
  mov    $0x2,%r13d
L106:
  movslq 0x10(%rsp),%rax
  mov    0x8(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  mov    0x2c(%rsp),%edx
  mov    0x20(%rsp),%rsi
  call   <memcpy@plt>
  jmp    L197
L61:
  movslq 0x10(%rsp),%rax
  shl    $0x3,%rax
  lea    -0x18(%rbp,%rax,1),%rsi
  lea    -0x8(%rbp,%rax,1),%rdi
  call   <stable_grail_swap1@plt>
  jmp    L172
L98:
  mov    0x18(%rsp),%ebx
  jmp    L289
L232:
  movslq %ebx,%rbx
  movslq %ebp,%rax
  sub    %rax,%rbx
  mov    0x8(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  call   <stable_grail_rotate@plt>
L262:
  movslq %ebp,%rbp
  shl    $0x3,%rbp
  sub    %rbp,0x8(%rsp)
  cmp    0x14(%rsp),%r13d
  jge    L160
L215:
  mov    %r13d,%ebp
  add    %r13d,%r13d
  mov    0x10(%rsp),%r14d
  sub    %r13d,%r14d
  js     L98
  movslq %r13d,%rax
  shl    $0x3,%rax
  mov    %rax,(%rsp)
  mov    0x8(%rsp),%r12
  mov    0x18(%rsp),%ebx
  mov    %ebp,%r15d
  neg    %r15d
L88:
  mov    %r15d,%ecx
  mov    %ebp,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <stable_grail_merge_left@plt>
  add    %r13d,%ebx
  add    (%rsp),%r12
  cmp    %ebx,%r14d
  jge    L88
L289:
  mov    0x10(%rsp),%edx
  sub    %ebx,%edx
  cmp    %ebp,%edx
  jle    L232
  mov    %ebp,%ecx
  neg    %ecx
  sub    %ebp,%edx
  movslq %ebx,%rbx
  mov    0x8(%rsp),%rax
  lea    (%rax,%rbx,8),%rdi
  mov    %ebp,%esi
  call   <stable_grail_merge_left@plt>
  jmp    L262
L151:
  mov    0x14(%rsp),%ecx
  sub    %ecx,%esi
  mov    %esi,%edx
  cltq
  mov    0x8(%rsp),%rdi
  lea    (%rdi,%rax,8),%rdi
  mov    %ecx,%esi
  call   <stable_grail_merge_right@plt>
  jmp    L212
```

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