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

```asm
<merge>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %esi,%ebp
  mov    %edx,0xc(%rsp)
  mov    %edx,%edi
  sub    %esi,%edi
  mov    %edi,0x8(%rsp)
  lea    0x1(%rdi),%r15d
  sub    %edx,%ecx
  mov    %ecx,%r12d
  lea    0x0(,%r15,4),%edi
  call   <malloc@plt>
  mov    %rax,%r14
  lea    0x0(,%r12,4),%edi
  call   <malloc@plt>
  mov    %rax,%r13
  test   %r15d,%r15d
  jle    L100
  mov    %r14,%rax
  mov    0x8(%rsp),%edx
  lea    0x4(%r14,%rdx,4),%rsi
  movslq %ebp,%rdx
  lea    (%rbx,%rdx,4),%rcx
  sub    %r14,%rcx
L52:
  mov    (%rcx,%rax,1),%edx
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L52
L100:
  test   %r12d,%r12d
  jle    L65
  mov    %r13,%rax
  mov    %r12d,%edx
  lea    0x0(%r13,%rdx,4),%rsi
  movslq 0xc(%rsp),%rdx
  lea    (%rbx,%rdx,4),%rcx
  sub    %r13,%rcx
L129:
  mov    0x4(%rcx,%rax,1),%edx
  mov    %edx,(%rax)
  add    $0x4,%rax
  cmp    %rsi,%rax
  jne    L129
  test   %r15d,%r15d
  jle    L47
  lea    0x1(%rbp),%eax
  cltq
  mov    $0x0,%ecx
  mov    $0x0,%edx
  jmp    L110
L128:
  mov    %esi,-0x4(%rbx,%rax,4)
  add    $0x1,%ecx
L117:
  mov    %eax,%ebp
  add    $0x1,%rax
  cmp    %r15d,%edx
  jge    L62
  cmp    %r12d,%ecx
  jge    L62
L110:
  movslq %edx,%rsi
  mov    (%r14,%rsi,4),%edi
  movslq %ecx,%rsi
  mov    0x0(%r13,%rsi,4),%esi
  cmp    %esi,%edi
  jg     L128
  mov    %edi,-0x4(%rbx,%rax,4)
  add    $0x1,%edx
  jmp    L117
L65:
  mov    $0x0,%ecx
  mov    $0x0,%edx
L62:
  cmp    %edx,%r15d
  jle    L71
  movslq %edx,%rsi
  lea    (%r14,%rsi,4),%rax
  mov    %edx,%r8d
  mov    0x8(%rsp),%edi
  sub    %edx,%edi
  lea    (%rdi,%rsi,1),%rdx
  lea    0x4(%r14,%rdx,4),%rdi
  movslq %ebp,%rdx
  sub    %rsi,%rdx
  lea    (%rbx,%rdx,4),%rsi
  sub    %r14,%rsi
L67:
  mov    (%rax),%edx
  mov    %edx,(%rsi,%rax,1)
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L67
  mov    0x8(%rsp),%eax
  lea    0x1(%rax,%rbp,1),%ebp
  sub    %r8d,%ebp
L71:
  cmp    %ecx,%r12d
  jle    L24
  movslq %ecx,%rdx
  lea    0x0(%r13,%rdx,4),%rax
  sub    $0x1,%r12d
  sub    %ecx,%r12d
  add    %rdx,%r12
  lea    0x4(%r13,%r12,4),%rcx
  neg    %rdx
  shl    $0x2,%rdx
  sub    %r13,%rdx
  movslq %ebp,%rbp
  lea    (%rdx,%rbp,4),%rdx
  add    %rdx,%rbx
L95:
  mov    (%rax),%edx
  mov    %edx,(%rbx,%rax,1)
  add    $0x4,%rax
  cmp    %rcx,%rax
  jne    L95
L24:
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L47:
  mov    $0x0,%ecx
  jmp    L71
```

assistant: ```c
void merge(int *a, int l, int m, int r) {
  int i, j, k;
  int len1 = m - l + 1;
  int len2 = r - m;
  int *a1;
  a1 = (int *)malloc(len1 * sizeof(int));
  int *a2;
  a2 = (int *)malloc(len2 * sizeof(int));
  for (i = 0; i < len1; i++) {
    *(a1 + i) = *(a + l + i);
  }
  for (i = 0; i < len2; i++) {
    *(a2 + i) = *(a + m + 1 + i);
  }
  i = 0;
  j = 0;
  k = l;
  while (i < len1 && j < len2) {
    if (*(a1 + i) <= *(a2 + j)) {
      *(a + k) = *(a1 + i);
      i++;
    } else {
      *(a + k) = *(a2 + j);
      j++;
    }
    k++;
  }
  while (i < len1) {
    *(a + k) = *(a1 + i);
    i++;
    k++;
  }
  while (j < len2) {
    *(a + k) = *(a2 + j);
    j++;
    k++;
  }
  free(a1);
  free(a2);
}
```