user: Converte this assembly snippet into its equivalent C code:

```asm
<stable_grail_combine_blocks>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %rsi,-0x50(%rbp)
  mov    %edx,-0x54(%rbp)
  mov    %ecx,-0x58(%rbp)
  mov    %r8d,-0x5c(%rbp)
  mov    %r9d,-0x60(%rbp)
  mov    -0x58(%rbp),%eax
  lea    (%rax,%rax,1),%esi
  mov    -0x54(%rbp),%eax
  cltd
  idiv   %esi
  mov    %eax,-0x14(%rbp)
  mov    -0x58(%rbp),%eax
  lea    (%rax,%rax,1),%ecx
  mov    -0x54(%rbp),%eax
  cltd
  idiv   %ecx
  mov    %edx,-0x2c(%rbp)
  mov    -0x2c(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  jg     L24
  mov    -0x2c(%rbp),%eax
  sub    %eax,-0x54(%rbp)
  movl   $0x0,-0x2c(%rbp)
L24:
  cmpq   $0x0,0x10(%rbp)
  je     L329
  mov    -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x5c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  neg    %rax
  mov    %rax,%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  mov    %rax,%rsi
  mov    0x10(%rbp),%rdi
  call   <memcpy@plt>
L329:
  movl   $0x0,-0x34(%rbp)
  jmp    L49
L108:
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L121
  cmpl   $0x0,-0x2c(%rbp)
  je     L217
L121:
  mov    -0x34(%rbp),%eax
  imul   -0x58(%rbp),%eax
  add    %eax,%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L214
  mov    -0x58(%rbp),%eax
  add    %eax,%eax
  jmp    L153
L214:
  mov    -0x2c(%rbp),%eax
L153:
  cltd
  idivl  -0x5c(%rbp)
  mov    %eax,-0x10(%rbp)
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  sete   %al
  movzbl %al,%edx
  mov    -0x10(%rbp),%eax
  add    %eax,%edx
  mov    -0x48(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <stable_binary_insertion_sort@plt>
  mov    -0x58(%rbp),%eax
  cltd
  idivl  -0x5c(%rbp)
  mov    %eax,-0x30(%rbp)
  movl   $0x1,-0x28(%rbp)
  jmp    L31
L168:
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x28(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  jmp    L296
L95:
  mov    -0x24(%rbp),%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    (%rax),%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jg     L318
  cmpl   $0x0,-0xc(%rbp)
  jne    L274
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    (%rax),%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  jle    L274
L318:
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x24(%rbp)
L274:
  addl   $0x1,-0x20(%rbp)
L296:
  mov    -0x20(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L95
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x24(%rbp)
  je     L130
  mov    -0x24(%rbp),%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x5c(%rbp),%eax
  mov    %eax,%edx
  mov    %rcx,%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap_n@plt>
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  add    %rax,%rdx
  mov    -0x28(%rbp),%eax
  cltq
  shl    $0x3,%rax
  lea    -0x8(%rax),%rcx
  mov    -0x48(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap1@plt>
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x30(%rbp)
  je     L202
  mov    -0x30(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jne    L130
L202:
  mov    -0x28(%rbp),%eax
  sub    $0x1,%eax
  xor    -0x24(%rbp),%eax
  xor    %eax,-0x30(%rbp)
L130:
  addl   $0x1,-0x28(%rbp)
L31:
  mov    -0x28(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L168
  movl   $0x0,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L21
  mov    -0x2c(%rbp),%eax
  cltd
  idivl  -0x5c(%rbp)
  mov    %edx,-0x18(%rbp)
L21:
  cmpl   $0x0,-0x18(%rbp)
  je     L148
  jmp    L211
L80:
  addl   $0x1,-0x1c(%rbp)
L211:
  mov    -0x1c(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jge    L148
  mov    -0x10(%rbp),%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  imul   -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x8(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    (%rax),%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  js     L80
L148:
  cmpq   $0x0,0x10(%rbp)
  je     L177
  mov    -0x10(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x1c(%rbp),%r9d
  mov    -0x5c(%rbp),%r8d
  mov    -0x8(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  sub    $0x8,%rsp
  mov    -0x18(%rbp),%edi
  push   %rdi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <stable_grail_merge_buffers_left_with_x_buf@plt>
  add    $0x10,%rsp
  jmp    L25
L177:
  mov    -0x10(%rbp),%eax
  sub    -0x1c(%rbp),%eax
  mov    %eax,%ecx
  mov    -0x30(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rsi
  mov    -0x60(%rbp),%r9d
  mov    -0x5c(%rbp),%r8d
  mov    -0x8(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    -0x18(%rbp),%edi
  push   %rdi
  mov    -0x1c(%rbp),%edi
  push   %rdi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <stable_grail_merge_buffers_left@plt>
  add    $0x10,%rsp
L25:
  addl   $0x1,-0x34(%rbp)
L49:
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jle    L108
  jmp    L253
L217:
  nop
L253:
  cmpq   $0x0,0x10(%rbp)
  je     L52
  mov    -0x54(%rbp),%eax
  mov    %eax,-0x24(%rbp)
  jmp    L22
L205:
  mov    -0x24(%rbp),%eax
  sub    -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rdx,%rax
  mov    -0x24(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x50(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
L22:
  subl   $0x1,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jns    L205
  mov    -0x5c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x5c(%rbp),%eax
  cltq
  shl    $0x3,%rax
  neg    %rax
  mov    %rax,%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  mov    0x10(%rbp),%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  jmp    L45
L52:
  cmpl   $0x0,-0x60(%rbp)
  je     L45
  jmp    L245
L111:
  mov    -0x54(%rbp),%eax
  cltq
  mov    -0x5c(%rbp),%edx
  movslq %edx,%rdx
  sub    %rdx,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x50(%rbp),%rax
  add    %rax,%rdx
  mov    -0x54(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x50(%rbp),%rax
  add    %rcx,%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <stable_grail_swap1@plt>
L245:
  subl   $0x1,-0x54(%rbp)
  cmpl   $0x0,-0x54(%rbp)
  jns    L111
L45:
  nop
  leave
  ret
```

