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

```asm
<merge>:
  endbr64
  mov    %r8d,%eax
  push   %r15
  mov    %ecx,%r15d
  sub    %edx,%eax
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  add    $0x1,%eax
  push   %r12
  imul   %esi,%eax
  mov    %edx,%r12d
  push   %rbp
  lea    0x1(%rcx),%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x48,%rsp
  mov    %rdi,0x18(%rsp)
  mov    %eax,%edi
  mov    %edx,0x38(%rsp)
  mov    %ecx,0xc(%rsp)
  mov    %r8d,0x8(%rsp)
  mov    %r9,0x30(%rsp)
  mov    %eax,0x3c(%rsp)
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  test   %rax,%rax
  je     L147
  cmp    %r15d,%r12d
  jle    L55
  cmp    %r14d,%ebp
  jg     L120
L55:
  movslq %ebx,%rax
  xor    %r13d,%r13d
  mov    0x38(%rsp),%r12d
  mov    %ebx,%r14d
  mov    %rax,0x10(%rsp)
  mov    %r13d,%r15d
L30:
  cmp    %r12d,0xc(%rsp)
  jl     L88
L91:
  mov    %r14d,%ecx
  mov    0x18(%rsp),%rax
  mov    0x20(%rsp),%rbx
  imul   %r12d,%ecx
  movslq %ecx,%rcx
  lea    (%rax,%rcx,1),%r10
  mov    %r14d,%eax
  imul   %r15d,%eax
  cltq
  lea    (%rbx,%rax,1),%r13
  lea    0x1(%r15),%ebx
  cmp    %ebp,0x8(%rsp)
  jl     L35
  mov    %r14d,%esi
  mov    0x18(%rsp),%rax
  mov    %r10,0x28(%rsp)
  mov    %r10,%rdi
  imul   %ebp,%esi
  movslq %esi,%rsi
  lea    (%rax,%rsi,1),%r15
  mov    0x30(%rsp),%rax
  mov    %r15,%rsi
  call   *%rax
  mov    %r14d,%edx
  test   %eax,%eax
  js     L136
  mov    %r15,%rsi
  mov    %r13,%rdi
  add    $0x1,%ebp
  call   <memcpy@plt>
L33:
  mov    %ebx,%r15d
  cmp    %r12d,0xc(%rsp)
  jge    L91
L88:
  cmp    %ebp,0x8(%rsp)
  jl     L129
  mov    %r14d,%eax
  mov    0x20(%rsp),%rcx
  mov    0x18(%rsp),%rdx
  mov    %ebp,%r13d
  imul   %r15d,%eax
  mov    %r12d,0x28(%rsp)
  sub    %rcx,%rdx
  cltq
  lea    (%rcx,%rax,1),%rbx
  mov    %r14d,%ecx
  imul   %ebp,%ecx
  mov    %rbx,%r12
  movslq %ecx,%rcx
  add    %rcx,%rdx
  sub    %rax,%rdx
  mov    %rdx,%rbx
  nopl   (%rax)
L19:
  lea    (%rbx,%r12,1),%rsi
  mov    %r12,%rdi
  mov    %r14d,%edx
  add    $0x1,%r13d
  call   <memcpy@plt>
  lea    0x0(%r13,%r15,1),%eax
  add    0x10(%rsp),%r12
  sub    %ebp,%eax
  cmp    %r13d,0x8(%rsp)
  jge    L19
  mov    0x28(%rsp),%r12d
  mov    %eax,%r15d
  mov    %r13d,%ebp
L129:
  cmp    0xc(%rsp),%r12d
  jle    L30
  cmp    0x8(%rsp),%ebp
  jle    L30
  mov    %r14d,%ebx
L120:
  mov    0x38(%rsp),%eax
  mov    0x18(%rsp),%rdi
  mov    0x3c(%rsp),%edx
  imul   %ebx,%eax
  mov    0x20(%rsp),%rbx
  mov    %rbx,%rsi
  cltq
  add    %rax,%rdi
  call   <memcpy@plt>
  mov    %rbx,%rdi
  call   <free@plt>
  xor    %eax,%eax
L59:
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L136:
  mov    0x28(%rsp),%rsi
  mov    %r13,%rdi
  add    $0x1,%r12d
  call   <memcpy@plt>
  jmp    L33
  xchg   %ax,%ax
L35:
  mov    0x18(%rsp),%rdx
  sub    0x20(%rsp),%rdx
  mov    %ebp,0x28(%rsp)
  mov    %r12d,%ebp
  add    %rcx,%rdx
  sub    %rax,%rdx
  mov    %rdx,%rbx
  nopw   0x0(%rax,%rax,1)
L36:
  lea    0x0(%r13,%rbx,1),%rsi
  mov    %r13,%rdi
  mov    %r14d,%edx
  add    $0x1,%ebp
  call   <memcpy@plt>
  lea    0x0(%rbp,%r15,1),%eax
  add    0x10(%rsp),%r13
  sub    %r12d,%eax
  cmp    %ebp,0xc(%rsp)
  jge    L36
  mov    %ebp,%r13d
  mov    %eax,%r15d
  mov    0x28(%rsp),%ebp
  mov    %r13d,%r12d
  jmp    L129
L147:
  mov    $0xffffffff,%eax
  jmp    L59
```

assistant: ```c
int merge(void *data, int esize, int i, int j, int k, int (*compare)(const void *key1, const void *key2)) {
  char *a = data, *m;
  int ipos, jpos, mpos;
  ipos = i;
  jpos = j + 1;
  mpos = 0;
  if ((m = (char *)malloc(esize * (k - i + 1))) == NULL)
    return -1;
  while (ipos <= j || jpos <= k) {
    if (ipos > j) {
      while (jpos <= k) {
        memcpy(&m[mpos * esize], &a[jpos * esize], esize);
        jpos++;
        mpos++;
      }
      continue;
    } else if (jpos > k) {
      while (ipos <= j) {
        memcpy(&m[mpos * esize], &a[ipos * esize], esize);
        ipos++;
        mpos++;
      }
      continue;
    }
    if (compare(&a[ipos * esize], &a[jpos * esize]) < 0) {
      memcpy(&m[mpos * esize], &a[ipos * esize], esize);
      ipos++;
      mpos++;
    } else {
      memcpy(&m[mpos * esize], &a[jpos * esize], esize);
      jpos++;
      mpos++;
    }
  }
  memcpy(&a[i * esize], m, esize * (k - i + 1));
  free(m);
  return 0;
}
```