// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x2011
movq -0x20(%rbp), %rdi
movq 0xd23c(%rip), %rsi      # 0xf0a8
movl $0x5, %edx
callq 0x1060
cmpl $0x0, %eax
jne 0x1fb6
movb $0x1, -0x29(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x20(%rbp), %rax
addq $0x5, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1f4e
movq -0x38(%rbp), %rax
movb (%rax), %al
movb %al, -0x39(%rbp)
movsbl -0x39(%rbp), %eax
cmpl $0x2e, %eax
je 0x1ebb
cmpb $0x0, -0x39(%rbp)
jne 0x1ec0
jmp 0x1f4e
movsbl -0x39(%rbp), %eax
cmpl $0x30, %eax
jl 0x1ed2
movsbl -0x39(%rbp), %eax
cmpl $0x39, %eax
jle 0x1f2c
movsbl -0x39(%rbp), %eax
cmpl $0x61, %eax
jle 0x1eff
movsbl -0x39(%rbp), %eax
cmpl $0x7a, %eax
jg 0x1eff
movsbl -0x39(%rbp), %eax
cmpl $0x65, %eax
je 0x1eff
movsbl -0x39(%rbp), %eax
cmpl $0x69, %eax
je 0x1eff
movsbl -0x39(%rbp), %eax
cmpl $0x6f, %eax
jne 0x1f2c
movsbl -0x39(%rbp), %eax
cmpl $0x41, %eax
jle 0x1f2e
movsbl -0x39(%rbp), %eax
cmpl $0x5a, %eax
jg 0x1f2e
movsbl -0x39(%rbp), %eax
cmpl $0x45, %eax
je 0x1f2e
movsbl -0x39(%rbp), %eax
cmpl $0x49, %eax
je 0x1f2e
movsbl -0x39(%rbp), %eax
cmpl $0x4f, %eax
je 0x1f2e
jmp 0x1f34
movb $0x0, -0x29(%rbp)
jmp 0x1f4e
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e96
cmpl $0x0, -0x30(%rbp)
jne 0x1f58
movb $0x0, -0x29(%rbp)
cmpb $0x0, -0x29(%rbp)
je 0x1fb4
movq -0x10(%rbp), %rdi
movl -0x28(%rbp), %esi
movq -0x20(%rbp), %rcx
addq $0x5, %rcx
movl -0x30(%rbp), %r8d
leaq -0x24(%rbp), %rdx
callq 0x2060
cmpl $0x0, %eax
jne 0x1f84
jmp 0x203d
movl -0x30(%rbp), %ecx
addl $0x5, %ecx
movq -0x20(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x1faf
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1e54
jmp 0x1fb6
jmp 0x1fb8
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3a(%rbp)
je 0x1fd9
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
setne %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
testb $0x1, %al
jne 0x1fe2
jmp 0x1ff0
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x1fb8
movq -0x20(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x200a
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x200c
jmp 0x2011
jmp 0x1e54
cmpl $0x0, -0x24(%rbp)
jne 0x202b
callq 0x1050
movl $0x11, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x204f
movl -0x24(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movl $0x1, -0x4(%rbp)
jmp 0x204f
callq 0x1050
movl $0x1c, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)