assistant: ```c
void stable_grail_combine_blocks(int **keys, int **arr, int len, int LL, int lblock, int havebuf, int **xbuf) {
  int M, b, NBlk, midkey, lrest, u, p, v, kc, nbl2, llast;
  int **arr1;
  M = len / (2 * LL);
  lrest = len % (2 * LL);
  if (lrest <= LL) {
    len -= lrest;
    lrest = 0;
  }
  if (xbuf) {
    memcpy((xbuf), (arr - lblock), (lblock) * sizeof(int *));
  }
  for (b = 0; b <= M; b++) {
    if (b == M && lrest == 0) {
      break;
    }
    arr1 = arr + b * 2 * LL;
    NBlk = (b == M ? lrest : 2 * LL) / lblock;
    stable_binary_insertion_sort(keys, NBlk + (b == M ? 1 : 0));
    midkey = LL / lblock;
    for (u = 1; u < NBlk; u++) {
      p = u - 1;
      for (v = u; v < NBlk; v++) {
        kc = (*(*(arr1 + p * lblock)) - *(*(arr1 + v * lblock)));
        if (kc > 0 || (kc == 0 && (*(*(keys + p)) - *(*(keys + v))) > 0)) {
          p = v;
        }
      }
      if (p != u - 1) {
        stable_grail_swap_n(arr1 + (u - 1) * lblock, arr1 + p * lblock, lblock);
        stable_grail_swap1(keys + (u - 1), keys + p);
        if (midkey == u - 1 || midkey == p) {
          midkey ^= (u - 1) ^ p;
        }
      }
    }
    nbl2 = llast = 0;
    if (b == M) {
      llast = lrest % lblock;
    }
    if (llast != 0) {
      while (nbl2 < NBlk && (*(*(arr1 + NBlk * lblock)) - *(*(arr1 + (NBlk - nbl2 - 1) * lblock))) < 0) {
        nbl2++;
      }
    }
    if (xbuf) {
      stable_grail_merge_buffers_left_with_x_buf(keys, keys + midkey, arr1, NBlk - nbl2, lblock, nbl2, llast);
    } else {
      stable_grail_merge_buffers_left(keys, keys + midkey, arr1, NBlk - nbl2, lblock, havebuf, nbl2, llast);
    }
  }
  if (xbuf) {
    for (p = len; --p >= 0;) {
      arr[p] = arr[p - lblock];
    }
    memcpy((arr - lblock), (xbuf), (lblock) * sizeof(int *));
  } else if (havebuf) {
    while (--len >= 0) {
      stable_grail_swap1(arr + len, arr + len - lblock);
    }
  }
}
```