// File: /workspace/github_c_makefile_star2_O3/FH0[P]tun_direct/lwip-2.1.2/src/core/udp.c
// Function: udp_connect
err_t
udp_connect(struct udp_pcb *pcb, const ip_addr_t *ipaddr, u16_t port)
{
  struct udp_pcb *ipcb;

  LWIP_ASSERT_CORE_LOCKED();

  LWIP_ERROR("udp_connect: invalid pcb", pcb != NULL, return ERR_ARG);
  LWIP_ERROR("udp_connect: invalid ipaddr", ipaddr != NULL, return ERR_ARG);

  if (pcb->local_port == 0) {
    err_t err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
    if (err != ERR_OK) {
      return err;
    }
  }

  ip_addr_set_ipaddr(&pcb->remote_ip, ipaddr);
#if LWIP_IPV6 && LWIP_IPV6_SCOPES
  /* If the given IP address should have a zone but doesn't, assign one now,
   * using the bound address to make a more informed decision when possible. */
  if (IP_IS_V6(&pcb->remote_ip) &&
      ip6_addr_lacks_zone(ip_2_ip6(&pcb->remote_ip), IP6_UNKNOWN)) {
    ip6_addr_select_zone(ip_2_ip6(&pcb->remote_ip), ip_2_ip6(&pcb->local_ip));
  }
#endif /* LWIP_IPV6 && LWIP_IPV6_SCOPES */

  pcb->remote_port = port;
  pcb->flags |= UDP_FLAGS_CONNECTED;

  LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("udp_connect: connected to "));
  ip_addr_debug_print_val(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE,
                          pcb->remote_ip);
  LWIP_DEBUGF(UDP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, (", port %"U16_F")\n", pcb->remote_port));

  /* Insert UDP PCB into the list of active UDP PCBs. */
  for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
    if (pcb == ipcb) {
      /* already on the list, just return */
      return ERR_OK;
    }
  }
  /* PCB not yet on the list, add PCB now */
  pcb->next = udp_pcbs;
  udp_pcbs = pcb;
  return ERR_OK;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0xdad5
movq %rsi, %r14
testq %rsi, %rsi
je 0xdaf1
movl %edx, %ebp
movq %rdi, %rbx
cmpw $0x0, 0x42(%rdi)
je 0xdab7
movb 0x14(%r14), %cl
movb %cl, 0x2c(%rbx)
movl (%r14), %eax
movl %eax, 0x18(%rbx)
cmpb $0x6, %cl
jne 0xda76
movl 0x4(%r14), %ecx
movl %ecx, 0x1c(%rbx)
movl 0x8(%r14), %ecx
movl %ecx, 0x20(%rbx)
movl 0xc(%r14), %ecx
movl %ecx, 0x24(%rbx)
movb 0x10(%r14), %cl
movb %cl, 0x28(%rbx)
testb %cl, %cl
jne 0xda83
movl %eax, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
cmpl $0x80fe, %ecx           # imm = 0x80FE
je 0xda2c
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0xda2c
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0xda83
leaq 0x18(%rbx), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf744
testq %rax, %rax
je 0xda83
movl (%r14), %ecx
movl %ecx, %edx
andl $0xc0ff, %edx           # imm = 0xC0FF
cmpl $0x80fe, %edx           # imm = 0x80FE
je 0xda69
andl $0x8fff, %ecx           # imm = 0x8FFF
cmpl $0x2ff, %ecx            # imm = 0x2FF
je 0xda69
cmpl $0x1ff, %ecx            # imm = 0x1FF
jne 0xdad1
movb 0xee(%rax), %al
incb %al
movb %al, 0x28(%rbx)
jmp 0xda83
leaq 0x1c(%rbx), %rax
xorl %ecx, %ecx
movq %rcx, 0x5(%rax)
movq %rcx, (%rax)
movw %bp, 0x44(%rbx)
orb $0x4, 0x40(%rbx)
movq 0xef0e(%rip), %rax      # 0x1c9a0
testq %rax, %rax
je 0xdaa8
movq %rax, %rcx
cmpq %rbx, %rcx
je 0xdab3
movq 0x38(%rcx), %rcx
testq %rcx, %rcx
jne 0xda9a
movq %rax, 0x38(%rbx)
movq %rbx, 0xeeed(%rip)      # 0x1c9a0
xorl %eax, %eax
jmp 0xdacc
movq %rbx, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xd6e8
testb %al, %al
je 0xd9d3
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0xda71
leaq 0x67f0(%rip), %rdi      # 0x142cc
leaq 0x86e1(%rip), %rsi      # 0x161c4
leaq 0x847e(%rip), %rcx      # 0x15f68
movl $0x4a3, %edx            # imm = 0x4A3
jmp 0xdb0b
leaq 0x67d4(%rip), %rdi      # 0x142cc
leaq 0x86de(%rip), %rsi      # 0x161dd
leaq 0x8462(%rip), %rcx      # 0x15f68
movl $0x4a4, %edx            # imm = 0x4A4
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050