// File: /workspace/github_cpp_makefile_star2_O1/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 0x8400
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 0x9c48
cmpb $0x2a, (%rdi)
jne 0x9c4c
xorl %eax, %eax
jmp 0x9c5d
movb $0x1, %al
jmp 0x9c5d
movq 0x933d(%rip), %rsi      # 0x12f90
callq 0x8710
testl %eax, %eax
sete %al
movzbl %al, %ecx
leal 0x2(,%rcx,8), %ecx
cmpl %ecx, 0x4(%rbx)
je 0x9d4a
testb %al, %al
je 0x9ca0
movq %rsp, %rsi
movq %r15, %rdi
callq 0x8950
testq %rax, %rax
je 0x9d7c
movups (%rax), %xmm0
movq %rsp, %rsi
movups %xmm0, (%rsi)
movq %rbx, %rdi
movl $0x10, %edx
callq 0x9e1b
jmp 0x9ced
leaq 0x30(%rsp), %rsi
movq %r15, %rdi
callq 0x83b0
testq %rax, %rax
je 0x9d92
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)
movq %rbx, %rdi
movl $0x1c, %edx
callq 0x9e1b
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 0x9d3e
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 0x4472(%rip), %rsi      # 0xe1d0
movq %rax, %rdi
callq 0x8790
movq 0x9243(%rip), %rsi      # 0x12fb0
movq 0x91e4(%rip), %rdx      # 0x12f58
movq %r12, %rdi
callq 0x8900
movq 0x918d(%rip), %rax      # 0x12f10
addq $0x10, %rax
movq %rsp, %rdi
movq %rax, (%rdi)
callq 0x84b0
movq 0x9177(%rip), %rax      # 0x12f10
addq $0x10, %rax
leaq 0x30(%rsp), %rdi
movq %rax, (%rdi)
callq 0x84b0
jmp 0x9dfb
jmp 0x9dfb
movq %rax, %r15
leaq 0x30(%rsp), %rdi
jmp 0x9dbe
movq %rax, %r15
movq %rsp, %rdi
callq 0x89c0
jmp 0x9dfe
jmp 0x9dc7
movq %rax, %rdi
callq 0x95b2
jmp 0x9dfb
movq %rax, %r15
movq %r12, %rdi
callq 0x8330
jmp 0x9dfe
jmp 0x9de0
movq %rax, %r15
movq (%rsp), %rdi
cmpq %r12, %rdi
je 0x9dfe
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x84c0
jmp 0x9dfe
movq %rax, %r15
movq %r14, %rdi
callq 0x87a0
movq %rbx, %rdi
callq 0x8510
movq %r15, %rdi
callq 0x8970
movq %rax, %r15
jmp 0x9e06