// File: /workspace/github_cpp_makefile_star2_O1/davidcairuz[P]network-internet-relay-chat/server.cpp
// Function: spread_message(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int)
void spread_message(string message, int speaker) {
    pthread_mutex_lock(&lock);
    
    int pos = active->find(speaker);
    string name = active->clients[pos].name + "#" + to_string(active->clients[pos].id) + ": ";
    
    if (active->clients[pos].channel_name == "$") {
        send_message("Please, join a channel", speaker);
        pthread_mutex_unlock(&lock);
        return;
    }

    if (active->clients[pos].is_muted) {
        send_message("You have the right to remain silent!", speaker);
        pthread_mutex_unlock(&lock);
        return;
    }

    int max_len = Socket::buffer_size - name.size();
    vector<int> to_be_removed;

    for (Client client : active->clients) {
        int conn = client.conn;

        int receiver = active->find(conn);

        // checa canal do destinatário
        if (active->clients[receiver].channel_name != active->clients[pos].channel_name) continue;

        // envia batches da mensagem
        for (int i = 0; (unsigned int)i < message.size(); i += max_len) {
            string actual_message = name + message.substr(i, max_len);
            
            int status = -1, retries = Socket::max_retries;
            while (status == -1 && retries--)
                status = socket_server->Write(actual_message, conn);

            if (status == -1) to_be_removed.push_back(conn);
        }
    }

    for (int client : to_be_removed) active->remove(client);
    pthread_mutex_unlock(&lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movl %esi, %r14d
movq %rdi, -0xc0(%rbp)
leaq 0x7f72(%rip), %rdi      # 0xb220
callq 0x2310
movq 0x7fee(%rip), %rax      # 0xb2a8
movq (%rax), %rcx
movq 0x8(%rax), %rdx
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
subq %rcx, %rdx
je 0x32f6
sarq $0x3, %rdx
imulq %rsi, %rdx
xorl %esi, %esi
imulq $0x78, %rsi, %rdi
cmpl %r14d, 0x4(%rcx,%rdi)
je 0x32f1
incl %esi
cmpq %rsi, %rdx
ja 0x32da
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movslq %esi, %rcx
jmp 0x32fd
movq $-0x1, %rcx
movq (%rax), %rax
imulq $0x78, %rcx, %r15
leaq -0x40(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq 0x28(%rax,%r15), %rsi
movq 0x30(%rax,%r15), %rdx
addq %rsi, %rdx
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
callq 0x2810
leaq 0x4dfe(%rip), %rsi      # 0x812a
movq %rbx, %rdi
callq 0x23c0
movq 0x7f6d(%rip), %rax      # 0xb2a8
movq (%rax), %rax
movq %r15, -0xb8(%rbp)
movl (%rax,%r15), %r15d
movl %r15d, %r12d
negl %r12d
cmovsl %r15d, %r12d
movl $0x1, %r13d
cmpl $0xa, %r12d
jb 0x33a9
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x33a0
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x33a6
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x33a9
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x336d
addl $-0x3, %r13d
jmp 0x33a9
addl $-0x2, %r13d
jmp 0x33a9
decl %r13d
shrl $0x1f, %r15d
leal (%r15,%r13), %esi
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x90(%rbp), %rdi
movl $0x2d, %edx
callq 0x22c0
addq -0x90(%rbp), %r15
movq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x67d6
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x88(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
leaq -0x40(%rbp), %rdi
cmpq %rdi, %rcx
je 0x3404
movq -0x40(%rbp), %rsi
cmpq %rsi, %rax
movq -0xb8(%rbp), %r15
jbe 0x342b
movl $0xf, %esi
leaq -0x80(%rbp), %rdi
cmpq %rdi, -0x90(%rbp)
je 0x3426
movq -0x80(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x343d
movq -0x90(%rbp), %rsi
leaq -0x50(%rbp), %rdi
callq 0x20b0
jmp 0x344d
leaq -0x90(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a0
leaq -0x130(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x3477
movq %rsi, -0x140(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x130(%rbp)
jmp 0x347d
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x138(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x4efc(%rip), %rsi      # 0x839f
leaq -0x140(%rbp), %rdi
callq 0x23c0
leaq -0x60(%rbp), %rbx
movq %rbx, -0x10(%rbx)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x34d3
movq %rdx, -0x70(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x60(%rbp)
jmp 0x34d9
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0x68(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x350f
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x352b
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3544
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2250
movq 0x7d5d(%rip), %rax      # 0xb2a8
movq (%rax), %rax
leaq (%rax,%r15), %rdi
addq $0x50, %rdi
leaq 0x4bcf(%rip), %rsi      # 0x812c
callq 0x20a0
testl %eax, %eax
je 0x35e0
movq 0x7d3b(%rip), %rcx      # 0xb2a8
movq (%rcx), %rax
cmpb $0x1, 0x71(%rax,%r15)
jne 0x3646
leaq -0x180(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x4bb7(%rip), %rsi      # 0x8145
leaq 0x4bd4(%rip), %rdx      # 0x8169
leaq -0x190(%rbp), %rdi
callq 0x28aa
leaq -0x190(%rbp), %rdi
movl %r14d, %esi
callq 0x3168
movq -0x190(%rbp), %rdi
cmpq %r15, %rdi
je 0x35cb
movq -0x180(%rbp), %rsi
incq %rsi
callq 0x2250
leaq 0x7c4e(%rip), %rdi      # 0xb220
callq 0x21b0
leaq -0x60(%rbp), %r15
jmp 0x3a1f
movq %rbx, %r12
leaq -0x1a0(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x4b39(%rip), %rsi      # 0x812e
leaq 0x4b48(%rip), %rdx      # 0x8144
leaq -0x1b0(%rbp), %rdi
callq 0x28aa
leaq -0x1b0(%rbp), %rdi
movl %r14d, %esi
callq 0x3168
movq -0x1b0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3632
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x2250
leaq 0x7be7(%rip), %rdi      # 0xb220
callq 0x21b0
movq %r12, %r15
jmp 0x3a1f
movq -0x68(%rbp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movq (%rcx), %r12
movq 0x8(%rcx), %rcx
movq %rcx, -0x148(%rbp)
cmpq %rcx, %r12
movq -0xc0(%rbp), %rsi
je 0x39ca
movl $0x1000, %ecx           # imm = 0x1000
subl %eax, %ecx
movslq %ecx, %rax
movq %rax, -0xc8(%rbp)
leaq -0x160(%rbp), %r13
leaq -0x170(%rbp), %r15
movq %rsi, %r14
movq (%r12), %rax
movq %rax, -0x140(%rbp)
leaq -0x128(%rbp), %rax
movq %rax, -0x138(%rbp)
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
addq %rsi, %rdx
leaq -0x138(%rbp), %rdi
callq 0x2810
leaq -0x108(%rbp), %rax
movq %rax, -0x118(%rbp)
movq 0x28(%r12), %rsi
movq 0x30(%r12), %rdx
addq %rsi, %rdx
leaq -0x118(%rbp), %rdi
callq 0x2810
movl 0x48(%r12), %eax
movl %eax, -0xf8(%rbp)
leaq -0xe0(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq 0x50(%r12), %rsi
movq 0x58(%r12), %rdx
addq %rsi, %rdx
leaq -0xf0(%rbp), %rdi
callq 0x2810
movq %r12, -0x150(%rbp)
movzwl 0x70(%r12), %eax
movw %ax, -0xd0(%rbp)
movl -0x13c(%rbp), %ecx
movl %ecx, -0x2c(%rbp)
movq 0x7b5a(%rip), %rdx      # 0xb2a8
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
je 0x3789
sarq $0x3, %rdx
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
imulq %rsi, %rdx
xorl %esi, %esi
imulq $0x78, %rsi, %rdi
cmpl %ecx, 0x4(%rax,%rdi)
je 0x3784
incl %esi
cmpq %rsi, %rdx
ja 0x376e
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movslq %esi, %rcx
jmp 0x3790
movq $-0x1, %rcx
imulq $0x78, %rcx, %rcx
movq 0x58(%rax,%rcx), %rdx
movq -0xb8(%rbp), %rsi
cmpq 0x58(%rax,%rsi), %rdx
movq -0xc8(%rbp), %rbx
movq %r14, %rsi
jne 0x3940
testq %rdx, %rdx
je 0x37e5
addq %rax, %rcx
addq $0x50, %rcx
movq -0xb8(%rbp), %rsi
addq %rsi, %rax
addq $0x50, %rax
movq (%rax), %rsi
movq (%rcx), %rdi
callq 0x2260
movq %r14, %rsi
testl %eax, %eax
jne 0x3940
cmpq $0x0, 0x8(%rsi)
je 0x3940
xorl %r12d, %r12d
leaq -0x90(%rbp), %r14
movq %r14, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2270
movq -0x70(%rbp), %rcx
movq -0x68(%rbp), %r8
movq %r14, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x22a0
leaq -0x40(%rbp), %rsi
movq %rsi, -0x50(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x3840
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x3846
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq 0x8(%rax), %rdx
movq %rdx, -0x48(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3879
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2250
movl $0xfffffffa, %r14d      # imm = 0xFFFFFFFA
incl %r14d
je 0x38d7
movq 0x798d(%rip), %rbx      # 0xb218
movq %r13, -0x170(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
movq %r15, %rdi
callq 0x2810
movl -0x2c(%rbp), %edx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2f5e
movl %eax, %ebx
movq -0x170(%rbp), %rdi
cmpq %r13, %rdi
je 0x38d0
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x2250
cmpl $-0x1, %ebx
je 0x387f
jmp 0x3909
movq -0xa8(%rbp), %rsi
cmpq -0xa0(%rbp), %rsi
je 0x38f9
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0xa8(%rbp)
jmp 0x3909
leaq -0xb0(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x6d04
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rbx
cmpq %rbx, %rdi
je 0x3922
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0xc8(%rbp), %rbx
addq %rbx, %r12
movl %r12d, %eax
movq -0xc0(%rbp), %rsi
cmpq %rax, 0x8(%rsi)
ja 0x37f3
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
movq %rsi, %rbx
je 0x3968
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x398d
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x39b2
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x150(%rbp), %r12
addq $0x78, %r12
cmpq -0x148(%rbp), %r12
jne 0x369c
movq -0xb0(%rbp), %rbx
movq -0xa8(%rbp), %r14
cmpq %r14, %rbx
leaq -0x60(%rbp), %r15
je 0x39f8
movl (%rbx), %esi
movq 0x78be(%rip), %rdi      # 0xb2a8
callq 0x5fc2
addq $0x4, %rbx
cmpq %r14, %rbx
jne 0x39e1
leaq 0x7821(%rip), %rdi      # 0xb220
callq 0x21b0
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3a1f
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2250
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x3a34
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq -0x190(%rbp), %rdi
cmpq %r15, %rdi
je 0x3a69
movq -0x180(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3a69
movq %rax, %rbx
leaq -0x60(%rbp), %r15
jmp 0x3bfe
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3a95
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3a95
movq %rax, %rbx
movq %r12, %r15
jmp 0x3bfe
movq %rax, %rbx
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3ac4
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3ac4
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3ae7
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3ae7
jmp 0x3ae4
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3c13
movq -0x40(%rbp), %rsi
jmp 0x3c0b
movq %rax, %rbx
jmp 0x3b52
movq %rax, %rbx
jmp 0x3b30
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x3b30
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x3b52
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x60(%rbp), %r15
jmp 0x3be3
movq %rax, %rbx
jmp 0x3be3
jmp 0x3bb7
movq %rax, %rbx
jmp 0x3b89
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3b89
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x60(%rbp), %r15
jmp 0x3bd7
movq %rax, %rbx
movq -0x170(%rbp), %rdi
cmpq %r13, %rdi
leaq -0x60(%rbp), %r15
leaq -0x40(%rbp), %r14
je 0x3bc2
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3bc2
movq %rax, %rbx
leaq -0x60(%rbp), %r15
leaq -0x40(%rbp), %r14
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x3bd7
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x140(%rbp), %rdi
callq 0x603c
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3bfe
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2250
movq -0x70(%rbp), %rdi
cmpq %r15, %rdi
je 0x3c13
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x2380