// File: /workspace/github_c_makefile_star2_O1/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 0xd50b
movq %rsi, %r14
testq %rsi, %rsi
je 0xd527
movq %rdx, %rbx
testq %rdx, %rdx
je 0xd543
movl %r9d, %r15d
movl %r8d, %ebp
movl %ecx, %r12d
movq %rdi, %r13
movb 0x14(%rdi), %al
cmpb $0x2e, %al
je 0xd481
movb $-0x6, %cl
cmpb 0x14(%rbx), %al
jne 0xd4fa
movb 0x30(%r13), %al
testb %al, %al
je 0xd493
movzbl %al, %edi
callq 0x4dfd
jmp 0xd4ae
cmpb $0x6, 0x14(%rbx)
jne 0xd4a6
movq %r13, %rdi
movq %rbx, %rsi
callq 0xfae4
jmp 0xd4ae
movq %rbx, %rdi
callq 0xe3b4
testq %rax, %rax
je 0xd4f8
movb 0x14(%r13), %dl
cmpb $0x2e, %dl
je 0xd4c3
movb $-0x6, %cl
cmpb 0x14(%rbx), %dl
jne 0xd4fa
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 0xd644
addq $0x28, %rsp
jmp 0xd500
movb $-0x4, %cl
movl %ecx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7dba(%rip), %rdi      # 0x152cc
leaq 0x9b3d(%rip), %rsi      # 0x17056
leaq 0x9a80(%rip), %rcx      # 0x16fa0
movl $0x246, %edx            # imm = 0x246
jmp 0xd55d
leaq 0x7d9e(%rip), %rdi      # 0x152cc
leaq 0x9b39(%rip), %rsi      # 0x1706e
leaq 0x9a64(%rip), %rcx      # 0x16fa0
movl $0x247, %edx            # imm = 0x247
jmp 0xd55d
leaq 0x7d82(%rip), %rdi      # 0x152cc
leaq 0x9b36(%rip), %rsi      # 0x17087
leaq 0x9a48(%rip), %rcx      # 0x16fa0
movl $0x248, %edx            # imm = 0x248
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050