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

```asm
<validate_netmask>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  cmp    $0x12,%eax
  jg     L342
  xor    %ebx,%ebx
  xor    %r13d,%r13d
  xor    %r12d,%r12d
  jmp    L452
  nopl   (%rax)
L118:
  and    $0xffffffdf,%eax
  xor    %edx,%edx
  cmp    $0x58,%al
  jne    L26
L157:
  add    $0x1,%r13d
L432:
  add    $0x1,%rbx
L452:
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    %ebx,%eax
  jle    L459
  test   %r12d,%r12d
  jne    L427
  movsbl 0x0(%rbp,%rbx,1),%edi
  call   <isxdigit@plt>
  test   %eax,%eax
  movzbl 0x0(%rbp,%rbx,1),%eax
  jne    L118
  and    $0xffffffdf,%eax
  xor    %edx,%edx
  cmp    $0x58,%al
  setne  %dl
  cmp    $0x58,%al
  je     L157
L26:
  mov    %edx,%r12d
  jmp    L432
  nopl   0x0(%rax,%rax,1)
L459:
  and    $0x1,%r12d
  jne    L427
  cmp    $0x1,%r13d
  jne    L427
  movzbl 0x0(%rbp),%edx
  mov    $0x3,%eax
  mov    %edx,%ecx
  and    $0xffffffdf,%ecx
  cmp    $0x58,%cl
  je     L304
  cmp    $0x30,%dl
  je     L176
L427:
  lea    0x10(%rsp),%r12
  mov    $0x10,%esi
  mov    %r12,%rdi
  call   <bzero@plt>
  mov    $0x2f,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L297
  mov    $0xf,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  movb   $0x0,0x1f(%rsp)
  call   <strncpy@plt>
  nopl   0x0(%rax)
L24:
  lea    0xc(%rsp),%rsi
  mov    %r12,%rdi
  call   <quadtonum@plt>
  test   %rax,%rax
  jne    L342
  mov    $0x2f,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L148
  lea    0x1(%rax),%r15
  mov    %r15,%rdi
  call   <strlen@plt>
  test   %eax,%eax
  jg     L229
  nop
L342:
  xor    %eax,%eax
L304:
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L189
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L297:
  movzbl 0x0(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x10(%rsp)
  movzbl 0x1(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x11(%rsp)
  movzbl 0x2(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x12(%rsp)
  movzbl 0x3(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x13(%rsp)
  movzbl 0x4(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x14(%rsp)
  movzbl 0x5(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x15(%rsp)
  movzbl 0x6(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x16(%rsp)
  movzbl 0x7(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x17(%rsp)
  movzbl 0x8(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x18(%rsp)
  movzbl 0x9(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x19(%rsp)
  movzbl 0xa(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x1a(%rsp)
  movzbl 0xb(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x1b(%rsp)
  movzbl 0xc(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x1c(%rsp)
  movzbl 0xd(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x1d(%rsp)
  movzbl 0xe(%rbp),%eax
  cmp    $0x2f,%al
  je     L24
  mov    %al,0x1e(%rsp)
  jmp    L24
  nopl   0x0(%rax)
L229:
  mov    %r15,%rdi
  call   <strlen@plt>
  cmp    $0x2,%eax
  jg     L342
  cmpb   $0x2e,0x1(%rbx)
  je     L342
  cmpb   $0x2e,0x2(%rbx)
  je     L342
  lea    D7(%rip),%r12
  mov    %r15,%rbp
  xor    %r14d,%r14d
  lea    -0x1(%r12),%r13
  nopw   0x0(%rax,%rax,1)
L43:
  mov    %r15,%rdi
  call   <strlen@plt>
  cmp    %r14d,%eax
  jle    L428
  xor    %ebx,%ebx
  nopl   0x0(%rax,%rax,1)
L435:
  mov    %r12,%rdi
  call   <strlen@plt>
  cmp    %ebx,%eax
  jle    L342
  add    $0x1,%rbx
  movzbl 0x0(%r13,%rbx,1),%eax
  cmp    %al,0x0(%rbp)
  jne    L435
  mov    %r12,%rdi
  add    $0x1,%r14d
  add    $0x1,%rbp
  call   <strlen@plt>
  jmp    L43
  nopl   0x0(%rax)
L176:
  movzbl 0x1(%rbp),%edx
  and    $0xffffffdf,%edx
  cmp    $0x58,%dl
  jne    L427
  jmp    L304
  nopl   (%rax)
L148:
  mov    0xc(%rsp),%esi
  xor    %edx,%edx
  mov    $0x1f,%edi
  nopl   0x0(%rax,%rax,1)
L483:
  mov    %edi,%ecx
  mov    %esi,%eax
  sub    %edx,%ecx
  sar    %cl,%eax
  and    $0x1,%eax
  jne    L270
  mov    $0x1f,%ecx
L233:
  mov    %ecx,%eax
  sub    %edx,%eax
  add    $0x1,%edx
  bt     %eax,%esi
  jae    L347
  mov    $0xffffffff,%eax
  jmp    L304
L347:
  cmp    $0x20,%edx
  jne    L233
  mov    $0x1,%eax
  jmp    L304
  nop
L270:
  add    $0x1,%edx
  cmp    $0x20,%edx
  jne    L483
  jmp    L304
L428:
  mov    %r15,%rdi
  call   <atoi@plt>
  cmp    $0x20,%eax
  setbe  %al
  movzbl %al,%eax
  add    %eax,%eax
  jmp    L304
L189:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D7
datatype: string

tool: D7: 0123456789.

assistant: ```c
int validate_netmask(char *in_addr) {
  int x, y, z, m;
  char addr[16];
  char *sl;
  u_int32_t sm;
  if (strlen(in_addr) > 18)
    return 0;
  x = 0;
  y = 0;
  z = 0;
  while (x < strlen(in_addr) && !y) {
    if (!isxdigit(in_addr[x]) && in_addr[x] != 'x' && in_addr[x] != 'X')
      y = 1;
    if (in_addr[x] == 'x' || in_addr[x] == 'X') {
      z++;
      y = 0;
    }
    x++;
  }
  x = 0;
  if (!y && z == 1) {
    x = 0;
    if (in_addr[0] == 'x' || in_addr[0] == 'X')
      x = 1;
    if (!x) {
      if (in_addr[0] == '0' && (in_addr[1] == 'x' || in_addr[1] == 'X'))
        x = 1;
    }
  }
  if (x == 1)
    return 3;
  bzero((char *)addr, sizeof(addr));
  if (strstr(in_addr, "/")) {
    x = 0;
    while (in_addr[x] != '/' && x < 15) {
      addr[x] = in_addr[x];
      x++;
    }
  } else {
    strncpy(addr, in_addr, sizeof(addr) - 1 + (addr[sizeof(addr) - 1] = '\0') * 0);
  }
  if (quadtonum(addr, &sm))
    return 0;
  if (!(sl = strstr(in_addr, "/"))) {
    y = 0;
    for (x = 0; x < 32; x++) {
      if (!y && !((sm >> (31 - x)) & 1))
        y = 1;
      if (y == 1 && ((sm >> (31 - x)) & 1))
        y = 2;
    }
    if (y == 2)
      return -1;
    return 1;
  }
  sl++;
  if (strlen(sl) < 1 || strlen(sl) > 2)
    return 0;
  if (sl[0] == '.' || sl[1] == '.')
    return 0;
  x = 0;
  y = 0;
  while (x < strlen(sl)) {
    z = 0;
    y = 0;
    while (z < strlen("0123456789.") && !y) {
      if (sl[x] == "0123456789."[z])
        y = 1;
      z++;
    }
    if (!y)
      return 0;
    x++;
  }
  m = atoi(sl);
  if (m < 0 || m > 32)
    return 0;
  return 2;
}
```