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

```asm
<realhostname>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  mov    D4(%rip),%rax
  mov    %rsp,%rcx
  movslq (%rax),%rax
  mov    %rax,%r15
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L131
L70:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L70
L131:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L118
L97:
  mov    D29(%rip),%rax
  mov    $0x4,%esi
  mov    %rbx,%rdi
  mov    %rsp,-0x50(%rbp)
  mov    (%rax),%edx
  call   <gethostbyaddr@plt>
  mov    %rax,%r14
  test   %rax,%rax
  je     L62
  mov    (%rax),%rsi
  mov    %r15d,%edx
  mov    %rsp,%rdi
  call   <strlcpy@plt>
  mov    %rsp,%rdi
  call   <strlen@plt>
  mov    %rsp,%rdi
  mov    %rax,%rsi
  call   <trimdomain@plt>
  mov    %rsp,%rdi
  call   <strlen@plt>
  cmp    %r12,%rax
  jbe    L51
L62:
  mov    $0x2,%r14d
L22:
  mov    (%rbx),%edi
  call   <inet_ntoa@plt>
  mov    %r12,%rdx
  mov    %r13,%rdi
  mov    %rax,%rsi
  call   <strncpy@plt>
L34:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L130
  lea    -0x28(%rbp),%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L51:
  mov    D4(%rip),%rax
  mov    %rsp,-0x48(%rbp)
  mov    %rsp,%rsi
  movslq (%rax),%r15
  lea    0xf(%r15),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  and    $0xfffffffffffffff0,%rdx
  sub    %rax,%rsi
L135:
  cmp    %rsi,%rsp
  je     L161
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L135
  nopl   0x0(%rax)
L118:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L97
  nopl   0x0(%rax,%rax,1)
L161:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L186
L20:
  mov    (%r14),%rsi
  lea    -0x1(%r15),%rdx
  mov    %rsp,%rdi
  call   <strncpy@plt>
  movb   $0x0,-0x1(%rsp,%r15,1)
  mov    %rsp,%rdi
  call   <gethostbyname@plt>
  mov    %rax,%r15
  test   %rax,%rax
  je     L3
  mov    0x8(%rax),%rax
  mov    (%rax),%rdi
  test   %rdi,%rdi
  jne    L185
  jmp    L127
  nopl   (%rax)
L166:
  mov    0x8(%r15),%rax
  mov    0x8(%rax),%rdi
  lea    0x8(%rax),%rdx
  mov    %rdx,0x8(%r15)
  test   %rdi,%rdi
  je     L127
L185:
  mov    $0x4,%edx
  mov    %rbx,%rsi
  call   <memcmp@plt>
  mov    %eax,%r14d
  test   %eax,%eax
  jne    L166
  mov    -0x50(%rbp),%rsi
  mov    %r12,%rdx
  mov    %r13,%rdi
  call   <strncpy@plt>
  mov    -0x48(%rbp),%rsp
  jmp    L34
  nopl   0x0(%rax)
L3:
  mov    $0x3,%r14d
L11:
  mov    -0x48(%rbp),%rsp
  jmp    L22
  nop
L127:
  mov    $0x1,%r14d
  jmp    L11
  nopl   0x0(%rax,%rax,1)
L186:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L20
L130:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int realhostname(char *host, size_t hsize, const struct in_addr *ip) {
  char trimmed[MAXHOSTNAMELEN];
  int result;
  struct hostent *hp;
  result = (2);
  hp = gethostbyaddr((const char *)ip, sizeof(*ip), AF_INET);
  if (hp != NULL) {
    strlcpy(trimmed, hp->h_name, sizeof(trimmed));
    trimdomain(trimmed, strlen(trimmed));
    if (strlen(trimmed) <= hsize) {
      char lookup[MAXHOSTNAMELEN];
      strncpy(lookup, hp->h_name, sizeof(lookup) - 1);
      lookup[sizeof(lookup) - 1] = '\0';
      hp = gethostbyname(lookup);
      if (hp == NULL)
        result = (3);
      else
        for (;; hp->h_addr_list++) {
          if (*hp->h_addr_list == NULL) {
            result = (1);
            break;
          }
          if (!memcmp(*hp->h_addr_list, ip, sizeof(*ip))) {
            strncpy(host, trimmed, hsize);
            return (0);
          }
        }
    }
  }
  strncpy(host, inet_ntoa(*ip), hsize);
  return result;
}
```