// File: /workspace/github_c_makefile_star2_O2/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 0xd512
movq %rsi, %r14
testq %rsi, %rsi
je 0xd52e
movl %edx, %ebp
movq %rdi, %rbx
cmpw $0x0, 0x42(%rdi)
je 0xd4f4
movb 0x14(%r14), %cl
movb %cl, 0x2c(%rbx)
movl (%r14), %eax
movl %eax, 0x18(%rbx)
cmpb $0x6, %cl
jne 0xd4af
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 0xd4bc
movl %eax, %ecx
andl $0xc0ff, %ecx           # imm = 0xC0FF
cmpl $0x80fe, %ecx           # imm = 0x80FE
je 0xd466
andl $0x8fff, %eax           # imm = 0x8FFF
cmpw $0x2ff, %ax             # imm = 0x2FF
je 0xd466
cmpl $0x1ff, %eax            # imm = 0x1FF
jne 0xd4bc
leaq 0x18(%rbx), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf144
testq %rax, %rax
je 0xd4bc
movl (%r14), %ecx
movl %ecx, %edx
andl $0xc0ff, %edx           # imm = 0xC0FF
cmpl $0x80fe, %edx           # imm = 0x80FE
je 0xd4a2
andl $0x8fff, %ecx           # imm = 0x8FFF
cmpw $0x2ff, %cx             # imm = 0x2FF
je 0xd4a2
cmpl $0x1ff, %ecx            # imm = 0x1FF
jne 0xd50e
movb 0xee(%rax), %al
incb %al
movb %al, 0x28(%rbx)
jmp 0xd4bc
leaq 0x1c(%rbx), %rax
andq $0x0, 0x5(%rax)
andq $0x0, (%rax)
movw %bp, 0x44(%rbx)
orb $0x4, 0x40(%rbx)
leaq 0x104dd(%rip), %rax     # 0x1d9a8
movq (%rax), %rcx
testq %rcx, %rcx
je 0xd4de
leaq 0x38(%rcx), %rax
cmpq %rbx, %rcx
jne 0xd4cb
jmp 0xd4f0
movq 0x104c3(%rip), %rax     # 0x1d9a8
movq %rax, 0x38(%rbx)
movq %rbx, 0x104b8(%rip)     # 0x1d9a8
xorl %eax, %eax
jmp 0xd509
movq %rbx, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0xd12a
testb %al, %al
je 0xd40e
popq %rbx
popq %r14
popq %rbp
retq
xorl %eax, %eax
jmp 0xd4aa
leaq 0x6db3(%rip), %rdi      # 0x142cc
leaq 0x8cbc(%rip), %rsi      # 0x161dc
leaq 0x8a59(%rip), %rcx      # 0x15f80
movl $0x4a3, %edx            # imm = 0x4A3
jmp 0xd548
leaq 0x6d97(%rip), %rdi      # 0x142cc
leaq 0x8cb9(%rip), %rsi      # 0x161f5
leaq 0x8a3d(%rip), %rcx      # 0x15f80
movl $0x4a4, %edx            # imm = 0x4A4
xorl %eax, %eax
callq 0x20d0
xorl %edi, %edi
callq 0x21b0
callq 0x2050