// File: /workspace/github_c_makefile_star2_O2/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/nd6.c
// Function: nd6_send_na
static void
nd6_send_na(struct netif *netif, const ip6_addr_t *target_addr, u8_t flags)
{
  struct na_header *na_hdr;
  struct lladdr_option *lladdr_opt;
  struct pbuf *p;
  const ip6_addr_t *src_addr;
  const ip6_addr_t *dest_addr;
  u16_t lladdr_opt_len;

  LWIP_ASSERT("target address is required", target_addr != NULL);

  /* Use link-local address as source address. */
  /* src_addr = netif_ip6_addr(netif, 0); */
  /* Use target address as source address. */
  src_addr = target_addr;

  /* Allocate a packet. */
  lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
  p = pbuf_alloc(PBUF_IP, sizeof(struct na_header) + (lladdr_opt_len << 3), PBUF_RAM);
  if (p == NULL) {
    ND6_STATS_INC(nd6.memerr);
    return;
  }

  /* Set fields. */
  na_hdr = (struct na_header *)p->payload;
  lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct na_header));

  na_hdr->type = ICMP6_TYPE_NA;
  na_hdr->code = 0;
  na_hdr->chksum = 0;
  na_hdr->flags = flags & 0xf0;
  na_hdr->reserved[0] = 0;
  na_hdr->reserved[1] = 0;
  na_hdr->reserved[2] = 0;
  ip6_addr_copy_to_packed(na_hdr->target_address, *target_addr);

  lladdr_opt->type = ND6_OPTION_TYPE_TARGET_LLADDR;
  lladdr_opt->length = (u8_t)lladdr_opt_len;
  SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);

  /* Generate the solicited node address for the target address. */
  if (flags & ND6_SEND_FLAG_MULTICAST_DEST) {
    ip6_addr_set_solicitednode(&multicast_address, target_addr->addr[3]);
    ip6_addr_assign_zone(&multicast_address, IP6_MULTICAST, netif);
    dest_addr = &multicast_address;
  } else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) {
    ip6_addr_set_allnodes_linklocal(&multicast_address);
    ip6_addr_assign_zone(&multicast_address, IP6_MULTICAST, netif);
    dest_addr = &multicast_address;
  } else {
    dest_addr = ip6_current_src_addr();
  }

#if CHECKSUM_GEN_ICMP6
  IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_ICMP6) {
    na_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
      dest_addr);
  }
#endif /* CHECKSUM_GEN_ICMP6 */

  /* Send the packet out. */
  ND6_STATS_INC(nd6.xmit);
  ip6_output_if(p, src_addr, dest_addr,
      ND6_HOPLIM, 0, IP6_NEXTH_ICMP6, netif);
  pbuf_free(p);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rsi, %rsi
je 0x11dc5
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
movzbl 0xea(%rdi), %eax
addl $0x2, %eax
movl %eax, %r12d
shrl $0x3, %r12d
andl $0x7, %eax
cmpl $0x1, %eax
sbbl $-0x1, %r12d
leal 0x18(,%r12,8), %eax
movzwl %ax, %esi
pushq $0x36
popq %rdi
movl $0x280, %edx            # imm = 0x280
callq 0x4c47
testq %rax, %rax
je 0x11d14
movq %rax, %r15
movq 0x8(%rax), %r13
movl $0x88, (%r13)
movl %ebp, %eax
andb $0x70, %al
movb %al, 0x4(%r13)
andw $0x0, 0x5(%r13)
movb $0x0, 0x7(%r13)
movl (%rbx), %eax
movl %eax, 0x8(%r13)
movl 0x4(%rbx), %eax
movl %eax, 0xc(%r13)
movl 0x8(%rbx), %eax
movl %eax, 0x10(%r13)
movl 0xc(%rbx), %eax
movl %eax, 0x14(%r13)
movb $0x2, 0x18(%r13)
movb %r12b, 0x19(%r13)
leaq 0x1a(%r13), %rdi
leaq 0xe4(%r14), %rsi
movzbl 0xea(%r14), %edx
callq 0x2180
testb $0x1, %bpl
jne 0x11d23
testb $0x2, %bpl
jne 0x11d42
leaq 0xba62(%rip), %r12      # 0x1d770
addq $0x24, %r12
jmp 0x11d75
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x2ff, 0xc232(%rip) # imm = 0x2FF
movl $0x1000000, 0xc230(%rip) # imm = 0x1000000
movl $0xff, %eax
orl 0xc(%rbx), %eax
jmp 0x11d59
movq $0x2ff, 0xc213(%rip) # imm = 0x2FF
andl $0x0, 0xc214(%rip)      # 0x1df68
movl $0x1000000, %eax        # imm = 0x1000000
movl %eax, 0xc20d(%rip)      # 0x1df6c
leaq 0xc1fa(%rip), %r12      # 0x1df60
movb 0xee(%r14), %al
incb %al
movb %al, 0xc1fb(%rip)       # 0x1df70
movzwl 0x12(%r15), %edx
pushq $0x3a
popq %rbp
movq %r15, %rdi
movl %ebp, %esi
movq %rbx, %rcx
movq %r12, %r8
callq 0x13180
movw %ax, 0x2(%r13)
movq %r14, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0xff, %ecx
xorl %r8d, %r8d
movl %ebp, %r9d
callq 0xf908
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4e16
leaq 0x2500(%rip), %rdi      # 0x142cc
leaq 0x4a77(%rip), %rsi      # 0x1684a
leaq 0x4a26(%rip), %rcx      # 0x16800
movl $0x4ef, %edx            # imm = 0x4EF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050