// File: /workspace/github_c_makefile_star2_O0/FH0[P]tun_direct/lwip-2.1.2/src/core/raw.c
// Function: raw_sendto
err_t
raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
{
  struct netif *netif;
  const ip_addr_t *src_ip;

  if ((pcb == NULL) || (ipaddr == NULL) || !IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr)) {
    return ERR_VAL;
  }

  LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_TRACE, ("raw_sendto\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(ipaddr)) {
      /* For multicast-destined packets, use the user-provided interface index to
       * determine the outgoing interface, if an interface index is set and a
       * matching netif can be found. Otherwise, fall back to regular routing. */
      netif = netif_get_by_index(pcb->mcast_ifindex);
    }

    if (netif == NULL)
#endif /* LWIP_MULTICAST_TX_OPTIONS */
    {
      netif = ip_route(&pcb->local_ip, ipaddr);
    }
  }

  if (netif == NULL) {
    LWIP_DEBUGF(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ("raw_sendto: No route to "));
    ip_addr_debug_print(RAW_DEBUG | LWIP_DBG_LEVEL_WARNING, ipaddr);
    return ERR_RTE;
  }

  if (ip_addr_isany(&pcb->local_ip) || ip_addr_ismulticast(&pcb->local_ip)) {
    /* use outgoing network interface IP address as source address */
    src_ip = ip_netif_get_local_ip(netif, ipaddr);
#if LWIP_IPV6
    if (src_ip == NULL) {
      return ERR_RTE;
    }
#endif /* LWIP_IPV6 */
  } else {
    /* use RAW PCB local IP address as source address */
    src_ip = &pcb->local_ip;
  }

  return raw_sendto_if_src(pcb, p, ipaddr, netif, src_ip);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x9c53
cmpq $0x0, -0x20(%rbp)
je 0x9c53
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x2e, %eax
je 0x9c5c
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
movq -0x20(%rbp), %rcx
movzbl 0x14(%rcx), %ecx
cmpl %ecx, %eax
je 0x9c5c
movb $-0x6, -0x1(%rbp)
jmp 0x9e4f
jmp 0x9c5e
jmp 0x9c60
movq -0x10(%rbp), %rax
movzbl 0x30(%rax), %eax
cmpl $0x0, %eax
je 0x9c80
movq -0x10(%rbp), %rax
movzbl 0x30(%rax), %edi
callq 0x6cf0
movq %rax, -0x28(%rbp)
jmp 0x9cbc
cmpq $0x0, -0x20(%rbp)
je 0x9ca7
movq -0x20(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x9ca7
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1c270
movq %rax, -0x38(%rbp)
jmp 0x9cb4
movq -0x20(%rbp), %rdi
callq 0x196c0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x9cf4
jmp 0x9cc5
jmp 0x9cc7
jmp 0x9cc9
cmpq $0x0, -0x20(%rbp)
je 0x9ce3
movq -0x20(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x9ce3
jmp 0x9cdf
jmp 0x9ce1
jmp 0x9ce9
jmp 0x9ce5
jmp 0x9ce7
jmp 0x9ce9
jmp 0x9ceb
movb $-0x4, -0x1(%rbp)
jmp 0x9e4f
movq -0x10(%rbp), %rax
cmpq $0x0, %rax
jne 0x9d0a
movb $0x1, %al
testb $0x1, %al
jne 0x9daf
jmp 0x9d6b
movq -0x10(%rbp), %rax
cmpq $0x0, %rax
je 0x9d58
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x9d58
movq -0x10(%rbp), %rax
cmpq $0x0, %rax
je 0x9daf
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x9d6b
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4(%rax)
jne 0x9d6b
movq -0x10(%rbp), %rax
cmpl $0x0, 0x8(%rax)
jne 0x9d6b
movq -0x10(%rbp), %rax
cmpl $0x0, 0xc(%rax)
je 0x9daf
jmp 0x9d6b
movq -0x10(%rbp), %rax
cmpq $0x0, %rax
je 0x9daf
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
je 0x9daf
movq -0x10(%rbp), %rax
cmpq $0x0, %rax
je 0x9d9b
movq -0x10(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x9d9b
movq -0x10(%rbp), %rax
movl (%rax), %eax
andq $0xff, %rax
cmpq $0xff, %rax
je 0x9daf
jmp 0x9e2b
movq -0x10(%rbp), %rax
movl (%rax), %eax
andq $0xf0, %rax
cmpq $0xe0, %rax
jne 0x9e2b
cmpq $0x0, -0x20(%rbp)
je 0x9def
movq -0x20(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x9def
cmpq $0x0, -0x28(%rbp)
je 0x9ddd
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x1c290
movq %rax, -0x40(%rbp)
jmp 0x9de5
xorl %eax, %eax
movq %rax, -0x40(%rbp)
jmp 0x9de5
movq -0x40(%rbp), %rax
movq %rax, -0x48(%rbp)
jmp 0x9e14
cmpq $0x0, -0x28(%rbp)
je 0x9e04
movq -0x28(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x50(%rbp)
jmp 0x9e0c
xorl %eax, %eax
movq %rax, -0x50(%rbp)
jmp 0x9e0c
movq -0x50(%rbp), %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
jne 0x9e29
movb $-0x4, -0x1(%rbp)
jmp 0x9e4f
jmp 0x9e33
movq -0x10(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r8
callq 0x9e60
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)