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

```asm
<heap_to_tieheap>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  cmpl   $0x1,-0x2c(%rbp)
  jle    L46
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jne    L49
L46:
  mov    -0x38(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L35
L49:
  mov    -0x28(%rbp),%rdx
  mov    -0x40(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x2c(%rbp),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  je     L69
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    -0x48(%rbp),%rcx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   *%rcx
  test   %eax,%eax
  jne    L35
L69:
  mov    -0x40(%rbp),%rax
  lea    D35(%rip),%rdx
  lea    D12(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <malloc_error@plt>
  mov    %rax,-0x10(%rbp)
L41:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  jne    L48
  mov    -0x38(%rbp),%rax
  movl   $0x0,(%rax)
  jmp    L56
L48:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  cltq
  imul   -0x40(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x40(%rbp),%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x40(%rbp),%rdx
  mov    -0x8(%rbp),%rcx
  mov    -0x20(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x40(%rbp),%rdx
  mov    -0x10(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x38(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x38(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x48(%rbp),%rsi
  mov    -0x40(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rsi,%r8
  mov    %rax,%rsi
  mov    $0x1,%edi
  call   <heap_down@plt>
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    -0x48(%rbp),%rcx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   *%rcx
  test   %eax,%eax
  je     L41
L56:
  mov    -0x10(%rbp),%rax
  lea    D35(%rip),%rdx
  lea    D12(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <free_error@plt>
L35:
  nop
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D35
type: string
name: parse_data
arguments: data_tag: D12
type: string

tool: D35: heap_to_tieheap()

tool: D12: elt_1

assistant: ```c
void heap_to_tieheap(void *tieheap, int count, int *heap_count, size_t size, int (*compar)(const void *elt1, const void *elt2)) {
  void *elt_1;
  void *heap_1;
  void *heap_end;
  void *tieheap_end;
  if ((count <= 1) || (*heap_count == 0))
    *heap_count = 0;
  else {
    heap_1 = (char *)tieheap + size;
    tieheap_end = (char *)tieheap + size * count;
    if ((*heap_count == count) || ((*compar)(heap_1, tieheap_end) == 0)) {
      elt_1 = malloc_error(size, "elt_1", "heap_to_tieheap()");
      do {
        if (*heap_count == 1) {
          *heap_count = 0;
          break;
        } else {
          heap_end = (char *)tieheap + *heap_count * size;
          memcpy(elt_1, heap_1, size);
          memcpy(heap_1, heap_end, size);
          memcpy(heap_end, elt_1, size);
          --(*heap_count);
          heap_down(1, tieheap, *heap_count, size, compar);
        }
      } while ((*compar)(heap_1, tieheap_end) == 0);
      free_error(elt_1, "elt_1", "heap_to_tieheap()");
    }
  }
}
```