user: 请从给定的汇编指令推导出C源代码:

```asm
<addname>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %r9,-0x50(%rbp)
  mov    -0x50(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x50(%rbp),%rax
  mov    (%rax),%rdi
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x30(%rbp),%rax
  lea    0x0(,%rax,4),%rsi
  mov    -0x28(%rbp),%rax
  add    %rax,%rsi
  mov    -0x28(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <dn_expand@plt>
  mov    %eax,-0x1c(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  js     L135
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  mov    -0x40(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <prune_origin@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L23
  cmpq   $0x0,-0x18(%rbp)
  jne    L40
  mov    -0x18(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0x50(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  ja     L146
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  add    %rcx,%rax
  movb   $0x40,(%rax)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  jmp    L50
L40:
  cmpq   $0x0,-0x40(%rbp)
  je     L70
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L70
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  je     L50
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L50
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L50
L70:
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  sub    $0x1,%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  je     L50
  jmp    L158
L23:
  nop
L158:
  mov    -0x18(%rbp),%rax
  lea    0x2(%rax),%rdx
  mov    -0x50(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  ja     L154
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rcx
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  add    %rcx,%rax
  movb   $0x2e,(%rax)
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L50:
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x50(%rbp),%rdx
  mov    -0x48(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <addlen@plt>
  mov    -0x48(%rbp),%rax
  mov    (%rax),%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  jmp    L85
L135:
  nop
  jmp    L86
L146:
  nop
  jmp    L86
L154:
  nop
L86:
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <__set_errno@plt>
  mov    -0x48(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x50(%rbp),%rax
  mov    -0x10(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
L85:
  leave
  ret
```

assistant: ```c
int addname(const u_char *msg, size_t msglen, const u_char **pp, const char *origin, char **buf, size_t *buflen) {
  size_t newlen, save_buflen = *buflen;
  char *save_buf = *buf;
  int n;
  n = dn_expand(msg, msg + msglen, *pp, *buf, *buflen);
  if (n < 0)
    goto enospc;
  newlen = prune_origin(*buf, origin);
  if (**buf == '\0') {
    goto root;
  } else if (newlen == 0U) {
    if (newlen + 2 > *buflen)
      goto enospc;
    (*buf)[newlen++] = '@';
    (*buf)[newlen] = '\0';
  } else {
    if (((origin == NULL || origin[0] == '\0') || (origin[0] != '.' && origin[1] != '\0' && (*buf)[newlen] == '\0')) && (*buf)[newlen - 1] != '.') {
    root:
      if (newlen + 2 > *buflen)
        goto enospc;
      (*buf)[newlen++] = '.';
      (*buf)[newlen] = '\0';
    }
  }
  *pp += n;
  addlen(newlen, buf, buflen);
  **buf = '\0';
  return (newlen);
enospc:
  __set_errno(ENOSPC);
  *buf = save_buf;
  *buflen = save_buflen;
  return (-1);
}
```