// File: /workspace/github_c_makefile_star2_O1/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 0x106fb
movq %rdx, %r15
movq %rdi, %rbx
movq 0x70(%rsp), %r14
testq %rdx, %rdx
je 0x1048f
movl %r8d, %ebp
movq %rsi, %r12
leaq 0x4(%r15), %r10
leaq 0x8(%r15), %r8
leaq 0xc(%r15), %r13
movb 0x10(%r15), %dil
testb %dil, %dil
movl %r9d, 0x34(%rsp)
movl %ecx, 0x30(%rsp)
je 0x104f2
movq %r10, 0x20(%rsp)
movq %r8, 0x28(%rsp)
jmp 0x1058a
movq 0x8(%rbx), %rcx
movl 0x18(%rcx), %eax
movl %eax, 0xc(%rsp)
movl 0x1c(%rcx), %edx
movl %edx, 0x10(%rsp)
movl 0x20(%rcx), %edx
movl %edx, 0x14(%rsp)
movl 0x24(%rcx), %ecx
movl %ecx, 0x18(%rsp)
movb $0x0, 0x1c(%rsp)
movl %eax, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
cmpl $0x80fe, %ecx           # imm = 0x80FE
je 0x104db
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0x104db
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0x106e0
movb 0xee(%r14), %al
incb %al
leaq 0xc(%rsp), %r15
movb %al, 0x10(%r15)
jmp 0x10634
movl (%r15), %eax
movl %eax, %edx
andl $0xc0ff, %edx           # imm = 0xC0FF
cmpl $0x80fe, %edx           # imm = 0x80FE
je 0x10521
movl %eax, %esi
andl $0x8fff, %esi           # imm = 0x8FFF
cmpl $0x2ff, %esi            # imm = 0x2FF
je 0x10521
cmpl $0x1ff, %esi            # imm = 0x1FF
jne 0x10480
movl %eax, 0xc(%rsp)
movl (%r10), %esi
movl %esi, 0x10(%rsp)
movl (%r8), %esi
movl %esi, 0x14(%rsp)
movl (%r13), %esi
movl %esi, 0x18(%rsp)
movb %dil, 0x1c(%rsp)
cmpl $0x80fe, %edx           # imm = 0x80FE
je 0x1055f
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0x1055f
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0x106e7
movb 0xee(%r14), %al
incb %al
leaq 0x10(%rsp), %rcx
movq %rcx, 0x20(%rsp)
leaq 0x14(%rsp), %rcx
movq %rcx, 0x28(%rsp)
leaq 0x18(%rsp), %r13
movb %al, 0x4(%r13)
leaq 0xc(%rsp), %r15
movl $0x28, %esi
movq %rbx, %rdi
callq 0x5299
movl %eax, %ecx
movb $-0x2, %al
testb %cl, %cl
jne 0x106d1
cmpw $0x27, 0x12(%rbx)
jbe 0x10728
movl %ebp, %ecx
movq 0x8(%rbx), %rbp
movl 0x30(%rsp), %eax
movb %al, 0x7(%rbp)
movl 0x34(%rsp), %eax
movb %al, 0x6(%rbp)
movl (%r15), %eax
movl %eax, 0x18(%rbp)
movq 0x20(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x1c(%rbp)
movq 0x28(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x20(%rbp)
movl (%r13), %eax
movl %eax, 0x24(%rbp)
movzbl %cl, %edi
shll $0x14, %edi
orl $0x60000000, %edi       # imm = 0x60000000
callq 0x13c57
movl %eax, (%rbp)
movl 0x10(%rbx), %eax
addl $-0x28, %eax
movzwl %ax, %edi
callq 0x13c50
movw %ax, 0x4(%rbp)
testq %r12, %r12
jne 0x10615
leaq 0x709b(%rip), %r12      # 0x176b0
movl (%r12), %eax
movl %eax, 0x8(%rbp)
movl 0x4(%r12), %eax
movl %eax, 0xc(%rbp)
movl 0x8(%r12), %eax
movl %eax, 0x10(%rbp)
movl 0xc(%r12), %eax
movl %eax, 0x14(%rbp)
leaq 0x60(%r14), %rcx
xorl %edx, %edx
xorl %r12d, %r12d
testb $0x10, 0x98(%r14,%rdx)
je 0x10673
movl (%r15), %eax
cmpl -0x10(%rcx), %eax
jne 0x10673
movl 0x4(%r15), %eax
cmpl -0xc(%rcx), %eax
jne 0x10673
movl 0x8(%r15), %eax
cmpl -0x8(%rcx), %eax
jne 0x10673
movl 0xc(%r15), %eax
cmpl -0x4(%rcx), %eax
jne 0x10673
movb 0x10(%r15), %al
cmpb (%rcx), %al
je 0x106ee
cmpq $0x2, %rdx
leaq 0x1(%rdx), %rsi
setae %r12b
addq $0x18, %rcx
movq %rsi, %rdx
cmpq $0x3, %rsi
jne 0x1063d
testb $0x1, %r12b
je 0x106d1
cmpw $0x0, 0xe2(%r14)
je 0x106c1
movzwl 0x10(%rbx), %ebp
movq %r15, %rdi
movq %r14, %rsi
callq 0x139d1
cmpw %ax, %bp
jbe 0x106c1
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x11520
jmp 0x106d1
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 0x104e4
xorl %eax, %eax
jmp 0x10568
movq %r14, %rdi
movq %rbx, %rsi
callq 0x45a4
jmp 0x1068c
leaq 0x4bca(%rip), %rdi      # 0x152cc
leaq 0x6c25(%rip), %rsi      # 0x1732e
leaq 0x6f50(%rip), %rcx      # 0x17660
movl $0x4aa, %edx            # imm = 0x4AA
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050
leaq 0x4b9d(%rip), %rdi      # 0x152cc
leaq 0x6f49(%rip), %rsi      # 0x1767f
leaq 0x6f23(%rip), %rcx      # 0x17660
movl $0x4c5, %edx            # imm = 0x4C5
jmp 0x10715