// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/ip6_addr.c
// Function: ip6addr_aton
int
ip6addr_aton(const char *cp, ip6_addr_t *addr)
{
  u32_t addr_index, zero_blocks, current_block_index, current_block_value;
  const char *s;
#if LWIP_IPV4
  int check_ipv4_mapped = 0;
#endif /* LWIP_IPV4 */

  /* Count the number of colons, to count the number of blocks in a "::" sequence
     zero_blocks may be 1 even if there are no :: sequences */
  zero_blocks = 8;
  for (s = cp; *s != 0; s++) {
    if (*s == ':') {
      zero_blocks--;
#if LWIP_IPV4
    } else if (*s == '.') {
      if ((zero_blocks == 5) ||(zero_blocks == 2)) {
        check_ipv4_mapped = 1;
        /* last block could be the start of an IPv4 address */
        zero_blocks--;
      } else {
        /* invalid format */
        return 0;
      }
      break;
#endif /* LWIP_IPV4 */
    } else if (!lwip_isxdigit(*s)) {
      break;
    }
  }

  /* parse each block */
  addr_index = 0;
  current_block_index = 0;
  current_block_value = 0;
  for (s = cp; *s != 0; s++) {
    if (*s == ':') {
      if (addr) {
        if (current_block_index & 0x1) {
          addr->addr[addr_index++] |= current_block_value;
        }
        else {
          addr->addr[addr_index] = current_block_value << 16;
        }
      }
      current_block_index++;
#if LWIP_IPV4
      if (check_ipv4_mapped) {
        if (current_block_index == 6) {
          ip4_addr_t ip4;
          int ret = ip4addr_aton(s + 1, &ip4);
          if (ret) {
            if (addr) {
              addr->addr[3] = lwip_htonl(ip4.addr);
              current_block_index++;
              goto fix_byte_order_and_return;
            }
            return 1;
          }
        }
      }
#endif /* LWIP_IPV4 */
      current_block_value = 0;
      if (current_block_index > 7) {
        /* address too long! */
        return 0;
      }
      if (s[1] == ':') {
        if (s[2] == ':') {
          /* invalid format: three successive colons */
          return 0;
        }
        s++;
        /* "::" found, set zeros */
        while (zero_blocks > 0) {
          zero_blocks--;
          if (current_block_index & 0x1) {
            addr_index++;
          } else {
            if (addr) {
              addr->addr[addr_index] = 0;
            }
          }
          current_block_index++;
          if (current_block_index > 7) {
            /* address too long! */
            return 0;
          }
        }
      }
    } else if (lwip_isxdigit(*s)) {
      /* add current digit */
      current_block_value = (current_block_value << 4) +
          (lwip_isdigit(*s) ? (u32_t)(*s - '0') :
          (u32_t)(10 + (lwip_islower(*s) ? *s - 'a' : *s - 'A')));
    } else {
      /* unexpected digit, space? CRLF? */
      break;
    }
  }

  if (addr) {
    if (current_block_index & 0x1) {
      addr->addr[addr_index++] |= current_block_value;
    }
    else {
      addr->addr[addr_index] = current_block_value << 16;
    }
#if LWIP_IPV4
fix_byte_order_and_return:
#endif
    /* convert to network byte order. */
    for (addr_index = 0; addr_index < 4; addr_index++) {
      addr->addr[addr_index] = lwip_htonl(addr->addr[addr_index]);
    }

    ip6_addr_clear_zone(addr);
  }

  if (current_block_index != 7) {
    return 0;
  }

  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x8, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1dd8e
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x1dd1d
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1dd7b
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x1dd55
cmpl $0x5, -0x20(%rbp)
je 0x1dd35
cmpl $0x2, -0x20(%rbp)
jne 0x1dd47
movl $0x1, -0x34(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x1dd53
movl $0x0, -0x4(%rbp)
jmp 0x1e075
jmp 0x1dd8e
callq 0x2250
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
jne 0x1dd77
jmp 0x1dd8e
jmp 0x1dd79
jmp 0x1dd7b
jmp 0x1dd7d
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1dcf6
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x1dfe4
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x3a, %eax
jne 0x1df1f
cmpq $0x0, -0x18(%rbp)
je 0x1de0b
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1ddf9
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movl %ecx, %ecx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1de09
movl -0x28(%rbp), %edx
shll $0x10, %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x1de0b
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x1de70
cmpl $0x6, -0x24(%rbp)
jne 0x1de6e
movq -0x30(%rbp), %rdi
addq $0x1, %rdi
leaq -0x38(%rbp), %rsi
callq 0x1a2a0
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x3c(%rbp)
je 0x1de6c
cmpq $0x0, -0x18(%rbp)
je 0x1de60
movl -0x38(%rbp), %edi
callq 0x251f0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x1e024
movl $0x1, -0x4(%rbp)
jmp 0x1e075
jmp 0x1de6e
jmp 0x1de70
movl $0x0, -0x28(%rbp)
cmpl $0x7, -0x24(%rbp)
jbe 0x1de89
movl $0x0, -0x4(%rbp)
jmp 0x1e075
movq -0x30(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x3a, %eax
jne 0x1df1a
movq -0x30(%rbp), %rax
movsbl 0x2(%rax), %eax
cmpl $0x3a, %eax
jne 0x1deb3
movl $0x0, -0x4(%rbp)
jmp 0x1e075
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpl $0x0, -0x20(%rbp)
jbe 0x1df18
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1dee4
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1defb
cmpq $0x0, -0x18(%rbp)
je 0x1def9
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl $0x0, (%rax,%rcx,4)
jmp 0x1defb
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x7, -0x24(%rbp)
jbe 0x1df16
movl $0x0, -0x4(%rbp)
jmp 0x1e075
jmp 0x1debf
jmp 0x1df1a
jmp 0x1dfd1
callq 0x2250
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0x1dfcd
movl -0x28(%rbp), %eax
shll $0x4, %eax
movl %eax, -0x40(%rbp)
callq 0x2250
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x1df7b
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
subl $0x30, %eax
movl %eax, -0x44(%rbp)
jmp 0x1dfc0
callq 0x2250
movq (%rax), %rax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x200, %eax            # imm = 0x200
cmpl $0x0, %eax
je 0x1dfaa
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
subl $0x61, %eax
movl %eax, -0x48(%rbp)
jmp 0x1dfb7
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
subl $0x41, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
addl $0xa, %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movl -0x44(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x28(%rbp)
jmp 0x1dfcf
jmp 0x1dfe4
jmp 0x1dfd1
jmp 0x1dfd3
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1ddab
cmpq $0x0, -0x18(%rbp)
je 0x1e05f
movl -0x24(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x1e012
movl -0x28(%rbp), %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x1c(%rbp)
movl %ecx, %ecx
orl (%rax,%rcx,4), %edx
movl %edx, (%rax,%rcx,4)
jmp 0x1e022
movl -0x28(%rbp), %edx
shll $0x10, %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
jmp 0x1e024
movl $0x0, -0x1c(%rbp)
cmpl $0x4, -0x1c(%rbp)
jae 0x1e057
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl (%rax,%rcx,4), %edi
callq 0x251f0
movl %eax, %edx
movq -0x18(%rbp), %rax
movl -0x1c(%rbp), %ecx
movl %edx, (%rax,%rcx,4)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1e02b
movq -0x18(%rbp), %rax
movb $0x0, 0x10(%rax)
cmpl $0x7, -0x24(%rbp)
je 0x1e06e
movl $0x0, -0x4(%rbp)
jmp 0x1e075
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop