user: 请将以下的汇编代码转换成C语言代码:

```asm
<mid_trunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x2d2d2d,-0xc(%rbp)
  cmpq   $0x8,-0x48(%rbp)
  seta   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  cmpq   $0x0,-0x40(%rbp)
  je     L71
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L53
L71:
  cmpq   $0x0,-0x38(%rbp)
  jne    L51
  lea    -0xc(%rbp),%rax
  mov    %rax,%rdi
  call   <mkstring@plt>
  jmp    L119
L51:
  lea    -0xc(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x38(%rbp),%rax
  jmp    L119
L53:
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x20(%rbp)
  mov    -0x20(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  ja     L72
  cmpq   $0x0,-0x38(%rbp)
  jne    L161
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <mkstring@plt>
  jmp    L119
L161:
  mov    -0x40(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x38(%rbp),%rax
  jmp    L119
L72:
  cmpq   $0x0,-0x38(%rbp)
  jne    L93
  mov    -0x48(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x38(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jne    L93
  mov    $0x0,%eax
  jmp    L119
L93:
  mov    -0x48(%rbp),%rax
  shr    %rax
  sub    $0x3,%rax
  mov    %rax,-0x18(%rbp)
  movq   $0x0,-0x30(%rbp)
  jmp    L55
L163:
  mov    -0x40(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    -0x38(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addq   $0x1,-0x30(%rbp)
L55:
  mov    -0x30(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jb     L163
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  mov    -0x38(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x2e,(%rax)
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  mov    -0x38(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x2e,(%rax)
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  mov    -0x38(%rbp),%rdx
  add    %rdx,%rax
  movb   $0x2e,(%rax)
  mov    -0x48(%rbp),%rax
  shr    %rax
  mov    %rax,%rdx
  mov    -0x20(%rbp),%rax
  sub    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  jmp    L104
L66:
  mov    -0x40(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    -0x38(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addq   $0x1,-0x30(%rbp)
  addq   $0x1,-0x28(%rbp)
L104:
  mov    -0x30(%rbp),%rax
  cmp    -0x48(%rbp),%rax
  jb     L66
  mov    -0x38(%rbp),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x38(%rbp),%rax
L119:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L100
  call   <__stack_chk_fail@plt>
L100:
  leave
  ret
```

assistant: ```c
char *mid_trunc(char *str, const char *input, unsigned long len) {
  unsigned long ilen;
  unsigned long middle;
  unsigned long i, j;
  char defstr[4] = "---";
  assert(len > 8);
  if ((input == NULL) || (input[0] == 0)) {
    if (NULL == str) {
      return (mkstring(defstr));
    } else {
      strcpy(str, defstr);
      return (str);
    }
  }
  ilen = strlen(input);
  if (ilen <= len) {
    if (NULL == str)
      return (mkstring(input));
    else {
      strcpy(str, input);
      return (str);
    }
  } else {
    if (NULL == str) {
      if (NULL == (str = (char *)malloc(len + 1)))
        return (NULL);
    }
    middle = (len / 2) - 3;
    i = 0;
    while (i < middle) {
      str[i] = input[i];
      i++;
    }
    str[i++] = '.';
    str[i++] = '.';
    str[i++] = '.';
    j = ilen - (len / 2);
    while (i < len) {
      str[i] = input[j];
      i++;
      j++;
    }
    str[i] = 0;
    return (str);
  }
}
```