// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/netif.c
// Function: netif_create_ip6_linklocal_address
void
netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
{
  u8_t i, addr_index;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ASSERT("netif_create_ip6_linklocal_address: invalid netif", netif != NULL);

  /* Link-local prefix. */
  ip_2_ip6(&netif->ip6_addr[0])->addr[0] = PP_HTONL(0xfe800000ul);
  ip_2_ip6(&netif->ip6_addr[0])->addr[1] = 0;

  /* Generate interface ID. */
  if (from_mac_48bit) {
    /* Assume hwaddr is a 48-bit IEEE 802 MAC. Convert to EUI-64 address. Complement Group bit. */
    ip_2_ip6(&netif->ip6_addr[0])->addr[2] = lwip_htonl((((u32_t)(netif->hwaddr[0] ^ 0x02)) << 24) |
        ((u32_t)(netif->hwaddr[1]) << 16) |
        ((u32_t)(netif->hwaddr[2]) << 8) |
        (0xff));
    ip_2_ip6(&netif->ip6_addr[0])->addr[3] = lwip_htonl((u32_t)(0xfeul << 24) |
        ((u32_t)(netif->hwaddr[3]) << 16) |
        ((u32_t)(netif->hwaddr[4]) << 8) |
        (netif->hwaddr[5]));
  } else {
    /* Use hwaddr directly as interface ID. */
    ip_2_ip6(&netif->ip6_addr[0])->addr[2] = 0;
    ip_2_ip6(&netif->ip6_addr[0])->addr[3] = 0;

    addr_index = 3;
    for (i = 0; (i < 8) && (i < netif->hwaddr_len); i++) {
      if (i == 4) {
        addr_index--;
      }
      ip_2_ip6(&netif->ip6_addr[0])->addr[addr_index] |= lwip_htonl(((u32_t)(netif->hwaddr[netif->hwaddr_len - i - 1])) << (8 * (i & 0x03)));
    }
  }

  /* Set a link-local zone. Even though the zone is implied by the owning
   * netif, setting the zone anyway has two important conceptual advantages:
   * 1) it avoids the need for a ton of exceptions in internal code, allowing
   *    e.g. ip6_addr_cmp() to be used on local addresses;
   * 2) the properly zoned address is visible externally, e.g. when any outside
   *    code enumerates available addresses or uses one to bind a socket.
   * Any external code unaware of address scoping is likely to just ignore the
   * zone field, so this should not create any compatibility problems. */
  ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[0]), IP6_UNICAST, netif);

  /* Set address state. */
#if LWIP_IPV6_DUP_DETECT_ATTEMPTS
  /* Will perform duplicate address detection (DAD). */
  netif_ip6_addr_set_state(netif, 0, IP6_ADDR_TENTATIVE);
#else
  /* Consider address valid. */
  netif_ip6_addr_set_state(netif, 0, IP6_ADDR_PREFERRED);
#endif /* LWIP_IPV6_AUTOCONFIG */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x4b8c
movq %rdi, %rbx
leaq 0x50(%rdi), %r14
movq $0x80fe, 0x50(%rdi)     # imm = 0x80FE
testb %sil, %sil
je 0x4ae1
movl 0xe4(%rbx), %eax
xorl $0x2, %eax
shll $0x18, %eax
movzbl 0xe5(%rbx), %ecx
shll $0x10, %ecx
orl %eax, %ecx
movzbl 0xe6(%rbx), %eax
shll $0x8, %eax
leal (%rax,%rcx), %edi
addl $0xff, %edi
callq 0x135bb
movl %eax, 0x58(%rbx)
movzbl 0xe7(%rbx), %eax
shll $0x10, %eax
movzbl 0xe8(%rbx), %ecx
shll $0x8, %ecx
orl %eax, %ecx
movzbl 0xe9(%rbx), %eax
leal (%rax,%rcx), %edi
addl $0xfe000000, %edi       # imm = 0xFE000000
callq 0x135bb
movl %eax, 0x5c(%rbx)
jmp 0x4b40
movq $0x0, 0x58(%rbx)
movb $0x3, %bpl
xorl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %r13d, %r13d
movzbl 0xea(%rbx), %eax
cmpl %eax, %r13d
jae 0x4b40
cmpl $0x4, %r13d
sete %cl
subb %cl, %bpl
addl %r12d, %eax
cltq
movzbl 0xe4(%rbx,%rax), %edi
movl %r15d, %ecx
andb $0x18, %cl
shll %cl, %edi
callq 0x135bb
movzbl %bpl, %ecx
orl %eax, 0x50(%rbx,%rcx,4)
incl %r13d
addl $0x8, %r15d
decl %r12d
cmpl $0x8, %r13d
jne 0x4af8
movl $0xc0ff, %eax           # imm = 0xC0FF
andl (%r14), %eax
cmpl $0x80fe, %eax           # imm = 0x80FE
jne 0x4b59
movb 0xee(%rbx), %al
incb %al
jmp 0x4b5b
xorl %eax, %eax
movb %al, 0x60(%rbx)
movb 0x98(%rbx), %al
cmpb $0x8, %al
je 0x4b7d
testb $0x10, %al
je 0x4b76
movq %r14, %rdi
xorl %esi, %esi
callq 0x447a
movb $0x8, 0x98(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf739(%rip), %rdi      # 0x142cc
leaq 0xfbbd(%rip), %rsi      # 0x14757
leaq 0xf899(%rip), %rcx      # 0x1443a
movl $0x5df, %edx            # imm = 0x5DF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050