user: Converte this assembly snippet into its equivalent C code:

```asm
<valid_domain>:
  endbr64
  movzbl (%rdi),%eax
  cmp    $0x5b,%al
  je     L115
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  sub    $0x41,%edx
  cmp    $0x19,%dl
  ja     L163
L126:
  lea    0x1(%rdi),%rax
  mov    $0x1,%edx
  nopl   0x0(%rax)
L35:
  movzbl (%rax),%ecx
  cmp    $0x2d,%cl
  je     L2
L140:
  cmp    $0x2e,%cl
  je     L2
  mov    %ecx,%esi
  and    $0xffffffdf,%esi
  sub    $0x41,%esi
  cmp    $0x19,%sil
  jbe    L68
  lea    -0x30(%rcx),%esi
  cmp    $0x9,%sil
  ja     L65
L68:
  add    $0x1,%rdx
  cmp    $0x100,%rdx
  je     L179
  movzbl 0x1(%rax),%ecx
  add    $0x1,%rax
  cmp    $0x2d,%cl
  jne    L140
L2:
  cmp    $0xff,%rdx
  je     L179
  movzbl 0x1(%rax),%esi
  mov    %esi,%ecx
  and    $0xffffffdf,%ecx
  sub    $0x41,%ecx
  cmp    $0x19,%cl
  jbe    L128
  sub    $0x30,%esi
  cmp    $0x9,%sil
  ja     L179
L128:
  add    $0x2,%rdx
  cmp    $0x100,%rdx
  je     L179
  add    $0x2,%rax
  jmp    L35
  nopl   0x0(%rax)
L115:
  lea    0x1(%rdi),%rax
  xor    %edi,%edi
  cs nopw 0x0(%rax,%rax,1)
L177:
  movzbl (%rax),%edx
  lea    -0x30(%rdx),%ecx
  cmp    $0x9,%cl
  ja     L179
  sub    $0x30,%edx
L148:
  movzbl 0x1(%rax),%ecx
  add    $0x1,%rax
  cmp    $0x2e,%cl
  je     L142
  lea    -0x30(%rcx),%esi
  cmp    $0x9,%sil
  ja     L153
  lea    (%rdx,%rdx,4),%edx
  lea    -0x30(%rcx,%rdx,2),%edx
  cmp    $0xff,%edx
  jle    L148
L179:
  mov    $0xffffffff,%eax
  ret
L163:
  sub    $0x30,%eax
  cmp    $0x9,%al
  jbe    L126
  jmp    L179
  cs nopw 0x0(%rax,%rax,1)
L142:
  add    $0x1,%edi
  cmp    $0x4,%edi
  je     L179
  add    $0x1,%rax
  jmp    L177
L153:
  cmp    $0x5d,%cl
  jne    L179
  cmp    $0x3,%edi
  jne    L179
  movzbl 0x1(%rax),%ecx
L65:
  neg    %cl
  sbb    %eax,%eax
  ret
```

assistant: ```c
int valid_domain(const unsigned char *domain) {
  const unsigned char *ptr;
  int state;
  int n;
  int ndots;
  size_t len;
  ptr = domain;
  if (*ptr == '[') {
    ptr++;
    ndots = 0;
    state = 0;
    do {
      if (state == 0) {
        if (!((*ptr >= '0') && (*ptr <= '9'))) {
          return -1;
        }
        n = *ptr - '0';
        state = 1;
      } else {
        if (*ptr == '.') {
          if (++ndots > 3) {
            return -1;
          }
          state = 0;
        } else if (((*ptr >= '0') && (*ptr <= '9'))) {
          n = (n * 10) + (*ptr - '0');
          if (n > 255) {
            return -1;
          }
        } else if (*ptr == ']') {
          break;
        } else {
          return -1;
        }
      }
      ptr++;
    } while (1);
    if (ndots != 3) {
      return -1;
    }
    ptr++;
  } else {
    if ((!(((*ptr >= 'A') && (*ptr <= 'Z')) || ((*ptr >= 'a') && (*ptr <= 'z')))) && (!((*ptr >= '0') && (*ptr <= '9')))) {
      return -1;
    }
    ptr++;
    len = 1;
    state = 0;
    do {
      if (state == 0) {
        if (*ptr == '-') {
          state = 1;
        } else if (*ptr == '.') {
          state = 2;
        } else if ((!(((*ptr >= 'A') && (*ptr <= 'Z')) || ((*ptr >= 'a') && (*ptr <= 'z')))) && (!((*ptr >= '0') && (*ptr <= '9')))) {
          break;
        }
      } else if (state == 1) {
        if ((!(((*ptr >= 'A') && (*ptr <= 'Z')) || ((*ptr >= 'a') && (*ptr <= 'z')))) && (!((*ptr >= '0') && (*ptr <= '9')))) {
          return -1;
        }
        state = 0;
      } else {
        if ((!(((*ptr >= 'A') && (*ptr <= 'Z')) || ((*ptr >= 'a') && (*ptr <= 'z')))) && (!((*ptr >= '0') && (*ptr <= '9')))) {
          return -1;
        }
        state = 0;
      }
      if (++len > 255) {
        return -1;
      }
      ptr++;
    } while (1);
  }
  if (*ptr) {
    return -1;
  }
  return 0;
}
```