user: Please show me the C implementation that matches the assembly code listed below:

```asm
<merge>:
  endbr64
  push   %r15
  sub    %edx,%ecx
  push   %r14
  mov    %edx,%r14d
  push   %r13
  sub    %esi,%r14d
  mov    %ecx,%r13d
  push   %r12
  lea    0x1(%r14),%r15d
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %rdi,%rbx
  lea    0x0(,%r15,4),%edi
  sub    $0x18,%rsp
  mov    %edx,0xc(%rsp)
  call   <malloc@plt>
  lea    0x0(,%r13,4),%edi
  mov    %rax,%r12
  call   <malloc@plt>
  test   %r15d,%r15d
  mov    0xc(%rsp),%edx
  mov    %rax,%rcx
  jle    L68
  movslq %ebp,%rax
  mov    %r12,%rsi
  lea    0x4(,%rax,4),%rax
  lea    (%rbx,%rax,1),%rdi
  sub    %rdi,%rsi
  cmp    $0x8,%rsi
  jbe    L338
  cmp    $0x2,%r14d
  jbe    L338
  mov    %r15d,%esi
  lea    -0x4(%rbx,%rax,1),%rdi
  xor    %eax,%eax
  shr    $0x2,%esi
  shl    $0x4,%rsi
  nopl   0x0(%rax)
L83:
  movdqu (%rdi,%rax,1),%xmm0
  movups %xmm0,(%r12,%rax,1)
  add    $0x10,%rax
  cmp    %rsi,%rax
  jne    L83
  mov    %r15d,%eax
  and    $0xfffffffc,%eax
  test   $0x3,%r15b
  je     L68
  lea    0x0(%rbp,%rax,1),%esi
  movslq %eax,%r8
  movslq %esi,%rsi
  lea    0x0(,%r8,4),%rdi
  mov    (%rbx,%rsi,4),%esi
  mov    %esi,(%r12,%r8,4)
  lea    0x1(%rax),%r8d
  cmp    %eax,%r14d
  jle    L68
  lea    0x0(%rbp,%r8,1),%esi
  add    $0x2,%eax
  movslq %esi,%rsi
  mov    (%rbx,%rsi,4),%esi
  mov    %esi,0x4(%r12,%rdi,1)
  cmp    %r8d,%r14d
  jle    L68
  add    %ebp,%eax
  cltq
  mov    (%rbx,%rax,4),%eax
  mov    %eax,0x8(%r12,%rdi,1)
L68:
  test   %r13d,%r13d
  jle    L133
L302:
  movslq %edx,%rax
  mov    %rcx,%rsi
  lea    0x8(,%rax,4),%rax
  lea    (%rbx,%rax,1),%rdi
  sub    %rdi,%rsi
  cmp    $0x8,%rsi
  jbe    L231
  lea    -0x1(%r13),%esi
  cmp    $0x2,%esi
  jbe    L231
  mov    %r13d,%esi
  lea    -0x4(%rbx,%rax,1),%rdi
  xor    %eax,%eax
  shr    $0x2,%esi
  shl    $0x4,%rsi
  nopl   0x0(%rax,%rax,1)
L418:
  movdqu (%rdi,%rax,1),%xmm1
  movups %xmm1,(%rcx,%rax,1)
  add    $0x10,%rax
  cmp    %rsi,%rax
  jne    L418
  mov    %r13d,%eax
  and    $0xfffffffc,%eax
  test   $0x3,%r13b
  je     L328
  lea    (%rdx,%rax,1),%esi
  mov    %eax,%r8d
  movslq %esi,%rsi
  lea    0x0(,%r8,4),%rdi
  mov    0x4(%rbx,%rsi,4),%esi
  mov    %esi,(%rcx,%r8,4)
  lea    0x1(%rax),%esi
  cmp    %esi,%r13d
  jle    L328
  add    %edx,%esi
  add    $0x2,%eax
  movslq %esi,%rsi
  mov    0x4(%rbx,%rsi,4),%esi
  mov    %esi,0x4(%rcx,%rdi,1)
  cmp    %eax,%r13d
  jle    L328
  add    %eax,%edx
  movslq %edx,%rdx
  mov    0x4(%rbx,%rdx,4),%eax
  mov    %eax,0x8(%rcx,%rdi,1)
L328:
  test   %r15d,%r15d
  jle    L385
  lea    0x1(%rbp),%eax
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %r10d,%r10d
  cltq
  xor    %r9d,%r9d
  nopl   0x0(%rax)
L167:
  mov    (%r12,%r10,4),%r8d
  mov    (%rcx,%r9,4),%edi
  mov    %eax,%ebp
  cmp    %r8d,%edi
  jl     L124
L275:
  mov    %r8d,-0x4(%rbx,%rax,4)
  lea    0x1(%rsi),%edi
  add    $0x1,%rax
  cmp    %edx,%r13d
  jle    L175
  cmp    %esi,%r14d
  jle    L175
  movslq %edi,%r10
  mov    (%rcx,%r9,4),%edi
  mov    %eax,%ebp
  mov    (%r12,%r10,4),%r8d
  mov    %r10,%rsi
  cmp    %r8d,%edi
  jge    L275
L124:
  mov    %edi,-0x4(%rbx,%rax,4)
  add    $0x1,%edx
  add    $0x1,%rax
  cmp    %esi,%r15d
  jle    L292
  cmp    %edx,%r13d
  jle    L292
  movslq %edx,%r9
  jmp    L167
  nopl   0x0(%rax)
L292:
  mov    %esi,%edi
L175:
  cmp    %edi,%r15d
  jle    L40
  movslq %ebp,%rax
  mov    %r14d,%r10d
  lea    (%rbx,%rax,4),%r8
  lea    0x1(%rdi),%eax
  sub    %edi,%r10d
  cltq
  mov    %r8,%rsi
  shl    $0x2,%rax
  lea    (%r12,%rax,1),%r9
  sub    %r9,%rsi
  cmp    $0x8,%rsi
  jbe    L94
  cmp    $0x2,%r10d
  jbe    L94
  lea    0x1(%r10),%r11d
  lea    -0x4(%r12,%rax,1),%r9
  xor    %eax,%eax
  mov    %r11d,%esi
  shr    $0x2,%esi
  shl    $0x4,%rsi
  nopl   0x0(%rax)
L132:
  movdqu (%r9,%rax,1),%xmm2
  movups %xmm2,(%r8,%rax,1)
  add    $0x10,%rax
  cmp    %rax,%rsi
  jne    L132
  mov    %r11d,%eax
  and    $0xfffffffc,%eax
  add    %eax,%edi
  lea    0x0(%rbp,%rax,1),%esi
  cmp    %eax,%r11d
  je     L92
  movslq %edi,%r9
  lea    0x1(%rsi),%eax
  lea    0x1(%rdi),%r8d
  movslq %esi,%rsi
  mov    (%r12,%r9,4),%r9d
  mov    %r9d,(%rbx,%rsi,4)
  cmp    %edi,%r14d
  jle    L92
  movslq %r8d,%rsi
  cltq
  lea    0x0(,%rsi,4),%r9
  mov    (%r12,%rsi,4),%esi
  lea    0x0(,%rax,4),%rdi
  mov    %esi,(%rbx,%rax,4)
  cmp    %r8d,%r14d
  jle    L92
  mov    0x4(%r12,%r9,1),%eax
  mov    %eax,0x4(%rbx,%rdi,1)
L92:
  lea    0x1(%r10,%rbp,1),%ebp
L40:
  cmp    %edx,%r13d
  jle    L337
L206:
  movslq %ebp,%r8
  movslq %edx,%rsi
  mov    %r13d,%r9d
  shl    $0x2,%r8
  lea    0x1(%rsi),%rax
  sub    %edx,%r9d
  lea    (%rbx,%r8,1),%rdi
  lea    0x0(,%rax,4),%r10
  lea    (%rcx,%r10,1),%r12
  mov    %rdi,%r11
  sub    %r12,%r11
  cmp    $0x8,%r11
  jbe    L126
  lea    -0x1(%r9),%r11d
  cmp    $0x2,%r11d
  jbe    L126
  mov    %r9d,%esi
  lea    -0x4(%rcx,%r10,1),%r8
  xor    %eax,%eax
  shr    $0x2,%esi
  shl    $0x4,%rsi
  nopw   0x0(%rax,%rax,1)
L207:
  movdqu (%r8,%rax,1),%xmm3
  movups %xmm3,(%rdi,%rax,1)
  add    $0x10,%rax
  cmp    %rsi,%rax
  jne    L207
  mov    %r9d,%eax
  and    $0xfffffffc,%eax
  add    %eax,%edx
  add    %eax,%ebp
  cmp    %r9d,%eax
  je     L337
  movslq %edx,%rdi
  lea    0x1(%rbp),%esi
  lea    0x1(%rdx),%eax
  movslq %ebp,%rbp
  mov    (%rcx,%rdi,4),%edi
  mov    %edi,(%rbx,%rbp,4)
  cmp    %r13d,%eax
  jge    L337
  cltq
  movslq %esi,%rsi
  add    $0x2,%edx
  lea    0x0(,%rax,4),%r8
  mov    (%rcx,%rax,4),%eax
  lea    0x0(,%rsi,4),%rdi
  mov    %eax,(%rbx,%rsi,4)
  cmp    %r13d,%edx
  jge    L337
  mov    0x4(%rcx,%r8,1),%eax
  mov    %eax,0x4(%rbx,%rdi,1)
L337:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L231:
  lea    -0x8(%rbx,%rax,1),%rsi
  lea    0x1(%r13),%edi
  mov    $0x1,%eax
  xchg   %ax,%ax
L321:
  mov    (%rsi,%rax,4),%edx
  mov    %edx,-0x4(%rcx,%rax,4)
  add    $0x1,%rax
  cmp    %rdi,%rax
  jne    L321
  jmp    L328
  nopl   (%rax)
L126:
  mov    %rsi,%rdx
  neg    %rdx
  lea    (%r8,%rdx,4),%rdx
  add    %rdx,%rbx
  jmp    L382
  nopw   0x0(%rax,%rax,1)
L78:
  add    $0x1,%rax
L382:
  mov    (%rcx,%rsi,4),%edx
  mov    %edx,(%rbx,%rsi,4)
  mov    %rax,%rsi
  cmp    %eax,%r13d
  jg     L78
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L94:
  lea    -0x4(%r12,%rax,1),%rdi
  mov    %r10d,%r9d
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L75:
  mov    (%rdi,%rax,4),%esi
  mov    %esi,(%r8,%rax,4)
  mov    %rax,%rsi
  add    $0x1,%rax
  cmp    %rsi,%r9
  jne    L75
  jmp    L92
L338:
  mov    %r14d,%esi
  lea    -0x4(%rbx,%rax,1),%rdi
  xor    %eax,%eax
  lea    0x4(,%rsi,4),%r8
  nopw   0x0(%rax,%rax,1)
L15:
  mov    (%rdi,%rax,1),%esi
  mov    %esi,(%r12,%rax,1)
  add    $0x4,%rax
  cmp    %r8,%rax
  jne    L15
  test   %r13d,%r13d
  jg     L302
  nopl   0x0(%rax)
L133:
  xor    %edx,%edx
  xor    %edi,%edi
  jmp    L175
L385:
  xor    %edx,%edx
  jmp    L206
```

assistant: ```c
void merge(int *a, int p, int q, int r) {
  int n1 = q - p + 1;
  int n2 = r - q;
  int *left = malloc(n1 * sizeof(int));
  int *right = malloc(n2 * sizeof(int));
  int i, j, k;
  for (i = 0; i < n1; i++)
    left[i] = a[p + i];
  for (j = 0; j < n2; j++)
    right[j] = a[q + j + 1];
  i = j = 0;
  k = p;
  while (i < n1 & j < n2) {
    if (left[i] <= right[j]) {
      a[k++] = left[i++];
    } else {
      a[k++] = right[j++];
    }
  }
  while (i < n1) {
    a[k++] = left[i++];
  }
  while (j < n2) {
    a[k++] = right[j++];
  }
}
```