// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/udp.c
// Function: udp_sendto_chksum
err_t
udp_sendto_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
                  u16_t dst_port, u8_t have_chksum, u16_t chksum)
{
#endif /* TUN2SOCKS */
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
  struct netif *netif;

  LWIP_ERROR("udp_sendto: invalid pcb", pcb != NULL, return ERR_ARG);
  LWIP_ERROR("udp_sendto: invalid pbuf", p != NULL, return ERR_ARG);
  LWIP_ERROR("udp_sendto: invalid dst_ip", dst_ip != NULL, return ERR_ARG);

  if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
    return ERR_VAL;
  }

  LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE, ("udp_send\n"));

  if (pcb->netif_idx != NETIF_NO_INDEX) {
    netif = netif_get_by_index(pcb->netif_idx);
  } else {
#if LWIP_MULTICAST_TX_OPTIONS
    netif = NULL;
    if (ip_addr_ismulticast(dst_ip)) {
      /* For IPv6, the interface to use for packets with a multicast destination
       * is specified using an interface index. The same approach may be used for
       * IPv4 as well, in which case it overrides the IPv4 multicast override
       * address below. Here we have to look up the netif by going through the
       * list, but by doing so we skip a route lookup. If the interface index has
       * gone stale, we fall through and do the regular route lookup after all. */
      if (pcb->mcast_ifindex != NETIF_NO_INDEX) {
        netif = netif_get_by_index(pcb->mcast_ifindex);
      }
#if LWIP_IPV4
      else
#if LWIP_IPV6
        if (IP_IS_V4(dst_ip))
#endif /* LWIP_IPV6 */
        {
          /* IPv4 does not use source-based routing by default, so we use an
             administratively selected interface for multicast by default.
             However, this can be overridden by setting an interface address
             in pcb->mcast_ip4 that is used for routing. If this routing lookup
             fails, we try regular routing as though no override was set. */
          if (!ip4_addr_isany_val(pcb->mcast_ip4) &&
              !ip4_addr_cmp(&pcb->mcast_ip4, IP4_ADDR_BROADCAST)) {
            netif = ip4_route_src(ip_2_ip4(&pcb->local_ip), &pcb->mcast_ip4);
          }
        }
#endif /* LWIP_IPV4 */
    }

    if (netif == NULL)
#endif /* LWIP_MULTICAST_TX_OPTIONS */
    {
      /* find the outgoing network interface for this packet */
      netif = ip_route(&pcb->local_ip, dst_ip);
    }
  }

  /* no outgoing network interface could be found? */
  if (netif == NULL) {
    LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, ("udp_send: No route to "));
    ip_addr_debug_print(UDP_DEBUG | LWIP_DBG_LEVEL_SERIOUS, dst_ip);
    LWIP_DEBUGF(UDP_DEBUG, ("\n"));
    UDP_STATS_INC(udp.rterr);
    return ERR_RTE;
  }
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
#if TUN2SOCKS
  return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum, src_ip, src_port);
#else
  return udp_sendto_if_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum);
#endif /* TUN2SOCKS */
#else /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
#if TUN2SOCKS
  return udp_sendto_if(pcb, p, dst_ip, dst_port, netif, src_ip, src_port);
#else
  return udp_sendto_if(pcb, p, dst_ip, dst_port, netif);
#endif /* TUN2SOCKS */
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0xd299
movq %rsi, %r14
testq %rsi, %rsi
je 0xd2b5
movq %rdx, %rbx
testq %rdx, %rdx
je 0xd2d1
movl %r9d, %r15d
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdi, %r13
movb 0x14(%rdi), %al
cmpb $0x2e, %al
je 0xd20f
movb $-0x6, %cl
cmpb 0x14(%rbx), %al
jne 0xd288
movb 0x30(%r13), %al
testb %al, %al
je 0xd221
movzbl %al, %edi
callq 0x4d9d
jmp 0xd23c
cmpb $0x6, 0x14(%rbx)
jne 0xd234
movq %r13, %rdi
movq %rbx, %rsi
callq 0xf744
jmp 0xd23c
movq %rbx, %rdi
callq 0xe120
testq %rax, %rax
je 0xd286
movb 0x14(%r13), %dl
cmpb $0x2e, %dl
je 0xd251
movb $-0x6, %cl
cmpb 0x14(%rbx), %dl
jne 0xd288
subq $0x8, %rsp
movzwl 0x50(%rsp), %r10d
movzwl %r15w, %r11d
movzwl %r12w, %ecx
movzbl %bpl, %r9d
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
movq %rax, %r8
pushq %r10
pushq 0x50(%rsp)
pushq %r11
callq 0xd3d2
addq $0x28, %rsp
jmp 0xd28e
movb $-0x4, %cl
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x702c(%rip), %rdi      # 0x142cc
leaq 0x8d77(%rip), %rsi      # 0x1601e
leaq 0x8cba(%rip), %rcx      # 0x15f68
movl $0x246, %edx            # imm = 0x246
jmp 0xd2eb
leaq 0x7010(%rip), %rdi      # 0x142cc
leaq 0x8d73(%rip), %rsi      # 0x16036
leaq 0x8c9e(%rip), %rcx      # 0x15f68
movl $0x247, %edx            # imm = 0x247
jmp 0xd2eb
leaq 0x6ff4(%rip), %rdi      # 0x142cc
leaq 0x8d70(%rip), %rsi      # 0x1604f
leaq 0x8c82(%rip), %rcx      # 0x15f68
movl $0x248, %edx            # imm = 0x248
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050