// File: /workspace/github_c_makefile_star2_O1/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 0x1269f
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 0x4e57
testq %rax, %rax
je 0x125e1
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 0x125f0
testb $0x2, %bpl
jne 0x1260f
leaq 0xb195(%rip), %r12      # 0x1d770
addq $0x24, %r12
jmp 0x1264c
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x2ff, 0xb949(%rip) # imm = 0x2FF
movl $0x1000000, 0xb947(%rip) # imm = 0x1000000
movl $0xff, %eax
orl 0xc(%rbx), %eax
jmp 0x12629
movq $0x2ff, 0xb92a(%rip) # imm = 0x2FF
movl $0x0, 0xb928(%rip)      # 0x1df4c
movl $0x1000000, %eax        # imm = 0x1000000
movl %eax, 0xb921(%rip)      # 0x1df50
leaq 0xb90e(%rip), %r12      # 0x1df44
movb $0x0, 0xb917(%rip)      # 0x1df54
movb 0xee(%r14), %al
incb %al
movb %al, 0xb908(%rip)       # 0x1df54
movzwl 0x12(%r15), %edx
movq %r15, %rdi
movl $0x3a, %esi
movq %rbx, %rcx
movq %r12, %r8
callq 0x13f92
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 0x103a0
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x5069
leaq 0x2c26(%rip), %rdi      # 0x152cc
leaq 0x51f0(%rip), %rsi      # 0x1789d
leaq 0x519f(%rip), %rcx      # 0x17853
movl $0x4ef, %edx            # imm = 0x4EF
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050