// File: /workspace/github_c_makefile_star2_O1/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 0xdd52
movq %rsi, %r14
testq %rsi, %rsi
je 0xdd6e
movl %edx, %ebp
movq %rdi, %rbx
movzwl 0x42(%rdi), %eax
testw %ax, %ax
je 0xdd33
movb 0x14(%r14), %al
movb %al, 0x2c(%rbx)
cmpb $0x6, 0x14(%r14)
movl (%r14), %ecx
movl %ecx, 0x18(%rbx)
jne 0xdc7c
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)
jmp 0xdc86
xorl %ecx, %ecx
movq %rcx, 0x21(%rbx)
movq %rcx, 0x1c(%rbx)
cmpb $0x6, %al
jne 0xdcfe
cmpb $0x0, 0x28(%rbx)
jne 0xdcfe
leaq 0x18(%rbx), %r14
movl (%r14), %eax
movl %eax, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
cmpl $0x80fe, %ecx           # imm = 0x80FE
je 0xdcba
andl $0x8fff, %eax           # imm = 0x8FFF
cmpl $0x2ff, %eax            # imm = 0x2FF
je 0xdcba
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0xdcfe
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfae4
testq %rax, %rax
je 0xdcfe
movl (%r14), %ecx
movl %ecx, %edx
andl $0xc0ff, %edx           # imm = 0xC0FF
cmpl $0x80fe, %edx           # imm = 0x80FE
je 0xdcf3
andl $0x8fff, %ecx           # imm = 0x8FFF
cmpl $0x2ff, %ecx            # imm = 0x2FF
je 0xdcf3
cmpl $0x1ff, %ecx            # imm = 0x1FF
jne 0xdd4e
movb 0xee(%rax), %al
incb %al
movb %al, 0x28(%rbx)
movw %bp, 0x44(%rbx)
orb $0x4, 0x40(%rbx)
movq 0xfc93(%rip), %rax      # 0x1d9a0
testq %rax, %rax
je 0xdd1d
cmpq %rbx, %rax
je 0xdd2f
movq 0x38(%rax), %rax
jmp 0xdd0d
movq 0xfc7c(%rip), %rax      # 0x1d9a0
movq %rax, 0x38(%rbx)
movq %rbx, 0xfc71(%rip)      # 0x1d9a0
xorl %eax, %eax
jmp 0xdd49
movzwl %ax, %edx
movq %rbx, %rdi
movq %rbx, %rsi
callq 0xd95d
testb %al, %al
je 0xdc4a
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0xdcfb
leaq 0x7573(%rip), %rdi      # 0x152cc
leaq 0x949c(%rip), %rsi      # 0x171fc
leaq 0x9239(%rip), %rcx      # 0x16fa0
movl $0x4a3, %edx            # imm = 0x4A3
jmp 0xdd88
leaq 0x7557(%rip), %rdi      # 0x152cc
leaq 0x9499(%rip), %rsi      # 0x17215
leaq 0x921d(%rip), %rcx      # 0x16fa0
movl $0x4a4, %edx            # imm = 0x4A4
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050