user: Translate the below assembly code into C programming language:

```asm
<mid_trunc>:
  endbr64
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  xor    %edi,%edi
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  cmp    $0x8,%rdx
  movl   $0x2d2d2d,0x4(%rsp)
  seta   %dil
  call   <assert@plt>
  test   %rbp,%rbp
  je     L30
  cmpb   $0x0,0x0(%rbp)
  jne    L54
L30:
  test   %rbx,%rbx
  je     L99
  lea    0x4(%rsp),%rsi
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
L143:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L168
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L54:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%r13
  cmp    %rax,%r12
  jae    L71
  test   %rbx,%rbx
  je     L55
L57:
  mov    %r12,%rdx
  shr    %rdx
  mov    %rdx,%rsi
  sub    $0x3,%rsi
  je     L50
  xor    %eax,%eax
  nopw   0x0(%rax,%rax,1)
L152:
  movzbl 0x0(%rbp,%rax,1),%ecx
  mov    %cl,(%rbx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L152
  add    %rbx,%rsi
  lea    -0x2(%rdx),%rdi
  lea    -0x1(%rdx),%rax
  mov    %rdx,%rcx
L22:
  movb   $0x2e,(%rsi)
  movb   $0x2e,(%rbx,%rdi,1)
  movb   $0x2e,(%rbx,%rax,1)
  mov    %r13,%rax
  sub    %rdx,%rax
  cmp    %rcx,%r12
  jbe    L106
  sub    %r13,%rdx
  lea    (%r12,%rax,1),%rsi
  add    %rcx,%rdx
  sub    %rcx,%rsi
  add    %rbx,%rdx
  nopl   0x0(%rax)
L11:
  movzbl 0x0(%rbp,%rax,1),%ecx
  mov    %cl,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L11
L179:
  movb   $0x0,(%rbx,%r12,1)
  mov    %rbx,%rax
  jmp    L143
  xchg   %ax,%ax
L99:
  lea    0x4(%rsp),%rdi
  call   <mkstring@plt>
  jmp    L143
  nop
L71:
  test   %rbx,%rbx
  je     L87
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strcpy@plt>
  mov    %rbx,%rax
  jmp    L143
  nopl   0x0(%rax,%rax,1)
L87:
  mov    %rbp,%rdi
  call   <mkstring@plt>
  jmp    L143
  nopl   (%rax)
L55:
  lea    0x1(%r12),%rdi
  call   <malloc@plt>
  mov    %rax,%rdx
  xor    %eax,%eax
  test   %rdx,%rdx
  je     L143
  mov    %rdx,%rbx
  jmp    L57
L106:
  mov    %rcx,%r12
  jmp    L179
  nopl   (%rax)
L50:
  mov    %rbx,%rsi
  mov    $0x3,%ecx
  mov    $0x2,%eax
  mov    $0x1,%edi
  jmp    L22
L168:
  call   <__stack_chk_fail@plt>
```

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);
  }
}
```