// File: /workspace/github_c_makefile_star2_O2/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 0x4704(%rip), %rax      # 0x16670
movq %r14, %r15
cmoveq %rax, %r15
movaps 0x4876(%rip), %xmm0     # 0x167f0
movaps %xmm0, 0xbfdf(%rip)     # 0x1df60
movb 0xee(%rdi), %cl
incb %cl
movb %cl, 0xbfe1(%rip)       # 0x1df70
cmpq %rax, %r15
je 0x11fb1
movzbl 0xea(%rbx), %eax
addl $0x2, %eax
movl %eax, %r13d
shrl $0x3, %r13d
andl $0x7, %eax
cmpl $0x1, %eax
sbbl $-0x1, %r13d
jmp 0x11fb4
xorl %r13d, %r13d
leal 0x8(,%r13,8), %eax
movzwl %ax, %esi
pushq $0x36
popq %rdi
movl $0x280, %edx            # imm = 0x280
callq 0x4c47
testq %rax, %rax
je 0x1200a
movq %rax, %r12
movq 0x8(%rax), %rbp
movq $0x85, (%rbp)
cmpq 0xb001(%rip), %r15      # 0x1cfe8
je 0x1200e
movb $0x1, 0x8(%rbp)
movb %r13b, 0x9(%rbp)
leaq 0xa(%rbp), %rdi
leaq 0xe4(%rbx), %rsi
movzbl 0xea(%rbx), %edx
callq 0x2180
jmp 0x12011
movb $-0x2, %al
jmp 0x1205d
xorl %r14d, %r14d
movzwl 0x12(%r12), %edx
leaq 0xbf42(%rip), %r13      # 0x1df60
pushq $0x3a
popq %rsi
movq %r12, %rdi
movq %r15, %rcx
movq %r13, %r8
callq 0x13180
movw %ax, 0x2(%rbp)
movq %rbx, (%rsp)
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
movl $0xff, %ecx
xorl %r8d, %r8d
pushq $0x3a
popq %r9
callq 0xf908
movl %eax, %ebx
movq %r12, %rdi
callq 0x4e16
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq