// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/udp.c
// Function: udp_sendto_if_chksum
err_t
udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_ip,
                     u16_t dst_port, struct netif *netif, u8_t have_chksum,
                     u16_t chksum)
{
#endif /* TUN2SOCKS */
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
#if TUN2SOCKS
#else
  const ip_addr_t *src_ip;
#endif /* TUN2SOCKS */

  LWIP_ERROR("udp_sendto_if: invalid pcb", pcb != NULL, return ERR_ARG);
  LWIP_ERROR("udp_sendto_if: invalid pbuf", p != NULL, return ERR_ARG);
  LWIP_ERROR("udp_sendto_if: invalid dst_ip", dst_ip != NULL, return ERR_ARG);
  LWIP_ERROR("udp_sendto_if: invalid netif", netif != NULL, return ERR_ARG);

  if (!IP_ADDR_PCB_VERSION_MATCH(pcb, dst_ip)) {
    return ERR_VAL;
  }

#if TUN2SOCKS
#else
  /* PCB local address is IP_ANY_ADDR or multicast? */
#if LWIP_IPV6
  if (IP_IS_V6(dst_ip)) {
    if (ip6_addr_isany(ip_2_ip6(&pcb->local_ip)) ||
        ip6_addr_ismulticast(ip_2_ip6(&pcb->local_ip))) {
      src_ip = ip6_select_source_address(netif, ip_2_ip6(dst_ip));
      if (src_ip == NULL) {
        /* No suitable source address was found. */
        return ERR_RTE;
      }
    } else {
      /* use UDP PCB local IPv6 address as source address, if still valid. */
      if (netif_get_ip6_addr_match(netif, ip_2_ip6(&pcb->local_ip)) < 0) {
        /* Address isn't valid anymore. */
        return ERR_RTE;
      }
      src_ip = &pcb->local_ip;
    }
  }
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
  else
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
    if (ip4_addr_isany(ip_2_ip4(&pcb->local_ip)) ||
        ip4_addr_ismulticast(ip_2_ip4(&pcb->local_ip))) {
      /* if the local_ip is any or multicast
       * use the outgoing network interface IP address as source address */
      src_ip = netif_ip_addr4(netif);
    } else {
      /* check if UDP PCB local IP address is correct
       * this could be an old address if netif->ip_addr has changed */
      if (!ip4_addr_cmp(ip_2_ip4(&(pcb->local_ip)), netif_ip4_addr(netif))) {
        /* local_ip doesn't match, drop the packet */
        return ERR_RTE;
      }
      /* use UDP PCB local IP address as source address */
      src_ip = &pcb->local_ip;
    }
#endif /* LWIP_IPV4 */
#endif /* TUN2SOCKS */
#if LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP
#if TUN2SOCKS
  return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum, src_ip, src_port);
#else
  return udp_sendto_if_src_chksum(pcb, p, dst_ip, dst_port, netif, have_chksum, chksum, src_ip);
#endif /* TUN2SOCKS */
#else /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
#if TUN2SOCKS
  return udp_sendto_if_src(pcb, p, dst_ip, dst_port, netif, src_ip, src_port);
#else
  return udp_sendto_if_src(pcb, p, dst_ip, dst_port, netif, src_ip);
#endif /* TUN2SOCKS */
#endif /* LWIP_CHECKSUM_ON_COPY && CHECKSUM_GEN_UDP */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %r9b, %al
movw 0x20(%rbp), %r9w
movq 0x18(%rbp), %r9
movw 0x10(%rbp), %r9w
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movw %cx, -0x22(%rbp)
movq %r8, -0x30(%rbp)
movb %al, -0x31(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x17908
jmp 0x178d9
leaq 0xf9ec(%rip), %rdi      # 0x272cc
leaq 0x11b6b(%rip), %rsi     # 0x29452
movl $0x2cc, %edx            # imm = 0x2CC
leaq 0x11a5d(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1790a
jmp 0x1790c
cmpq $0x0, -0x18(%rbp)
jne 0x17944
jmp 0x17915
leaq 0xf9b0(%rip), %rdi      # 0x272cc
leaq 0x11b4a(%rip), %rsi     # 0x2946d
movl $0x2cd, %edx            # imm = 0x2CD
leaq 0x11a21(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x17946
jmp 0x17948
cmpq $0x0, -0x20(%rbp)
jne 0x17980
jmp 0x17951
leaq 0xf974(%rip), %rdi      # 0x272cc
leaq 0x11b2a(%rip), %rsi     # 0x29489
movl $0x2ce, %edx            # imm = 0x2CE
leaq 0x119e5(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x17982
jmp 0x17984
cmpq $0x0, -0x30(%rbp)
jne 0x179bc
jmp 0x1798d
leaq 0xf938(%rip), %rdi      # 0x272cc
leaq 0x11b0c(%rip), %rsi     # 0x294a7
movl $0x2cf, %edx            # imm = 0x2CF
leaq 0x119a9(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x179be
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x2e, %eax
je 0x179e5
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
movq -0x20(%rbp), %rcx
movzbl 0x14(%rcx), %ecx
cmpl %ecx, %eax
je 0x179e5
movb $-0x6, -0x1(%rbp)
jmp 0x17a2a
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movw -0x22(%rbp), %cx
movq -0x30(%rbp), %r8
movb -0x31(%rbp), %r9b
movw 0x10(%rbp), %r10w
movq 0x18(%rbp), %rax
movzwl %cx, %ecx
movzbl %r9b, %r9d
movzwl %r10w, %r10d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movzwl 0x20(%rbp), %eax
movl %eax, 0x10(%rsp)
callq 0x17ab0
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)