// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/ipv6/ip6.c
// Function: ip6_output_if_src
err_t
ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
             u8_t hl, u8_t tc,
             u8_t nexth, struct netif *netif)
{
  struct ip6_hdr *ip6hdr;
  ip6_addr_t dest_addr;

  LWIP_ASSERT_CORE_LOCKED();
  LWIP_IP_CHECK_PBUF_REF_COUNT_FOR_TX(p);

  /* Should the IPv6 header be generated or is it already included in p? */
  if (dest != LWIP_IP_HDRINCL) {
#if LWIP_IPV6_SCOPES
    /* If the destination address is scoped but lacks a zone, add a zone now,
     * based on the outgoing interface. The lower layers (e.g., nd6) absolutely
     * require addresses to be properly zoned for correctness. In some cases,
     * earlier attempts will have been made to add a zone to the destination,
     * but this function is the only one that is called in all (other) cases,
     * so we must do this here. */
    if (ip6_addr_lacks_zone(dest, IP6_UNKNOWN)) {
      ip6_addr_copy(dest_addr, *dest);
      ip6_addr_assign_zone(&dest_addr, IP6_UNKNOWN, netif);
      dest = &dest_addr;
    }
#endif /* LWIP_IPV6_SCOPES */

    /* generate IPv6 header */
    if (pbuf_add_header(p, IP6_HLEN)) {
      LWIP_DEBUGF(IP6_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("ip6_output: not enough room for IPv6 header in pbuf\n"));
      IP6_STATS_INC(ip6.err);
      return ERR_BUF;
    }

    ip6hdr = (struct ip6_hdr *)p->payload;
    LWIP_ASSERT("check that first pbuf can hold struct ip6_hdr",
               (p->len >= sizeof(struct ip6_hdr)));

    IP6H_HOPLIM_SET(ip6hdr, hl);
    IP6H_NEXTH_SET(ip6hdr, nexth);

    /* dest cannot be NULL here */
    ip6_addr_copy_to_packed(ip6hdr->dest, *dest);

    IP6H_VTCFL_SET(ip6hdr, 6, tc, 0);
    IP6H_PLEN_SET(ip6hdr, (u16_t)(p->tot_len - IP6_HLEN));

    if (src == NULL) {
      src = IP6_ADDR_ANY6;
    }
    /* src cannot be NULL here */
    ip6_addr_copy_to_packed(ip6hdr->src, *src);

  } else {
    /* IP header already included in p */
    ip6hdr = (struct ip6_hdr *)p->payload;
    ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
    ip6_addr_assign_zone(&dest_addr, IP6_UNKNOWN, netif);
    dest = &dest_addr;
  }

  IP6_STATS_INC(ip6.xmit);

  LWIP_DEBUGF(IP6_DEBUG, ("ip6_output_if: %c%c%"U16_F"\n", netif->name[0], netif->name[1], (u16_t)netif->num));
  ip6_debug_print(p);

#if ENABLE_LOOPBACK
  {
    int i;
#if !LWIP_HAVE_LOOPIF
    if (ip6_addr_isloopback(dest)) {
      return netif_loop_output(netif, p);
    }
#endif /* !LWIP_HAVE_LOOPIF */
    for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
      if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) &&
          ip6_addr_cmp(dest, netif_ip6_addr(netif, i))) {
        /* Packet to self, enqueue it for loopback */
        LWIP_DEBUGF(IP6_DEBUG, ("netif_loop_output()\n"));
        return netif_loop_output(netif, p);
      }
    }
  }
#if LWIP_MULTICAST_TX_OPTIONS
  if ((p->flags & PBUF_FLAG_MCASTLOOP) != 0) {
    netif_loop_output(netif, p);
  }
#endif /* LWIP_MULTICAST_TX_OPTIONS */
#endif /* ENABLE_LOOPBACK */
#if LWIP_IPV6_FRAG
  /* don't fragment if interface has mtu set to 0 [loopif] */
  if (netif_mtu6(netif) && (p->tot_len > nd6_get_destination_mtu(dest, netif))) {
    return ip6_frag(p, netif, dest);
  }
#endif /* LWIP_IPV6_FRAG */

  LWIP_DEBUGF(IP6_DEBUG, ("netif->output_ip6()\n"));
  return netif->output_ip6(netif, p, dest);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpb $0x1, 0x16(%rdi)
jne 0x10243
movq %rdx, %r15
movq %rdi, %rbx
movq 0x70(%rsp), %r14
testq %rdx, %rdx
je 0x1013a
movl %r8d, %r12d
leaq 0x4(%r15), %rbp
leaq 0xc(%r15), %r13
cmpb $0x0, 0x10(%r15)
movq %rsi, 0x30(%rsp)
movl %r9d, 0xc(%rsp)
movl %ecx, 0x8(%rsp)
jne 0x10080
movl (%r15), %eax
movl %eax, %edi
andl $0xc0ff, %edi           # imm = 0xC0FF
cmpl $0x80fe, %edi           # imm = 0x80FE
je 0x10030
movl %eax, %edx
andl $0x8fff, %edx           # imm = 0x8FFF
cmpl $0x2ff, %edx            # imm = 0x2FF
je 0x10030
cmpl $0x1ff, %edx            # imm = 0x1FF
jne 0x10080
movl %eax, 0x10(%rsp)
movq (%rbp), %rdx
movq %rdx, 0x14(%rsp)
movl (%r13), %edx
movl %edx, 0x1c(%rsp)
cmpl $0x80fe, %edi           # imm = 0x80FE
je 0x10064
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0x10064
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0x10223
movb 0xee(%r14), %al
incb %al
leaq 0x14(%rsp), %rbp
leaq 0x1c(%rsp), %r13
movb %al, 0x4(%r13)
leaq 0x10(%rsp), %r15
movl $0x28, %esi
movq %rbx, %rdi
callq 0x5208
movl %eax, %ecx
movb $-0x2, %al
testb %cl, %cl
jne 0x1020d
cmpw $0x27, 0x12(%rbx)
jbe 0x10270
movl %r12d, %ecx
movq 0x8(%rbx), %r12
movl 0x8(%rsp), %eax
movb %al, 0x7(%r12)
movl 0xc(%rsp), %eax
movb %al, 0x6(%r12)
movl (%r15), %eax
movl %eax, 0x18(%r12)
movl (%rbp), %eax
movl %eax, 0x1c(%r12)
movl 0x8(%r15), %eax
movl %eax, 0x20(%r12)
movl (%r13), %eax
movl %eax, 0x24(%r12)
movzbl %cl, %edi
shll $0x14, %edi
orl $0x60000000, %edi       # imm = 0x60000000
callq 0x135bb
movl %eax, (%r12)
movl 0x10(%rbx), %eax
addl $-0x28, %eax
movzwl %ax, %edi
callq 0x135b4
movw %ax, 0x4(%r12)
movq 0x30(%rsp), %rcx
testq %rcx, %rcx
jne 0x10119
leaq 0x64c7(%rip), %rcx      # 0x165e0
movl (%rcx), %eax
movl %eax, 0x8(%r12)
movl 0x4(%rcx), %eax
movl %eax, 0xc(%r12)
movl 0x8(%rcx), %eax
movl %eax, 0x10(%r12)
movl 0xc(%rcx), %eax
movl %eax, 0x14(%r12)
jmp 0x10183
movq 0x8(%rbx), %rcx
movl 0x18(%rcx), %eax
movups 0x18(%rcx), %xmm0
movaps %xmm0, 0x10(%rsp)
movl %eax, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
cmpl $0x80fe, %ecx           # imm = 0x80FE
je 0x10171
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0x10171
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0x1021c
movb 0xee(%r14), %al
incb %al
leaq 0x10(%rsp), %r15
movb %al, 0x10(%r15)
leaq 0x60(%r14), %rax
movl $0x98, %ecx
testb $0x10, (%r14,%rcx)
je 0x101be
movl (%r15), %edx
cmpl -0x10(%rax), %edx
jne 0x101be
movl 0x4(%r15), %edx
cmpl -0xc(%rax), %edx
jne 0x101be
movl 0x8(%r15), %edx
cmpl -0x8(%rax), %edx
jne 0x101be
movl 0xc(%r15), %edx
cmpl -0x4(%rax), %edx
jne 0x101be
movb 0x10(%r15), %dl
cmpb (%rax), %dl
je 0x1022a
addq $0x18, %rax
incq %rcx
cmpq $0x9b, %rcx
jne 0x1018c
cmpw $0x0, 0xe2(%r14)
je 0x101fd
movzwl 0x10(%rbx), %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x13337
cmpw %ax, %bp
jbe 0x101fd
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x10fe8
jmp 0x1020d
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *0xd0(%r14)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x1017a
xorl %eax, %eax
jmp 0x1006d
movq %r14, %rdi
movq %rbx, %rsi
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4573
leaq 0x4082(%rip), %rdi      # 0x142cc
leaq 0x60a5(%rip), %rsi      # 0x162f6
leaq 0x6339(%rip), %rcx      # 0x16591
movl $0x4aa, %edx            # imm = 0x4AA
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0x4055(%rip), %rdi      # 0x142cc
leaq 0x6332(%rip), %rsi      # 0x165b0
leaq 0x630c(%rip), %rcx      # 0x16591
movl $0x4c5, %edx            # imm = 0x4C5
jmp 0x1025d