// File: /workspace/github_cpp_makefile_star2_O3/dak98[P]SocketIO/src/client.cpp
// Function: socket_io::client::client(socket_io::socket&&, boost::variant<socket_io::socket_address<sockaddr_in>, socket_io::socket_address<sockaddr_in6>> const&)
client::client(socket&& client,
	       ip_socket_address const& address_of_server)
    : main_socket{std::move(client)}, address_of_server{address_of_server}
{
    bool is_ipv4 = address_of_server.type() == typeid(ipv4_socket_address);
    auto ip_version = main_socket.get_ip_protocol();

    if ((is_ipv4 && ip_version == ip_protocol::IPv6) ||
	(!is_ipv4 && ip_version == ip_protocol::IPv4))
	throw std::logic_error{"Socket and address have different protocols"};
    
    if (is_ipv4)
    {
	auto to_connect = boost::get<ipv4_socket_address>(address_of_server);
	sockaddr_in addr_in = to_connect.get_native_handle();
	socket_io::connect(main_socket, reinterpret_cast<sockaddr*>(&addr_in),
			   sizeof(sockaddr_in));
    }
    else
    {
	auto to_connect = boost::get<ipv6_socket_address>(address_of_server);	
	sockaddr_in6 addr_in6 = to_connect.get_native_handle();
	socket_io::connect(main_socket, reinterpret_cast<sockaddr*>(&addr_in6),
			   sizeof(sockaddr_in6));
    }


    std::string idStr;
    main_socket.make_view() >> idStr;
    id = string_to_integer<int>(idStr);
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r15
movq %rdi, %rbx
callq 0x8410
leaq 0x8(%rbx), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x8880
movq %rsp, %rsi
movq %r15, %rdi
callq 0x8860
movq 0x8(%rax), %rdi
cmpq 0x9353(%rip), %rdi      # 0x12f90
je 0x9c4f
cmpb $0x2a, (%rdi)
jne 0x9c58
cmpl $0x2, 0x4(%rbx)
jne 0x9caa
jmp 0x9d53
movl $0xa, %eax
movb $0x1, %cl
jmp 0x9c72
movq 0x9331(%rip), %rsi      # 0x12f90
callq 0x8710
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
leal 0x2(,%rcx,8), %eax
cmpl %eax, 0x4(%rbx)
je 0x9d53
testb %cl, %cl
je 0x9caa
movq %rsp, %rsi
movq %r15, %rdi
callq 0x8950
testq %rax, %rax
je 0x9d9d
movups (%rax), %xmm0
movq %rsp, %rsi
movaps %xmm0, (%rsi)
movl (%rbx), %edi
movl $0x10, %edx
callq 0x9e24
jmp 0x9cf6
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x83c0
testq %rax, %rax
je 0x9d85
movq 0x20(%rax), %rcx
movq %rcx, 0x20(%rsp)
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movaps %xmm1, 0x10(%rsp)
movaps %xmm0, (%rsp)
movups 0xc(%rsp), %xmm1
leaq 0x30(%rsp), %rsi
movups %xmm1, 0xc(%rsi)
movaps %xmm0, (%rsi)
movl (%rbx), %edi
movl $0x1c, %edx
callq 0x9e24
leaq 0x10(%rsp), %r12
movq %r12, -0x10(%r12)
movq $0x0, -0x8(%r12)
movb $0x0, (%r12)
movq %rbx, %rdi
callq 0x80d0
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
movq %rsp, %rsi
callq 0x8180
movq %rsp, %rdi
callq 0x8810
movl %eax, 0x38(%rbx)
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x9d47
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x84c0
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movl $0x10, %edi
callq 0x8220
movq %rax, %r12
leaq 0x4469(%rip), %rsi      # 0xe1d0
movq %rax, %rdi
callq 0x8790
movq 0x923a(%rip), %rsi      # 0x12fb0
movq 0x91db(%rip), %rdx      # 0x12f58
movq %r12, %rdi
callq 0x8900
movq 0x9184(%rip), %rax      # 0x12f10
addq $0x10, %rax
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x84b0
movq 0x916c(%rip), %rax      # 0x12f10
addq $0x10, %rax
movq %rsp, %rdi
movq %rax, (%rdi)
callq 0x84b0
jmp 0x9e04
movq %rax, %r15
movq %rsp, %rdi
jmp 0x9dd8
jmp 0x9ddf
jmp 0x9e04
movq %rax, %r15
movq %r12, %rdi
callq 0x8340
jmp 0x9e07
jmp 0x9e04
movq %rax, %r15
leaq 0x30(%rsp), %rdi
callq 0x89d0
jmp 0x9e07
movq %rax, %rdi
callq 0x960d
jmp 0x9de9
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x9e07
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x84c0
jmp 0x9e07
movq %rax, %r15
movq %r14, %rdi
callq 0x87a0
movq %rbx, %rdi
callq 0x8510
movq %r15, %rdi
callq 0x8970
movq %rax, %r15
jmp 0x9e0f