user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<intmsort>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x38,%rsp
  mov    %rdi,0x28(%rsp)
  lea    0x0(,%rsi,4),%edi
  mov    %rsi,0x10(%rsp)
  call   <malloc@plt>
  mov    %rax,0x20(%rsp)
  test   %rbx,%rbx
  je     L129
  mov    %rax,(%rsp)
  mov    (%rsp),%r13
  mov    $0x1,%r14d
  movq   $0x0,0x18(%rsp)
  mov    0x28(%rsp),%rax
  mov    %rax,0x8(%rsp)
  mov    %rax,%r15
  nopl   (%rax)
L84:
  mov    0x10(%rsp),%rbp
  nopl   (%rax)
L46:
  cmp    %rbp,%r14
  mov    %rbp,%rbx
  mov    %r14,%r12
  mov    %r13,%r8
  cmovbe %r14,%rbx
  mov    %r15,%rdi
  sub    %rbx,%rbp
  lea    (%r15,%rbx,4),%rdx
  mov    %rbx,%rsi
  cmp    %r14,%rbp
  cmovbe %rbp,%r12
  add    %r12,%rbx
  mov    %r12,%rcx
  sub    %r12,%rbp
  call   <intmerge@plt>
  shl    $0x2,%rbx
  add    %rbx,%r15
  add    %rbx,%r13
  test   %rbp,%rbp
  jne    L46
  mov    0x8(%rsp),%rsi
  mov    (%rsp),%rax
  add    %r14,%r14
  addq   $0x1,0x18(%rsp)
  mov    %rsi,(%rsp)
  cmp    %r14,0x10(%rsp)
  jb     L147
  mov    %rax,0x8(%rsp)
  mov    %rsi,%r13
  mov    %rax,%r15
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L147:
  testb  $0x1,0x18(%rsp)
  jne    L127
L129:
  mov    0x20(%rsp),%rdi
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1070 <free@plt>
L127:
  mov    0x10(%rsp),%rax
  mov    0x28(%rsp),%rdx
  sub    0x20(%rsp),%rdx
  add    $0xc,%rdx
  shl    $0x2,%rax
  cmp    $0x8,%rdx
  jbe    L90
  mov    0x10(%rsp),%rdi
  lea    -0x1(%rdi),%rdx
  cmp    $0x2,%rdx
  jbe    L11
  shr    $0x2,%rdi
  mov    0x20(%rsp),%rcx
  sub    $0x10,%rax
  mov    %rdi,%rdx
  neg    %rdx
  add    %rax,%rcx
  add    0x28(%rsp),%rax
  shl    $0x4,%rdx
  nopw   0x0(%rax,%rax,1)
L89:
  movdqu (%rcx,%rbp,1),%xmm0
  movups %xmm0,(%rax,%rbp,1)
  sub    $0x10,%rbp
  cmp    %rdx,%rbp
  jne    L89
  mov    0x10(%rsp),%rdi
  mov    %rdi,%rax
  and    $0x3,%eax
  and    $0x3,%edi
  je     L129
  mov    0x20(%rsp),%rdi
  lea    0x0(,%rax,4),%rdx
  mov    0x28(%rsp),%rsi
  mov    -0x4(%rdi,%rdx,1),%ecx
  mov    %ecx,-0x4(%rsi,%rdx,1)
  mov    %rax,%rdx
  sub    $0x1,%rdx
  je     L129
  shl    $0x2,%rdx
  mov    -0x4(%rdi,%rdx,1),%ecx
  mov    %ecx,-0x4(%rsi,%rdx,1)
  sub    $0x2,%rax
  je     L129
  shl    $0x2,%rax
  mov    -0x4(%rdi,%rax,1),%edx
  mov    %edx,-0x4(%rsi,%rax,1)
  jmp    L129
L90:
  mov    0x10(%rsp),%rax
  mov    0x20(%rsp),%rsi
  mov    0x28(%rsp),%rdi
  lea    -0x1(%rax),%rdx
  jmp    L56
  nopl   0x0(%rax)
L35:
  sub    $0x1,%rdx
L56:
  mov    -0x4(%rsi,%rax,4),%ecx
  mov    %ecx,-0x4(%rdi,%rax,4)
  mov    %rdx,%rax
  test   %rdx,%rdx
  jne    L35
  jmp    L129
L11:
  mov    %rdi,%rax
  mov    0x20(%rsp),%rsi
  mov    0x28(%rsp),%rdi
  jmp    L56
```

assistant: ```c
void intmsort(int *arr_, size_t n) {
  int *arr = arr_;
  int *workarray = malloc(sizeof(int) * n);
  int *current_ = arr;
  int *work_ = workarray;
  int *swap, *first, *second, *cur, *work;
  size_t sub_array_size = 1;
  size_t counter = 0;
  size_t m, len1, len2;
  while (sub_array_size <= n) {
    m = n;
    cur = current_;
    work = work_;
    while (m) {
      first = cur;
      len1 = (m < sub_array_size) ? m : sub_array_size;
      m -= len1;
      second = cur + len1;
      len2 = (m < sub_array_size) ? m : sub_array_size;
      m -= len2;
      intmerge(first, len1, second, len2, work);
      cur += (len1 + len2);
      work += (len1 + len2);
    }
    swap = current_;
    current_ = work_;
    work_ = swap;
    counter++;
    sub_array_size *= 2;
  }
  if (counter % 2) {
    m = n;
    while (m) {
      arr[m - 1] = workarray[m - 1];
      m--;
    }
  }
  free(workarray);
}
```