// File: /workspace/github_c_makefile_star2_O2/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 0xccea
movq %rsi, %r14
testq %rsi, %rsi
je 0xcd06
movq %rdx, %rbx
testq %rdx, %rdx
je 0xcd22
movl %r9d, %r15d
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdi, %r13
movb 0x14(%rdi), %cl
cmpb $0x2e, %cl
je 0xcc72
movb $-0x6, %al
cmpb 0x14(%rbx), %cl
jne 0xccdb
movb 0x30(%r13), %al
testb %al, %al
je 0xcc84
movzbl %al, %edi
callq 0x4bee
jmp 0xcc9f
cmpb $0x6, 0x14(%rbx)
jne 0xcc97
movq %r13, %rdi
movq %rbx, %rsi
callq 0xf144
jmp 0xcc9f
movq %rbx, %rdi
callq 0xdb18
testq %rax, %rax
je 0xccd9
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 0xcd4f
addq $0x28, %rsp
jmp 0xccdf
movb $-0x4, %al
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x75db(%rip), %rdi      # 0x142cc
leaq 0x933e(%rip), %rsi      # 0x16036
leaq 0x9281(%rip), %rcx      # 0x15f80
movl $0x246, %edx            # imm = 0x246
jmp 0xcd3c
leaq 0x75bf(%rip), %rdi      # 0x142cc
leaq 0x933a(%rip), %rsi      # 0x1604e
leaq 0x9265(%rip), %rcx      # 0x15f80
movl $0x247, %edx            # imm = 0x247
jmp 0xcd3c
leaq 0x75a3(%rip), %rdi      # 0x142cc
leaq 0x9337(%rip), %rsi      # 0x16067
leaq 0x9249(%rip), %rcx      # 0x15f80
movl $0x248, %edx            # imm = 0x248
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050