// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/nd6.c
// Function: nd6_send_rs
static err_t
nd6_send_rs(struct netif *netif)
{
  struct rs_header *rs_hdr;
  struct lladdr_option *lladdr_opt;
  struct pbuf *p;
  const ip6_addr_t *src_addr;
  err_t err;
  u16_t lladdr_opt_len = 0;

  /* Link-local source address, or unspecified address? */
  if (ip6_addr_isvalid(netif_ip6_addr_state(netif, 0))) {
    src_addr = netif_ip6_addr(netif, 0);
  } else {
    src_addr = IP6_ADDR_ANY6;
  }

  /* Generate the all routers target address. */
  ip6_addr_set_allrouters_linklocal(&multicast_address);
  ip6_addr_assign_zone(&multicast_address, IP6_MULTICAST, netif);

  /* Allocate a packet. */
  if (src_addr != IP6_ADDR_ANY6) {
    lladdr_opt_len = ((netif->hwaddr_len + 2) >> 3) + (((netif->hwaddr_len + 2) & 0x07) ? 1 : 0);
  }
  p = pbuf_alloc(PBUF_IP, sizeof(struct rs_header) + (lladdr_opt_len << 3), PBUF_RAM);
  if (p == NULL) {
    ND6_STATS_INC(nd6.memerr);
    return ERR_BUF;
  }

  /* Set fields. */
  rs_hdr = (struct rs_header *)p->payload;

  rs_hdr->type = ICMP6_TYPE_RS;
  rs_hdr->code = 0;
  rs_hdr->chksum = 0;
  rs_hdr->reserved = 0;

  if (src_addr != IP6_ADDR_ANY6) {
    /* Include our hw address. */
    lladdr_opt = (struct lladdr_option *)((u8_t*)p->payload + sizeof(struct rs_header));
    lladdr_opt->type = ND6_OPTION_TYPE_SOURCE_LLADDR;
    lladdr_opt->length = (u8_t)lladdr_opt_len;
    SMEMCPY(lladdr_opt->addr, netif->hwaddr, netif->hwaddr_len);
  }

#if CHECKSUM_GEN_ICMP6
  IF__NETIF_CHECKSUM_ENABLED(netif, NETIF_CHECKSUM_GEN_ICMP6) {
    rs_hdr->chksum = ip6_chksum_pseudo(p, IP6_NEXTH_ICMP6, p->len, src_addr,
      &multicast_address);
  }
#endif /* CHECKSUM_GEN_ICMP6 */

  /* Send the packet out. */
  ND6_STATS_INC(nd6.xmit);

  err = ip6_output_if(p, (src_addr == IP6_ADDR_ANY6) ? NULL : src_addr, &multicast_address,
      ND6_HOPLIM, 0, IP6_NEXTH_ICMP6, netif);
  pbuf_free(p);

  return err;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x50(%rdi), %r14
testb $0x10, 0x98(%rdi)
leaq 0x4384(%rip), %rax      # 0x165e0
movq %r14, %r15
cmoveq %rax, %r15
movaps 0x4516(%rip), %xmm0     # 0x16780
movaps %xmm0, 0xacdf(%rip)     # 0x1cf50
movb 0xee(%rdi), %cl
incb %cl
movb %cl, 0xace1(%rip)       # 0x1cf60
cmpq %rax, %r15
je 0x122a1
movzbl 0xea(%rbx), %eax
addl $0x2, %eax
movl %eax, %r13d
shrl $0x3, %r13d
andl $0x7, %eax
cmpl $0x1, %eax
sbbl $-0x1, %r13d
jmp 0x122a4
xorl %r13d, %r13d
leal 0x8(,%r13,8), %eax
movzwl %ax, %esi
movl $0x36, %edi
movl $0x280, %edx            # imm = 0x280
callq 0x4df7
testq %rax, %rax
je 0x122fc
movq %rax, %r12
movq 0x8(%rax), %rbp
movq $0x85, (%rbp)
cmpq 0x9d0f(%rip), %r15      # 0x1bfe8
je 0x12300
movb $0x1, 0x8(%rbp)
movb %r13b, 0x9(%rbp)
leaq 0xa(%rbp), %rdi
leaq 0xe4(%rbx), %rsi
movzbl 0xea(%rbx), %edx
callq 0x2180
jmp 0x12303
movb $-0x2, %al
jmp 0x12353
xorl %r14d, %r14d
movzwl 0x12(%r12), %edx
leaq 0xac40(%rip), %r13      # 0x1cf50
movq %r12, %rdi
movl $0x3a, %esi
movq %r15, %rcx
movq %r13, %r8
callq 0x138e7
movw %ax, 0x2(%rbp)
movq %rbx, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0xff, %ecx
xorl %r8d, %r8d
movl $0x3a, %r9d
callq 0xff25
movl %eax, %ebx
movq %r12, %rdi
callq 0x4fdf
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq