user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<sorter_grail_merge_buffers_left_with_x_buf>:
  endbr64
  push   %r15
  mov    %rdi,%rax
  mov    %r8d,%r15d
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    0x70(%rsp),%edi
  mov    %rsi,(%rsp)
  mov    %r9d,0x18(%rsp)
  mov    %edi,0x14(%rsp)
  mov    %fs:0x28,%rdx
  mov    %rdx,0x28(%rsp)
  xor    %edx,%edx
  test   %ecx,%ecx
  je     L8
  mov    (%rsp),%rdi
  xor    %r11d,%r11d
  mov    %r8d,0x20(%rsp)
  mov    (%rdi),%rsi
  cmp    %rsi,(%rax)
  setge  %r11b
  mov    %r11d,0x24(%rsp)
  cmp    $0x1,%ecx
  jle    L105
  lea    -0x2(%rcx),%edx
  lea    0x8(%rax),%r13
  mov    %r8d,%ebx
  lea    0x10(%rax,%rdx,8),%rax
  lea    0x24(%rsp),%r14
  mov    %edx,0x1c(%rsp)
  mov    %r8d,%edx
  mov    %rax,0x8(%rsp)
  mov    %r14,%r12
  jmp    L7
  nopl   (%rax)
L47:
  mov    %r12,%rdx
  lea    0x20(%rsp),%rsi
  mov    %ebx,%r8d
  mov    %ebx,%ecx
  call   <sorter_grail_smart_merge_with_x_buf@plt>
  mov    0x20(%rsp),%edx
  mov    %r14d,%r15d
  add    $0x8,%r13
  sub    %edx,%r15d
  cmp    %r13,0x8(%rsp)
  je     L116
L69:
  mov    (%rsp),%rax
  mov    0x24(%rsp),%r11d
  mov    %r14d,%r15d
  mov    (%rax),%rsi
L7:
  mov    %r15d,%eax
  xor    %ecx,%ecx
  lea    (%rbx,%r15,1),%r14d
  sub    %edx,%eax
  cmp    %rsi,0x0(%r13)
  cltq
  setge  %cl
  lea    0x0(%rbp,%rax,8),%rdi
  cmp    %r11d,%ecx
  jne    L47
  movslq %ebx,%rcx
  shl    $0x3,%edx
  mov    %rdi,%rsi
  add    $0x8,%r13
  sub    %rcx,%rax
  lea    0x0(%rbp,%rax,8),%r10
  mov    %r10,%rdi
  call   <memcpy@plt>
  mov    %ebx,0x20(%rsp)
  mov    %ebx,%edx
  cmp    %r13,0x8(%rsp)
  jne    L69
L116:
  mov    0x1c(%rsp),%eax
  movslq %r15d,%rcx
  mov    %ebx,%r15d
  lea    0x0(%rbp,%rcx,8),%rdi
  imul   %ebx,%eax
  lea    (%rax,%rbx,2),%ebx
L0:
  mov    0x14(%rsp),%esi
  test   %esi,%esi
  je     L38
  mov    0x18(%rsp),%r12d
  mov    0x24(%rsp),%eax
  imul   %r15d,%r12d
  test   %eax,%eax
  jne    L48
  add    %edx,%r12d
  mov    %r12d,0x20(%rsp)
L1:
  mov    %r15d,%ecx
  mov    0x14(%rsp),%edx
  mov    %r12d,%esi
  neg    %ecx
  call   <sorter_grail_merge_left_with_x_buf@plt>
L110:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L90
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L38:
  movslq %r15d,%r8
  mov    %rdi,%rsi
  shl    $0x3,%edx
  sub    %r8,%rcx
  lea    0x0(%rbp,%rcx,8),%r8
  mov    %r8,%rdi
  call   <memcpy@plt>
  jmp    L110
  nopl   0x0(%rax,%rax,1)
L8:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L90
  mov    0x18(%rsp),%esi
  mov    0x14(%rsp),%edx
  mov    %r8d,%ecx
  add    $0x38,%rsp
  pop    %rbx
  mov    %rbp,%rdi
  neg    %ecx
  pop    %rbp
  imul   %r8d,%esi
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    10a0 <sorter_grail_merge_left_with_x_buf@plt>
  nopw   0x0(%rax,%rax,1)
L48:
  movslq %r15d,%rax
  mov    %rdi,%rsi
  shl    $0x3,%edx
  movslq %ebx,%rbx
  sub    %rax,%rcx
  lea    0x0(%rbp,%rcx,8),%r9
  mov    %r9,%rdi
  call   <memcpy@plt>
  mov    %r12d,0x20(%rsp)
  lea    0x0(%rbp,%rbx,8),%rdi
  movl   $0x0,0x24(%rsp)
  jmp    L1
  nopl   0x0(%rax,%rax,1)
L105:
  mov    %rbp,%rdi
  mov    %r8d,%edx
  mov    %r8d,%ebx
  xor    %ecx,%ecx
  jmp    L0
L90:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void sorter_grail_merge_buffers_left_with_x_buf(int64_t *keys, int64_t *midkey, int64_t *arr, int nblock, int lblock, int nblock2, int llast) {
  int l, prest, lrest, frest, pidx, cidx, fnext;
  if (nblock == 0) {
    l = nblock2 * lblock;
    sorter_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(int64_t));
      prest = pidx;
      lrest = lblock;
    } else {
      sorter_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(int64_t));
      prest = pidx;
      lrest = lblock * nblock2;
      frest = 0;
    } else {
      lrest += lblock * nblock2;
    }
    sorter_grail_merge_left_with_x_buf(arr + prest, lrest, llast, -lblock);
  } else {
    memcpy(arr + prest - lblock, arr + prest, lrest * sizeof(int64_t));
  }
}
```