user: Converte this assembly snippet into its equivalent C code:

```asm
<mergesort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %edx,-0x30(%rbp)
  mov    %ecx,-0x34(%rbp)
  mov    %r8d,-0x38(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x38(%rbp),%eax
  cltq
  shl    $0x2,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L59
L27:
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L113
  mov    -0x2c(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x2c(%rbp)
  addl   $0x1,-0x18(%rbp)
  jmp    L59
L113:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x14(%rbp)
  addl   $0x1,-0x18(%rbp)
L59:
  mov    -0x2c(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jg     L13
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jle    L27
L13:
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jle    L35
  mov    -0x2c(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  jmp    L26
L8:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
L26:
  mov    -0x10(%rbp),%eax
  cmp    -0x30(%rbp),%eax
  jle    L8
  jmp    L23
L35:
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  jmp    L18
L47:
  mov    -0x10(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x18(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    (%rcx),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x10(%rbp)
L18:
  mov    -0x10(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jle    L47
L23:
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  jmp    L129
L46:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  addl   $0x1,-0x18(%rbp)
L129:
  mov    -0x18(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jle    L46
  nop
  nop
  leave
  ret
```

assistant: ```c
void mergesort(int *a, int start, int mid, int end, int size) {
  int i = start, begin = start, m = mid + 1, k, *b;
  b = (int *)malloc(sizeof(int) * size);
  while (start <= mid && m <= end) {
    if (a[start] < a[m]) {
      b[i] = a[start];
      start++;
      i++;
    } else {
      b[i] = a[m];
      m++;
      i++;
    }
  }
  if (m > end) {
    for (k = start; k <= mid; k++)
      b[i++] = a[k];
  } else {
    for (k = m; k <= end; k++)
      b[i++] = a[k];
  }
  for (i = begin; i <= end; i++) {
    a[i] = b[i];
  }
}
```