// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv4/ip4_addr.c
// Function: ip4addr_aton
int
ip4addr_aton(const char *cp, ip4_addr_t *addr)
{
  u32_t val;
  u8_t base;
  char c;
  u32_t parts[4];
  u32_t *pp = parts;

  c = *cp;
  for (;;) {
    /*
     * Collect number up to ``.''.
     * Values are specified as for C:
     * 0x=hex, 0=octal, 1-9=decimal.
     */
    if (!lwip_isdigit(c)) {
      return 0;
    }
    val = 0;
    base = 10;
    if (c == '0') {
      c = *++cp;
      if (c == 'x' || c == 'X') {
        base = 16;
        c = *++cp;
      } else {
        base = 8;
      }
    }
    for (;;) {
      if (lwip_isdigit(c)) {
        val = (val * base) + (u32_t)(c - '0');
        c = *++cp;
      } else if (base == 16 && lwip_isxdigit(c)) {
        val = (val << 4) | (u32_t)(c + 10 - (lwip_islower(c) ? 'a' : 'A'));
        c = *++cp;
      } else {
        break;
      }
    }
    if (c == '.') {
      /*
       * Internet format:
       *  a.b.c.d
       *  a.b.c   (with c treated as 16 bits)
       *  a.b (with b treated as 24 bits)
       */
      if (pp >= parts + 3) {
        return 0;
      }
      *pp++ = val;
      c = *++cp;
    } else {
      break;
    }
  }
  /*
   * Check for trailing characters.
   */
  if (c != '\0' && !lwip_isspace(c)) {
    return 0;
  }
  /*
   * Concoct the address according to
   * the number of parts specified.
   */
  switch (pp - parts + 1) {

    case 0:
      return 0;       /* initial nondigit */

    case 1:             /* a -- 32 bits */
      break;

    case 2:             /* a.b -- 8.24 bits */
      if (val > 0xffffffUL) {
        return 0;
      }
      if (parts[0] > 0xff) {
        return 0;
      }
      val |= parts[0] << 24;
      break;

    case 3:             /* a.b.c -- 8.8.16 bits */
      if (val > 0xffff) {
        return 0;
      }
      if ((parts[0] > 0xff) || (parts[1] > 0xff)) {
        return 0;
      }
      val |= (parts[0] << 24) | (parts[1] << 16);
      break;

    case 4:             /* a.b.c.d -- 8.8.8.8 bits */
      if (val > 0xff) {
        return 0;
      }
      if ((parts[0] > 0xff) || (parts[1] > 0xff) || (parts[2] > 0xff)) {
        return 0;
      }
      val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
      break;
    default:
      LWIP_ASSERT("unhandled", 0);
      break;
  }
  if (addr) {
    ip4_addr_set_u32(addr, lwip_htonl(val));
  }
  return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, 0x8(%rsp)
movq %rdi, %r15
callq 0x2250
movq (%rax), %rcx
xorl %r14d, %r14d
pushq $0xa
popq %rdx
pushq $0x8
popq %rsi
pushq $0x10
popq %r8
xorl %eax, %eax
movzbl (%r15), %r10d
testb $0x8, 0x1(%rcx,%r10,2)
je 0xe218
movb $0x1, %r9b
cmpb $0x30, %r10b
jne 0xe0b1
movb 0x1(%r15), %r10b
movl %r10d, %edi
andb $-0x21, %dil
cmpb $0x58, %dil
jne 0xe0b6
movb 0x2(%r15), %r10b
addq $0x2, %r15
xorl %r9d, %r9d
movl %r8d, %r11d
jmp 0xe0bc
movl %edx, %r11d
jmp 0xe0bc
incq %r15
movl %esi, %r11d
incq %r15
xorl %edi, %edi
movzbl %r10b, %r13d
movzwl (%rcx,%r13,2), %ebp
btl $0xb, %ebp
movsbl %r10b, %r12d
jb 0xe101
btl $0xc, %ebp
setae %bl
orb %r9b, %bl
jne 0xe113
shll $0x4, %edi
xorl %r10d, %r10d
btl $0x9, %ebp
setae %r10b
shll $0x5, %r10d
addl %r12d, %r10d
addl $-0x57, %r10d
orl %edi, %r10d
movl %r10d, %edi
jmp 0xe10b
imull %r11d, %edi
addl %r12d, %edi
addl $-0x30, %edi
movb (%r15), %r10b
incq %r15
jmp 0xe0c1
cmpb $0x2e, %r10b
jne 0xe12c
cmpq $0xb, %rax
ja 0xe137
movl %edi, 0x10(%rsp,%rax)
addq $0x4, %rax
jmp 0xe077
testl %r13d, %r13d
je 0xe13f
btl $0xd, %ebp
jb 0xe13f
xorl %r14d, %r14d
jmp 0xe218
shrq $0x2, %rax
cmpq $0x3, %rax
ja 0xe22a
leaq 0x8214(%rip), %rcx      # 0x16368
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %r14d, %r14d
cmpl $0xffffff, %edi         # imm = 0xFFFFFF
ja 0xe218
movl 0x10(%rsp), %eax
cmpl $0xff, %eax
ja 0xe218
shll $0x18, %eax
jmp 0xe1b4
xorl %r14d, %r14d
cmpl $0xffff, %edi           # imm = 0xFFFF
ja 0xe218
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %eax
movl $0x100, %edx            # imm = 0x100
cmpl %edx, %ecx
setae %sil
cmpl %edx, %eax
setae %dl
orb %sil, %dl
jne 0xe218
shll $0x18, %ecx
shll $0x10, %eax
orl %ecx, %eax
orl %edi, %eax
movl %eax, %edi
jmp 0xe200
xorl %r14d, %r14d
cmpl $0xff, %edi
ja 0xe218
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %eax
movl $0x100, %esi            # imm = 0x100
cmpl %esi, %ecx
setae %dl
cmpl %esi, %eax
setae %r8b
orb %dl, %r8b
movl 0x18(%rsp), %edx
cmpl %esi, %edx
setae %sil
orb %r8b, %sil
jne 0xe218
shll $0x18, %ecx
shll $0x10, %eax
orl %ecx, %eax
shll $0x8, %edx
orl %edi, %edx
orl %eax, %edx
movl %edx, %edi
movq 0x8(%rsp), %rax
pushq $0x1
popq %r14
testq %rax, %rax
je 0xe218
movq %rax, %rbx
callq 0x12ed7
movl %eax, (%rbx)
movl %r14d, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x609b(%rip), %rdi      # 0x142cc
leaq 0x8170(%rip), %rsi      # 0x163a8
leaq 0x8173(%rip), %rcx      # 0x163b2
movl $0xf9, %edx
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050