// File: /workspace/github_c_makefile_star2_O3/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 0x120c1
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
movl $0x36, %edi
movl $0x280, %edx            # imm = 0x280
callq 0x4df7
testq %rax, %rax
je 0x1200a
movq %rax, %r15
movq 0x8(%rax), %r13
movl $0x88, (%r13)
movl %ebp, %eax
andb $0x70, %al
movb %al, 0x4(%r13)
movw $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 0x12019
testb $0x2, %bpl
jne 0x12038
leaq 0xa76c(%rip), %r12      # 0x1c770
addq $0x24, %r12
jmp 0x1206e
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x2ff, 0xaf2c(%rip) # imm = 0x2FF
movl $0x1000000, 0xaf2a(%rip) # imm = 0x1000000
movl $0xff, %eax
orl 0xc(%rbx), %eax
jmp 0x12052
movq $0x2ff, 0xaf0d(%rip) # imm = 0x2FF
movl $0x0, 0xaf0b(%rip)      # 0x1cf58
movl $0x1000000, %eax        # imm = 0x1000000
movl %eax, 0xaf04(%rip)      # 0x1cf5c
leaq 0xaef1(%rip), %r12      # 0x1cf50
movb 0xee(%r14), %al
incb %al
movb %al, 0xaef2(%rip)       # 0x1cf60
movzwl 0x12(%r15), %edx
movq %r15, %rdi
movl $0x3a, %esi
movq %rbx, %rcx
movq %r12, %r8
callq 0x138e7
movw %ax, 0x2(%r13)
movq %r14, (%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0xff, %ecx
xorl %r8d, %r8d
movl $0x3a, %r9d
callq 0xff25
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4fdf
leaq 0x2204(%rip), %rdi      # 0x142cc
leaq 0x470b(%rip), %rsi      # 0x167da
leaq 0x46ba(%rip), %rcx      # 0x16790
movl $0x4ef, %edx            # imm = 0x4EF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050