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

```asm
<mergesort>:
  endbr64
  cmp    %edx,%esi
  jl     L123
  xor    %eax,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L123:
  mov    %edx,%eax
  push   %r15
  mov    %rdi,%r15
  sub    %esi,%eax
  push   %r14
  push   %r13
  mov    %eax,%r13d
  push   %r12
  sar    %r13d
  mov    %edx,%r12d
  push   %rbp
  add    %esi,%r13d
  mov    %esi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x28,%rsp
  cmp    %r13d,%esi
  jl     L77
  lea    0x1(%r13),%r8d
  cmp    %r12d,%r8d
  jl     L34
L39:
  mov    %r12d,%ecx
  mov    %r13d,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  call   <merge@plt>
  add    $0x28,%rsp
  add    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L77:
  mov    %eax,%r8d
  xor    %r14d,%r14d
  sar    $0x2,%r8d
  lea    (%r8,%rsi,1),%ebx
  cmp    %ebx,%esi
  jl     L23
L98:
  lea    0x1(%rbx),%r9d
  cmp    %r9d,%r13d
  jg     L18
L72:
  mov    %ebx,%edx
  mov    %r13d,%ecx
  mov    %ebp,%esi
  mov    %r15,%rdi
  call   <merge@plt>
  lea    0x1(%r13),%r8d
  lea    (%rax,%r14,1),%rbx
  cmp    %r12d,%r8d
  jge    L39
L34:
  mov    %r12d,%eax
  xor    %r14d,%r14d
  sub    %r8d,%eax
  mov    %eax,%r9d
  sar    %r9d
  add    %r8d,%r9d
  cmp    %r9d,%r8d
  jl     L105
L83:
  lea    0x1(%r9),%r10d
  cmp    %r10d,%r12d
  jg     L82
L50:
  mov    %r12d,%ecx
  mov    %r9d,%edx
  mov    %r8d,%esi
  mov    %r15,%rdi
  call   <merge@plt>
  add    %rbx,%r14
  lea    (%r14,%rax,1),%rbx
  jmp    L39
  nopl   0x0(%rax)
L23:
  sar    $0x3,%eax
  lea    (%rax,%rsi,1),%r14d
  mov    %r14d,%edx
  call   <mergesort>
  lea    0x1(%r14),%esi
  mov    %ebx,%edx
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  call   <mergesort>
  mov    %ebx,%ecx
  add    0x8(%rsp),%rax
  mov    %r14d,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  call   <merge@plt>
  mov    0x8(%rsp),%rcx
  lea    (%rax,%rcx,1),%r14
  jmp    L98
  nopl   0x0(%rax)
L82:
  mov    %r12d,%r11d
  mov    %r10d,%esi
  mov    %r15,%rdi
  mov    %r9d,0x1c(%rsp)
  sub    %r10d,%r11d
  mov    %r8d,0x18(%rsp)
  sar    %r11d
  mov    %r10d,0x14(%rsp)
  add    %r10d,%r11d
  mov    %r11d,%edx
  mov    %r11d,0x10(%rsp)
  call   <mergesort>
  mov    0x10(%rsp),%r11d
  mov    %r12d,%edx
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  lea    0x1(%r11),%esi
  call   <mergesort>
  mov    0x10(%rsp),%edx
  mov    0x14(%rsp),%esi
  mov    %r12d,%ecx
  add    0x8(%rsp),%rax
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  call   <merge@plt>
  mov    0x8(%rsp),%rcx
  mov    0x1c(%rsp),%r9d
  mov    0x18(%rsp),%r8d
  lea    (%rcx,%r14,1),%rdx
  lea    (%rdx,%rax,1),%r14
  jmp    L50
  nopl   0x0(%rax,%rax,1)
L105:
  sar    $0x2,%eax
  mov    %r8d,%esi
  mov    %r15,%rdi
  mov    %r9d,0x10(%rsp)
  lea    (%rax,%r8,1),%r14d
  mov    %r8d,0x18(%rsp)
  mov    %r14d,%edx
  call   <mergesort>
  mov    0x10(%rsp),%edx
  lea    0x1(%r14),%esi
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  call   <mergesort>
  mov    0x10(%rsp),%r9d
  mov    %r14d,%edx
  mov    %r15,%rdi
  mov    0x18(%rsp),%r8d
  add    0x8(%rsp),%rax
  mov    %r9d,%ecx
  mov    %r9d,0x14(%rsp)
  mov    %r8d,%esi
  mov    %r8d,0x10(%rsp)
  mov    %rax,0x8(%rsp)
  call   <merge@plt>
  mov    0x8(%rsp),%rcx
  mov    0x14(%rsp),%r9d
  mov    0x10(%rsp),%r8d
  lea    (%rax,%rcx,1),%r14
  jmp    L83
  nopl   0x0(%rax,%rax,1)
L18:
  mov    %r13d,%r10d
  mov    %r9d,%esi
  mov    %r15,%rdi
  mov    %r9d,0x14(%rsp)
  sub    %r9d,%r10d
  sar    %r10d
  add    %r9d,%r10d
  mov    %r10d,%edx
  mov    %r10d,0x10(%rsp)
  call   <mergesort>
  mov    0x10(%rsp),%r10d
  mov    %r13d,%edx
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  lea    0x1(%r10),%esi
  call   <mergesort>
  mov    0x10(%rsp),%edx
  mov    0x14(%rsp),%esi
  mov    %r13d,%ecx
  add    0x8(%rsp),%rax
  mov    %r15,%rdi
  mov    %rax,0x8(%rsp)
  call   <merge@plt>
  mov    0x8(%rsp),%rcx
  lea    (%rcx,%r14,1),%rdx
  lea    (%rdx,%rax,1),%r14
  jmp    L72
```

assistant: ```c
unsigned long long mergesort(int ar[], int l, int r) {
  unsigned long long count = 0;
  if (l < r) {
    int m = l + (r - l) / 2;
    count = mergesort(ar, l, m);
    count += mergesort(ar, m + 1, r);
    count += merge(ar, l, m, r);
  }
  return count;
}
```