// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movw %dx, %ax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movw %ax, -0x1a(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x186df
jmp 0x186b0
leaq 0xec15(%rip), %rdi      # 0x272cc
leaq 0x10eee(%rip), %rsi     # 0x295ac
movl $0x4a3, %edx            # imm = 0x4A3
leaq 0x10c86(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x186e1
jmp 0x186e3
cmpq $0x0, -0x18(%rbp)
jne 0x1871b
jmp 0x186ec
leaq 0xebd9(%rip), %rdi      # 0x272cc
leaq 0x10ecb(%rip), %rsi     # 0x295c5
movl $0x4a4, %edx            # imm = 0x4A4
leaq 0x10c4a(%rip), %rcx     # 0x29350
movb $0x0, %al
callq 0x20d0
xorl %eax, %eax
movl %eax, %edi
callq 0x21b0
callq 0x2040
jmp 0x1871d
movq -0x10(%rbp), %rax
movzwl 0x42(%rax), %eax
cmpl $0x0, %eax
jne 0x18758
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x10(%rbp), %rax
movzwl 0x42(%rax), %edx
callq 0x17fd0
movb %al, -0x29(%rbp)
movsbl -0x29(%rbp), %eax
cmpl $0x0, %eax
je 0x18756
movb -0x29(%rbp), %al
movb %al, -0x1(%rbp)
jmp 0x18a38
jmp 0x18758
jmp 0x1875a
jmp 0x1875c
movq -0x10(%rbp), %rax
addq $0x18, %rax
cmpq $0x0, %rax
je 0x1877c
jmp 0x1876c
movq -0x18(%rbp), %rax
movb 0x14(%rax), %cl
movq -0x10(%rbp), %rax
movb %cl, 0x2c(%rax)
jmp 0x1877c
jmp 0x1877e
cmpq $0x0, -0x18(%rbp)
je 0x18859
movq -0x18(%rbp), %rax
movzbl 0x14(%rax), %eax
cmpl $0x6, %eax
jne 0x18859
jmp 0x1879c
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x187ad
xorl %eax, %eax
movl %eax, -0x3c(%rbp)
jmp 0x187b6
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x187d1
xorl %eax, %eax
movl %eax, -0x40(%rbp)
jmp 0x187db
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x40(%rbp)
movl -0x40(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x1c(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x187f6
xorl %eax, %eax
movl %eax, -0x44(%rbp)
jmp 0x18800
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x1881b
xorl %eax, %eax
movl %eax, -0x48(%rbp)
jmp 0x18825
movq -0x18(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x18840
xorl %eax, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1884b
movq -0x18(%rbp), %rax
movzbl 0x10(%rax), %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x28(%rax)
jmp 0x188a8
movq -0x18(%rbp), %rax
cmpq $0x0, %rax
jne 0x1886a
xorl %eax, %eax
movl %eax, -0x50(%rbp)
jmp 0x18873
movq -0x18(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x50(%rbp)
movl -0x50(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x20(%rax)
movq -0x10(%rbp), %rax
movl $0x0, 0x1c(%rax)
movq -0x10(%rbp), %rax
movb $0x0, 0x28(%rax)
jmp 0x188a8
jmp 0x188aa
movq -0x10(%rbp), %rax
addq $0x18, %rax
cmpq $0x0, %rax
je 0x189ab
movq -0x10(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x6, %eax
jne 0x189ab
movq -0x10(%rbp), %rax
movzbl 0x28(%rax), %eax
cmpl $0x0, %eax
jne 0x189ab
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0xc0ff, %rax           # imm = 0xC0FF
cmpq $0x80fe, %rax           # imm = 0x80FE
je 0x18921
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0x8fff, %rax           # imm = 0x8FFF
cmpq $0x1ff, %rax            # imm = 0x1FF
je 0x18921
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0x8fff, %rax           # imm = 0x8FFF
cmpq $0x2ff, %rax            # imm = 0x2FF
jne 0x189ab
jmp 0x18923
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rsi
addq $0x18, %rsi
callq 0x1c270
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x189a7
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0xc0ff, %rax           # imm = 0xC0FF
cmpq $0x80fe, %rax           # imm = 0x80FE
je 0x1897e
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0x8fff, %rax           # imm = 0x8FFF
cmpq $0x1ff, %rax            # imm = 0x1FF
je 0x1897e
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
andq $0x8fff, %rax           # imm = 0x8FFF
cmpq $0x2ff, %rax            # imm = 0x2FF
jne 0x18994
movq -0x38(%rbp), %rax
movzbl 0xee(%rax), %eax
addl $0x1, %eax
movzbl %al, %eax
movl %eax, -0x54(%rbp)
jmp 0x1899b
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0x1899b
movl -0x54(%rbp), %eax
movb %al, %cl
movq -0x10(%rbp), %rax
movb %cl, 0x28(%rax)
jmp 0x189a9
jmp 0x189ab
movw -0x1a(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, 0x44(%rax)
movq -0x10(%rbp), %rax
movzbl 0x40(%rax), %ecx
orl $0x4, %ecx
movb %cl, 0x40(%rax)
jmp 0x189c7
jmp 0x189c9
movq -0x10(%rbp), %rax
movzbl 0x2c(%rax), %eax
cmpl $0x6, %eax
jne 0x189dc
jmp 0x189d8
jmp 0x189da
jmp 0x189e2
jmp 0x189de
jmp 0x189e0
jmp 0x189e2
jmp 0x189e4
jmp 0x189e6
jmp 0x189e8
movq 0x16fb9(%rip), %rax     # 0x2f9a8
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x18a1a
movq -0x10(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x18a0a
movb $0x0, -0x1(%rbp)
jmp 0x18a38
jmp 0x18a0c
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0x189f3
movq 0x16f87(%rip), %rcx     # 0x2f9a8
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq %rax, 0x16f74(%rip)     # 0x2f9a8
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)