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

```asm
<stable_grail_merge_buffers_left_with_x_buf>:
  endbr64
  push   %r15
  mov    %rdi,%rax
  movslq %r8d,%r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  mov    %ecx,%edx
  push   %rbx
  sub    $0x38,%rsp
  mov    0x70(%rsp),%edi
  mov    %rsi,(%rsp)
  mov    %r9d,0x18(%rsp)
  mov    %edi,0x14(%rsp)
  mov    %fs:0x28,%rcx
  mov    %rcx,0x28(%rsp)
  xor    %ecx,%ecx
  test   %edx,%edx
  je     L15
  mov    (%rsp),%rdi
  mov    (%rax),%rcx
  mov    %r15d,0x20(%rsp)
  xor    %r8d,%r8d
  mov    (%rdi),%rsi
  mov    (%rsi),%edi
  cmp    %edi,(%rcx)
  setge  %r8b
  mov    %r8d,0x24(%rsp)
  cmp    $0x1,%edx
  jle    L36
  sub    $0x2,%edx
  lea    0x8(%rax),%r12
  lea    0x24(%rsp),%r13
  mov    %r8d,%r10d
  lea    0x10(%rax,%rdx,8),%rax
  mov    %edx,0x1c(%rsp)
  mov    %r15d,%ebx
  movslq %r15d,%rdx
  mov    %rax,0x8(%rsp)
  mov    %r12,%r14
  jmp    L19
  cs nopw 0x0(%rax,%rax,1)
L24:
  mov    %r13,%rdx
  lea    0x20(%rsp),%rsi
  mov    %ebx,%r8d
  mov    %ebx,%ecx
  xor    %eax,%eax
  mov    %r12d,%r15d
  add    $0x8,%r14
  call   <stable_grail_smart_merge_with_x_buf@plt>
  movslq 0x20(%rsp),%rdx
  sub    %edx,%r15d
  cmp    %r14,0x8(%rsp)
  je     L62
L105:
  mov    (%rsp),%rax
  mov    0x24(%rsp),%r10d
  mov    %r12d,%r15d
  mov    (%rax),%rsi
L19:
  mov    (%r14),%rcx
  mov    %r15d,%eax
  mov    (%rsi),%esi
  lea    (%rbx,%r15,1),%r12d
  sub    %edx,%eax
  cmp    %esi,(%rcx)
  cltq
  setge  %cl
  lea    0x0(%rbp,%rax,8),%rdi
  movzbl %cl,%ecx
  cmp    %r10d,%ecx
  jne    L24
  movslq %ebx,%rcx
  shl    $0x3,%rdx
  mov    %rdi,%rsi
  add    $0x8,%r14
  sub    %rcx,%rax
  lea    0x0(%rbp,%rax,8),%r10
  mov    %r10,%rdi
  call   <memcpy@plt>
  mov    %ebx,0x20(%rsp)
  movslq %ebx,%rdx
  cmp    %r14,0x8(%rsp)
  jne    L105
L62:
  mov    0x1c(%rsp),%eax
  movslq %r15d,%rcx
  movslq %ebx,%r15
  lea    0x0(%rbp,%rcx,8),%rdi
  imul   %r15d,%eax
  lea    (%rax,%r15,2),%ebx
L77:
  mov    0x14(%rsp),%esi
  test   %esi,%esi
  je     L30
  mov    0x18(%rsp),%r12d
  mov    0x24(%rsp),%eax
  imul   %r15d,%r12d
  test   %eax,%eax
  jne    L122
  add    %edx,%r12d
  mov    %r12d,0x20(%rsp)
L61:
  mov    %r15d,%ecx
  mov    0x14(%rsp),%edx
  xor    %eax,%eax
  mov    %r12d,%esi
  neg    %ecx
  call   <stable_grail_merge_left_with_x_buf@plt>
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L71
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L30:
  sub    %r15,%rcx
  shl    $0x3,%rdx
  lea    0x0(%rbp,%rcx,8),%r8
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L71
  add    $0x38,%rsp
  mov    %rdi,%rsi
  mov    %r8,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10a0 <memcpy@plt>
  nopl   0x0(%rax)
L15:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L71
  mov    0x18(%rsp),%esi
  mov    %r15d,%ecx
  mov    0x14(%rsp),%edx
  add    $0x38,%rsp
  pop    %rbx
  mov    %rbp,%rdi
  neg    %ecx
  pop    %rbp
  imul   %r15d,%esi
  pop    %r12
  xor    %eax,%eax
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10b0 <stable_grail_merge_left_with_x_buf@plt>
  nopl   0x0(%rax)
L122:
  movslq %r15d,%rax
  mov    %rdi,%rsi
  shl    $0x3,%rdx
  movslq %ebx,%rbx
  sub    %rax,%rcx
  lea    0x0(%rbp,%rcx,8),%r8
  mov    %r8,%rdi
  call   <memcpy@plt>
  mov    %r12d,0x20(%rsp)
  lea    0x0(%rbp,%rbx,8),%rdi
  movl   $0x0,0x24(%rsp)
  jmp    L61
  nopl   0x0(%rax)
L36:
  mov    %rbp,%rdi
  movslq %r15d,%rdx
  mov    %r15d,%ebx
  xor    %ecx,%ecx
  jmp    L77
L71:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void stable_grail_merge_buffers_left_with_x_buf(int **keys, int **midkey, int **arr, int nblock, int lblock, int nblock2, int llast) {
  int l, prest, lrest, frest, pidx, cidx, fnext;
  if (nblock == 0) {
    l = nblock2 * lblock;
    stable_grail_merge_left_with_x_buf(arr, l, llast, -lblock);
    return;
  }
  lrest = lblock;
  frest = (*(*(keys)) - *(*(midkey))) < 0 ? 0 : 1;
  pidx = lblock;
  for (cidx = 1; cidx < nblock; cidx++, pidx += lblock) {
    prest = pidx - lrest;
    fnext = (*(*(keys + cidx)) - *(*(midkey))) < 0 ? 0 : 1;
    if (fnext == frest) {
      memcpy((arr + prest - lblock), (arr + prest), (lrest) * sizeof(int *));
      prest = pidx;
      lrest = lblock;
    } else {
      stable_grail_smart_merge_with_x_buf(arr + prest, &lrest, &frest, lblock, lblock);
    }
  }
  prest = pidx - lrest;
  if (llast) {
    if (frest) {
      memcpy((arr + prest - lblock), (arr + prest), (lrest) * sizeof(int *));
      prest = pidx;
      lrest = lblock * nblock2;
      frest = 0;
    } else {
      lrest += lblock * nblock2;
    }
    stable_grail_merge_left_with_x_buf(arr + prest, lrest, llast, -lblock);
  } else {
    memcpy((arr + prest - lblock), (arr + prest), (lrest) * sizeof(int *));
  }
}
```