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

```asm
<str_trim>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  mov    %rbp,%rdi
  mov    %rax,%r12
  call   <strlen@plt>
  test   %eax,%eax
  je     L76
  movzbl 0x0(%rbp),%edx
  cmp    $0x1,%eax
  je     L85
  mov    %r12d,%ebx
  cmp    $0x20,%dl
  jne    L159
  mov    $0x1,%edx
  nopw   0x0(%rax,%rax,1)
L39:
  mov    %r12d,%ebx
  mov    %edx,%r13d
  sub    %edx,%ebx
  add    $0x1,%rdx
  cmpb   $0x20,-0x1(%rbp,%rdx,1)
  je     L39
L113:
  sub    $0x1,%eax
  cltq
  add    %rbp,%rax
  cmpb   $0x20,(%rax)
  jne    L246
  nopl   0x0(%rax)
L20:
  sub    $0x1,%rax
  mov    %ebx,%edi
  sub    $0x1,%ebx
  cmpb   $0x20,(%rax)
  je     L20
L41:
  call   <malloc@plt>
  mov    %rax,%r12
  test   %ebx,%ebx
  jle    L136
  movslq %r13d,%rdx
  mov    %r12,%rcx
  lea    -0x1(%rbx),%eax
  mov    %ebx,%esi
  lea    0x1(%rbp,%rdx,1),%rdi
  sub    %rdi,%rcx
  cmp    $0xe,%rcx
  jbe    L50
  cmp    $0x6,%eax
  jbe    L50
  cmp    $0xe,%eax
  jbe    L59
  mov    %ebx,%ecx
  add    %rbp,%rdx
  xor    %eax,%eax
  shr    $0x4,%ecx
  shl    $0x4,%rcx
  nopl   0x0(%rax,%rax,1)
L107:
  movdqu (%rdx,%rax,1),%xmm0
  movups %xmm0,(%r12,%rax,1)
  add    $0x10,%rax
  cmp    %rcx,%rax
  jne    L107
  mov    %ebx,%ecx
  and    $0xfffffff0,%ecx
  mov    %ecx,%eax
  cmp    %ecx,%ebx
  je     L136
  mov    %ebx,%esi
  sub    %ecx,%esi
  lea    -0x1(%rsi),%edi
  cmp    $0x6,%edi
  jbe    L131
L198:
  mov    (%rdx,%rcx,1),%rdx
  mov    %rdx,(%r12,%rcx,1)
  mov    %esi,%edx
  and    $0xfffffff8,%edx
  add    %edx,%eax
  cmp    %edx,%esi
  je     L136
L131:
  lea    0x0(%r13,%rax,1),%edx
  movslq %edx,%rdx
  movzbl 0x0(%rbp,%rdx,1),%ecx
  movslq %eax,%rdx
  mov    %cl,(%r12,%rdx,1)
  lea    0x1(%rax),%edx
  cmp    %ebx,%edx
  jge    L136
  lea    (%rdx,%r13,1),%ecx
  movslq %edx,%rdx
  movslq %ecx,%rcx
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,(%r12,%rdx,1)
  lea    0x2(%rax),%edx
  cmp    %ebx,%edx
  jge    L136
  lea    (%rdx,%r13,1),%ecx
  movslq %edx,%rdx
  movslq %ecx,%rcx
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,(%r12,%rdx,1)
  lea    0x3(%rax),%edx
  cmp    %edx,%ebx
  jle    L136
  lea    0x0(%r13,%rdx,1),%ecx
  movslq %edx,%rdx
  movslq %ecx,%rcx
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,(%r12,%rdx,1)
  lea    0x4(%rax),%edx
  cmp    %edx,%ebx
  jle    L136
  lea    0x0(%r13,%rdx,1),%ecx
  movslq %edx,%rdx
  movslq %ecx,%rcx
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,(%r12,%rdx,1)
  lea    0x5(%rax),%edx
  cmp    %edx,%ebx
  jle    L136
  lea    0x0(%r13,%rdx,1),%ecx
  add    $0x6,%eax
  movslq %edx,%rdx
  movslq %ecx,%rcx
  movzbl 0x0(%rbp,%rcx,1),%ecx
  mov    %cl,(%r12,%rdx,1)
  cmp    %eax,%ebx
  jle    L136
  add    %eax,%r13d
  cltq
  movslq %r13d,%r13
  movzbl 0x0(%rbp,%r13,1),%edx
  mov    %dl,(%r12,%rax,1)
L136:
  movslq %ebx,%rbx
  movb   $0x0,(%r12,%rbx,1)
L153:
  mov    %rbp,%rdi
  call   <free@plt>
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L76:
  mov    $0x1,%edi
  call   <malloc@plt>
  movb   $0x0,(%rax)
  mov    %rax,%r12
  add    $0x8,%rsp
  pop    %rbx
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L50:
  mov    %ebx,%esi
  xor    %eax,%eax
  add    %rbp,%rdx
  nopw   0x0(%rax,%rax,1)
L14:
  movzbl (%rdx,%rax,1),%ecx
  mov    %cl,(%r12,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L14
  jmp    L136
  nopl   0x0(%rax,%rax,1)
L85:
  cmp    $0x20,%dl
  je     L132
  mov    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  movzbl 0x0(%rbp),%eax
  movb   $0x0,0x1(%r12)
  mov    %al,(%r12)
  jmp    L153
  nopl   (%rax)
L159:
  xor    %r13d,%r13d
  jmp    L113
  nopl   0x0(%rax,%rax,1)
L246:
  lea    0x1(%rbx),%edi
  jmp    L41
L132:
  mov    $0x1,%edi
  call   <malloc@plt>
  movb   $0x0,(%rax)
  mov    %rax,%r12
  jmp    L153
L59:
  xor    %ecx,%ecx
  xor    %eax,%eax
  add    %rbp,%rdx
  jmp    L198
```

assistant: ```c
char *str_trim(char *string) {
  int final_len = strlen(string);
  int i = 0;
  const int len = strlen(string);
  if (len == 0) {
    char *output = malloc(sizeof(char));
    output[0] = '\0';
    return output;
  }
  if (len == 1) {
    char *output;
    if (string[0] != ' ') {
      output = malloc(sizeof(char) * 2);
      output[0] = string[0];
      output[1] = '\0';
    } else {
      output = malloc(sizeof(char));
      output[0] = '\0';
    }
    free(string);
    return output;
  }
  while (true) {
    if (string[i] != ' ') {
      break;
    } else {
      final_len -= 1;
      i += 1;
    }
  }
  int k = len - 1;
  while (true) {
    if (string[k] != ' ') {
      break;
    } else {
      final_len -= 1;
      k -= 1;
    }
  }
  char *output = malloc(sizeof(char) * (final_len + 1));
  for (int l = 0; l < final_len; l += 1) {
    output[l] = string[l + i];
  }
  output[final_len] = '\0';
  free(string);
  return output;
}
```