// File: dak98[P]SocketIO/src/communication.cpp
// Function: socket_io::operator<<(socket_io::socket_view&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
auto operator<<(socket_view& dst, std::string const& to_send) -> socket_view&
{
    // Prepare data to send
    std::string::size_type const length = to_send.length();
    if (length > std::numeric_limits<uint32_t>::max())
	throw std::invalid_argument{"Input message is too long"};
    uint32_t with_byte_order = htonl(static_cast<uint32_t>(length));
    
    char buffer[length + 1];
    if (snprintf(buffer, length + 1, "%s", to_send.c_str()) < 0)
	throw std::invalid_argument{"Input message is wrong: " +
		                    get_errno_as_string()};
    
    // Send the data
    send(dst.get_native_handle(), static_cast<void*>(&with_byte_order),
	 sizeof(uint32_t));
    send(dst.get_native_handle(), static_cast<void*>(&buffer), length);

    return dst;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x201f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x88(%rbp)
callq 0x1e400
movl %eax, %ecx
movq -0x88(%rbp), %rax
movl %ecx, %ecx
cmpq %rcx, %rax
jbe 0x20f8c
movl $0x10, %edi
callq 0x1ea70
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x90(%rbp)
leaq 0x100b2(%rip), %rsi     # 0x31000
callq 0x20b80
jmp 0x20f55
movq -0x90(%rbp), %rdi
movq 0x1a055(%rip), %rsi     # 0x3afb8
movq 0x1a02e(%rip), %rdx     # 0x3af98
callq 0x20690
movq -0x90(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x1efc0
jmp 0x21103
movl -0x18(%rbp), %edi
callq 0x1f0e0
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rdx
movq %rdx, %rax
incq %rax
movq %rsp, %rcx
movq %rcx, -0x30(%rbp)
addq $0x10, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, %rsp
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1e8e0
movq -0xa0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq %rax, %rcx
leaq 0x10026(%rip), %rdx     # 0x3101a
movb $0x0, %al
callq 0x20470
cmpl $0x0, %eax
jge 0x210bf
movb $0x1, -0x79(%rbp)
movl $0x10, %edi
callq 0x1ea70
movq %rax, -0xa8(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x1f040
jmp 0x21024
leaq 0xfff2(%rip), %rsi      # 0x3101d
leaq -0x58(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x20610
jmp 0x2103a
movq -0xa8(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x20710
jmp 0x2104c
movq -0xa8(%rbp), %rdi
movb $0x0, -0x79(%rbp)
movq 0x19f5a(%rip), %rsi     # 0x3afb8
movq 0x19f33(%rip), %rdx     # 0x3af98
callq 0x20690
jmp 0x2110c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x210a9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x210a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x1ed60
leaq -0x78(%rbp), %rdi
callq 0x1ed60
testb $0x1, -0x79(%rbp)
jne 0x210b1
jmp 0x210bd
movq -0xa8(%rbp), %rdi
callq 0x1efc0
jmp 0x21103
movq -0x8(%rbp), %rdi
callq 0x1f480
movl %eax, %edi
leaq -0x28(%rbp), %rsi
movl $0x4, %edx
callq 0x21110
movq -0x8(%rbp), %rdi
callq 0x1f480
movq -0xa0(%rbp), %rsi
movl %eax, %edi
movq -0x18(%rbp), %rdx
callq 0x21110
movq -0x8(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rsp
movq %rbp, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x20840
nopl (%rax)