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

```asm
<valid_domainname>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L18
  movzbl (%rdi),%eax
  mov    %rdi,%r13
  test   %al,%al
  je     L18
  xor    %ebp,%ebp
  and    $0x100,%esi
  lea    0x1(%rdi),%rbx
  mov    $0x1,%ecx
  jne    L97
  cmp    $0x20,%al
  je     L31
L56:
  cmp    $0x2e,%al
  je     L156
  cmp    $0x2d,%al
  sete   %dl
  cmp    $0x5f,%al
  sete   %sil
  or     %sil,%dl
  je     L68
  test   %ecx,%ecx
  jne    L68
  testb  $0xdf,(%rbx)
  jne    L250
L68:
  movzbl %al,%edi
  call   <isalnum@plt>
  test   %rax,%rax
  je     L31
L250:
  add    $0x1,%ebp
  cmp    $0x40,%ebp
  je     L159
  xor    %ecx,%ecx
L98:
  movzbl (%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  je     L296
  cmp    $0x20,%al
  jne    L56
L31:
  xor    %ebx,%ebx
L148:
  mov    D5(%rip),%rax
  mov    (%rax),%edx
L251:
  mov    D18(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  test   %rbx,%rbx
  je     L263
  movb   $0x0,(%rbx)
L296:
  mov    $0x1,%eax
L263:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L156:
  cmpb   $0x2e,(%rbx)
  je     L31
  xor    %ebp,%ebp
  jmp    L98
  nopl   0x0(%rax)
L18:
  mov    D5(%rip),%rax
  mov    (%rax),%edx
  mov    D18(%rip),%rax
  mov    %edx,(%rax)
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L97:
  mov    %rdi,%rbp
  xor    %r12d,%r12d
  mov    $0x1,%ecx
  xor    %ebx,%ebx
  cmp    $0x20,%al
  je     L88
L128:
  cmp    $0x2e,%al
  je     L197
  cmp    $0x5f,%al
  sete   %dl
  cmp    $0x2d,%al
  sete   %sil
  or     %sil,%dl
  je     L203
  test   %ecx,%ecx
  jne    L203
  testb  $0xdf,0x1(%rbp)
  jne    L204
L203:
  movzbl %al,%edi
  call   <isalnum@plt>
  test   %rax,%rax
  je     L148
L204:
  add    $0x1,%r12d
  cmp    $0x40,%r12d
  je     L162
  xor    %ecx,%ecx
L219:
  movzbl 0x1(%rbp),%eax
  add    $0x1,%rbp
  test   %al,%al
  je     L296
  cmp    $0x20,%al
  jne    L128
L88:
  cmp    %rbp,%r13
  je     L148
  xor    %r12d,%r12d
  test   %ecx,%ecx
  jne    L219
  mov    %rbp,%rbx
  mov    $0x1,%ecx
  jmp    L219
  nopw   0x0(%rax,%rax,1)
L197:
  cmpb   $0x2e,0x1(%rbp)
  je     L148
  xor    %r12d,%r12d
  jmp    L219
L159:
  xor    %ebx,%ebx
L162:
  mov    D0(%rip),%rax
  mov    (%rax),%edx
  jmp    L251
```

assistant: ```c
int valid_domainname(char *lbl, int type) {
  char *slbl, *lst;
  unsigned char c;
  int start, len, errset;
  if (lbl == NULL || *lbl == '\0') {
    errno = EINVAL;
    return 0;
  }
  slbl = lbl;
  lst = NULL;
  start = 1;
  len = errset = 0;
  for (;;) {
    c = (unsigned char)*lbl++;
    if (c == '\0')
      return 1;
    if (c == ' ') {
      if (lbl - 1 == slbl)
        break;
      if (!(type & (1 << 8)))
        break;
      if (!start) {
        start = 1;
        lst = lbl - 1;
      }
      if (len)
        len = 0;
      continue;
    }
    if (c == '.') {
      if (*lbl == '.')
        break;
      len = 0;
      continue;
    }
    if (((c == '-' || c == '_') && !start && *lbl != ' ' && *lbl != '\0') || isalnum(c)) {
      if (++len > 63) {
        errno = ERANGE;
        errset = 1;
        break;
      }
    } else
      break;
    if (start)
      start = 0;
  }
  if (!errset)
    errno = EINVAL;
  if (lst) {
    *lst = '\0';
    return 1;
  }
  return 0;
}
```