// File: /workspace/github_cpp_makefile_star2_O3/wrighteagle2d[P]wrighteaglebase/Debug/../src/UDPSocket.cpp
// Function: UDPSocket::Initial(char const*, int)
void UDPSocket::Initial(const char *host, int port) {
  struct hostent *host_ent;
  struct in_addr *addr_ptr;

#ifdef WIN32
  WORD wVersionRequested;
  WSADATA wsaData;
  wVersionRequested = MAKEWORD(2, 2);
  if (WSAStartup(wVersionRequested, &wsaData) != 0) {
    PRINT_ERROR("WSAStartup failed");
  }
  if (LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2) {
    WSACleanup();
    PRINT_ERROR("WSASTartup version mismatch");
  }
#endif

  if ((host_ent = (struct hostent *)gethostbyname(host)) == 0) {
    if (inet_addr(host) == INADDR_NONE)
      PRINT_ERROR("Invalid host name");
  } else {
    addr_ptr = (struct in_addr *)*host_ent->h_addr_list;
    host = inet_ntoa(*addr_ptr);
  }

  if ((mSockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    PRINT_ERROR("Can't create socket");
  }

  memset(&mAddress, 0, sizeof(mAddress));
  mAddress.sin_family = AF_INET;
  mAddress.sin_addr.s_addr = htonl(INADDR_ANY);
  mAddress.sin_port = htons(0);

  if (bind(mSockfd, (sockaddr *)&mAddress, sizeof(mAddress)) < 0) {
#ifdef WIN32
    closesocket(mSockfd);
#else
    close(mSockfd);
#endif
    PRINT_ERROR("Can't bind client to any port");
  }

  memset(&mAddress, 0, sizeof(mAddress));
  mAddress.sin_family = AF_INET;
  mAddress.sin_addr.s_addr = inet_addr(host);
  mAddress.sin_port = htons(port);
  mIsInitialOK = true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebx
movq %rsi, %r15
movq %rdi, %r14
movq %rsi, %rdi
callq 0x9550
testq %rax, %rax
je 0x5408f
movq 0x18(%rax), %rax
movq (%rax), %rax
movl (%rax), %edi
callq 0x9210
movq %rax, %r15
jmp 0x5412f
movq %r15, %rdi
callq 0x94d0
cmpl $-0x1, %eax
jne 0x5412f
movq 0x2ff49(%rip), %r12     # 0x83ff0
leaq 0x19185(%rip), %rsi     # 0x6d233
movl $0x14, %edx
movq %r12, %rdi
callq 0x9560
leaq 0x190d0(%rip), %rsi     # 0x6d192
movl $0x1, %edx
movq %r12, %rdi
callq 0x9560
movq %r12, %rdi
movl $0x42, %esi
callq 0x9880
movq %rax, %r12
leaq 0x17371(%rip), %rsi     # 0x6b457
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x1914e(%rip), %rsi     # 0x6d248
movl $0x11, %edx
movq %r12, %rdi
callq 0x9560
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x9160
movl %eax, 0x14(%r14)
testl %eax, %eax
jns 0x541df
movq 0x2fe9d(%rip), %r12     # 0x83ff0
leaq 0x190d9(%rip), %rsi     # 0x6d233
movl $0x14, %edx
movq %r12, %rdi
callq 0x9560
leaq 0x19024(%rip), %rsi     # 0x6d192
movl $0x1, %edx
movq %r12, %rdi
callq 0x9560
movq %r12, %rdi
movl $0x49, %esi
callq 0x9880
movq %rax, %r12
leaq 0x172c5(%rip), %rsi     # 0x6b457
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x190b4(%rip), %rsi     # 0x6d25a
movl $0x13, %edx
movq %r12, %rdi
callq 0x9560
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r12, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
movl 0x14(%r14), %eax
leaq 0x4(%r14), %r12
movq $0x0, 0xc(%r14)
movq $0x2, 0x4(%r14)
movl %eax, %edi
movq %r12, %rsi
movl $0x10, %edx
callq 0x90e0
testl %eax, %eax
jns 0x542a2
movl 0x14(%r14), %edi
callq 0x99c0
movq 0x2fdd6(%rip), %r13     # 0x83ff0
leaq 0x19012(%rip), %rsi     # 0x6d233
movl $0x14, %edx
movq %r13, %rdi
callq 0x9560
leaq 0x18f5d(%rip), %rsi     # 0x6d192
movl $0x1, %edx
movq %r13, %rdi
callq 0x9560
movq %r13, %rdi
movl $0x57, %esi
callq 0x9880
movq %rax, %r13
leaq 0x171fe(%rip), %rsi     # 0x6b457
movl $0x3, %edx
movq %rax, %rdi
callq 0x9560
leaq 0x19001(%rip), %rsi     # 0x6d26e
movl $0x1d, %edx
movq %r13, %rdi
callq 0x9560
movq (%r13), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x9480
movsbl %al, %esi
movq %r13, %rdi
callq 0x9070
movq %rax, %rdi
callq 0x9330
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movw $0x2, 0x4(%r14)
movq %r15, %rdi
callq 0x94d0
movl %eax, 0x8(%r14)
rolw $0x8, %bx
movw %bx, 0x6(%r14)
movb $0x1, (%r14)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop