// File: /workspace/github_c_makefile_star2_O1/agl[P]obstcp/libobstcp.c
// Function: obstcp_advert_cname_extract
int EXPORTED
obstcp_advert_cname_extract(char *output, unsigned *ooutlen, const char *name) {
  unsigned j = 0;  // current offset into output
  const unsigned outlen = *ooutlen;

  while (*name) {
    if (strncmp(name, kDNSMagic, kDNSMagicLen) == 0) {
      char good = 1;
      unsigned count = 0;
      const char *i;

      for (i = name + kDNSMagicLen; *i; ++i, count++) {
        const char c = *i;
        if (c == '.' || !c)
          break;
        if ((c >= '0' && c <= '9') ||
          (c > 'a' && c <= 'z' && c != 'e' && c != 'i' && c != 'o') ||
          (c > 'A' && c <= 'Z' && c != 'E' && c != 'I' && c != 'O'))
          continue;
        good = 0;
        break;
      }

      if (!count)
        good = 0;

      if (good) {
        if (!buffer_put((uint8_t *) output, outlen, &j,
                        name + kDNSMagicLen, count)) goto spc;
        name += kDNSMagicLen + count;
        if (*name == '.')
          name++;
        continue;
      }
    }

    while (*name && *name != '.')
      name++;
    if (*name == '.') {
      name++;
    } else {
      break;
    }
  }

  if (!j) {
    errno = EEXIST;
    return 0;
  }

  *ooutlen = j;

  return 1;

 spc:
  errno = ENOSPC;
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
cmpb $0x0, (%rdx)
je 0x1bcf
movq %rdx, %r12
movq %rdi, %r15
movl (%rbx), %eax
movl %eax, 0x4(%rsp)
xorl %ebp, %ebp
leaq 0x56d9(%rip), %r13      # 0x718e
movl $0x5, %edx
movq %r12, %rdi
movq %r13, %rsi
callq 0x1060
testl %eax, %eax
jne 0x1bb0
movl %ebp, %edi
leaq 0x5(%r12), %rsi
movb $0x1, %al
xorl %r14d, %r14d
movzbl 0x5(%r12,%r14), %ecx
cmpl $0x2e, %ecx
je 0x1b34
testl %ecx, %ecx
je 0x1b3f
leal -0x30(%rcx), %edx
cmpb $0xa, %dl
jae 0x1af4
xorl %edx, %edx
jmp 0x1b36
leal -0x62(%rcx), %edx
cmpb $0x18, %dl
ja 0x1b14
xorl %edx, %edx
leal -0x65(%rcx), %r8d
cmpl $0xa, %r8d
ja 0x1b36
movl $0x411, %r9d            # imm = 0x411
btl %r8d, %r9d
jae 0x1b36
leal -0x42(%rcx), %edx
cmpb $0x18, %dl
ja 0x1b32
xorl %edx, %edx
addl $-0x45, %ecx
cmpl $0xa, %ecx
ja 0x1b36
movl $0x411, %r8d            # imm = 0x411
btl %ecx, %r8d
jae 0x1b36
xorl %eax, %eax
movb $0x1, %dl
testb %dl, %dl
jne 0x1b3f
incq %r14
jmp 0x1ad9
testl %r14d, %r14d
sete %cl
testb %al, %al
sete %al
orb %cl, %al
cmpb $0x1, %al
jne 0x1b56
xorl %eax, %eax
movl %edi, %ebp
jmp 0x1ba5
movq %r15, %r13
leaq (%rdi,%r14), %r15
cmpl 0x4(%rsp), %r15d
ja 0x1b72
addq %r13, %rdi
movl %r14d, %edx
callq 0x10b0
movl %r15d, %ebp
movl $0x7, %eax
cmpl 0x4(%rsp), %r15d
ja 0x1b9b
addl $0x5, %r14d
leaq (%r12,%r14), %rax
xorl %ecx, %ecx
cmpb $0x2e, (%r12,%r14)
sete %cl
addq %rax, %rcx
movl $0x2, %eax
movq %rcx, %r12
movq %r13, %r15
leaq 0x55e9(%rip), %r13      # 0x718e
testl %eax, %eax
je 0x1bb0
cmpl $0x2, %eax
je 0x1bc2
jmp 0x1bfa
incq %r12
movzbl -0x1(%r12), %eax
testl %eax, %eax
je 0x1bd1
cmpl $0x2e, %eax
jne 0x1bb0
cmpb $0x0, (%r12)
jne 0x1ab5
jmp 0x1bd1
xorl %ebp, %ebp
testl %ebp, %ebp
je 0x1bde
movl %ebp, (%rbx)
movl $0x1, %eax
jmp 0x1beb
callq 0x1050
movl $0x11, (%rax)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x7, %eax
jne 0x1c0c
callq 0x1050
movl $0x1c, (%rax)
jmp 0x1be9
jmp 0x1beb