// File: /workspace/github_cpp_makefile_star2_O3/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 0x7f5b(%rip), %rdi      # 0xb220
callq 0x2310
movq 0x7fd7(%rip), %rcx      # 0xb2a8
movq (%rcx), %rax
movq 0x8(%rcx), %rcx
movabsq $-0x1111111111111111, %rdx # imm = 0xEEEEEEEEEEEEEEEF
subq %rax, %rcx
je 0x330d
sarq $0x3, %rcx
imulq %rdx, %rcx
xorl %edx, %edx
imulq $0x78, %rdx, %rsi
cmpl %r14d, 0x4(%rax,%rsi)
je 0x3308
incl %edx
cmpq %rdx, %rcx
ja 0x32f1
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movslq %edx, %rcx
jmp 0x3314
movq $-0x1, %rcx
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 0x4dea(%rip), %rsi      # 0x812a
movq %rbx, %rdi
callq 0x23c0
movq 0x7f59(%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 0x33bd
movl $0x4, %r13d
movl $0xd1b71759, %eax       # imm = 0xD1B71759
movl %r12d, %ecx
cmpl $0x63, %ecx
jbe 0x33b4
cmpl $0x3e7, %ecx            # imm = 0x3E7
jbe 0x33ba
cmpl $0x2710, %ecx           # imm = 0x2710
jb 0x33bd
movl %ecx, %edx
imulq %rax, %rdx
shrq $0x2d, %rdx
addl $0x4, %r13d
cmpl $0x1869f, %ecx          # imm = 0x1869F
movl %edx, %ecx
ja 0x3381
addl $-0x3, %r13d
jmp 0x33bd
addl $-0x2, %r13d
jmp 0x33bd
decl %r13d
shrl $0x1f, %r15d
leal (%r15,%r13), %esi
leaq -0x60(%rbp), %rax
movq %rax, -0x10(%rax)
leaq -0x70(%rbp), %rdi
movl $0x2d, %edx
callq 0x22c0
addq -0x70(%rbp), %r15
movq %r15, %rdi
movl %r13d, %esi
movl %r12d, %edx
callq 0x6666
movq -0x50(%rbp), %rcx
movq -0x48(%rbp), %r8
movq -0x68(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %edi
leaq -0x40(%rbp), %rsi
cmpq %rsi, %rcx
je 0x340f
movq -0x40(%rbp), %rdi
movq -0x70(%rbp), %rsi
cmpq %rdi, %rax
movq -0xb8(%rbp), %rbx
jbe 0x3436
movl $0xf, %edi
leaq -0x60(%rbp), %r9
cmpq %r9, %rsi
je 0x3431
movq -0x60(%rbp), %rdi
cmpq %rdi, %rax
jbe 0x3441
leaq -0x50(%rbp), %rdi
callq 0x20b0
jmp 0x344e
leaq -0x70(%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 0x3478
movq %rsi, -0x140(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x130(%rbp)
jmp 0x347e
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 0x4efb(%rip), %rsi      # 0x839f
leaq -0x140(%rbp), %rdi
callq 0x23c0
leaq -0x80(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x34d7
movq %rdx, -0x90(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x80(%rbp)
jmp 0x34de
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, -0x88(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3517
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3530
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3549
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2250
movq 0x7d58(%rip), %rax      # 0xb2a8
movq (%rax), %rax
leaq (%rax,%rbx), %rdi
addq $0x50, %rdi
leaq 0x4bca(%rip), %rsi      # 0x812c
callq 0x20a0
testl %eax, %eax
je 0x35cc
movq 0x7d36(%rip), %rcx      # 0xb2a8
movq (%rcx), %rax
cmpb $0x1, 0x71(%rax,%rbx)
jne 0x3632
movq %r15, %r12
leaq -0x180(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x4bb0(%rip), %rsi      # 0x8145
leaq 0x4bcd(%rip), %rdx      # 0x8169
leaq -0x190(%rbp), %rdi
callq 0x28ae
leaq -0x190(%rbp), %rdi
movl %r14d, %esi
callq 0x3170
movq -0x190(%rbp), %rdi
cmpq %r15, %rdi
je 0x361e
movq -0x180(%rbp), %rsi
jmp 0x3616
movq %r15, %r12
leaq -0x1a0(%rbp), %r15
movq %r15, -0x10(%r15)
leaq 0x4b4d(%rip), %rsi      # 0x812e
leaq 0x4b5c(%rip), %rdx      # 0x8144
leaq -0x1b0(%rbp), %rdi
callq 0x28ae
leaq -0x1b0(%rbp), %rdi
movl %r14d, %esi
callq 0x3170
movq -0x1b0(%rbp), %rdi
cmpq %r15, %rdi
je 0x361e
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x2250
leaq 0x7bfb(%rip), %rdi      # 0xb220
callq 0x21b0
movq %r12, %r15
jmp 0x3a0e
movq -0x88(%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
je 0x39e7
movl $0x1000, %ecx           # imm = 0x1000
subl %eax, %ecx
movslq %ecx, %rax
movq %rax, -0xc8(%rbp)
leaq -0x160(%rbp), %r13
leaq -0x170(%rbp), %r15
movq -0xc0(%rbp), %rsi
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 0x7b6b(%rip), %rdx      # 0xb2a8
movq (%rdx), %rax
movq 0x8(%rdx), %rdx
subq %rax, %rdx
je 0x3778
sarq $0x3, %rdx
movabsq $-0x1111111111111111, %rsi # imm = 0xEEEEEEEEEEEEEEEF
imulq %rsi, %rdx
xorl %esi, %esi
imulq $0x78, %rsi, %rdi
cmpl %ecx, 0x4(%rax,%rdi)
je 0x3773
incl %esi
cmpq %rsi, %rdx
ja 0x375d
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movslq %esi, %rcx
jmp 0x377f
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 0x392f
testq %rdx, %rdx
je 0x37d4
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 0x392f
cmpq $0x0, 0x8(%rsi)
je 0x392f
xorl %r12d, %r12d
leaq -0x70(%rbp), %r14
movq %r14, %rdi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x2270
movq -0x90(%rbp), %rcx
movq -0x88(%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 0x3832
movq %rdx, -0x50(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x40(%rbp)
jmp 0x3838
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 -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3868
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
movl $0xfffffffa, %r14d      # imm = 0xFFFFFFFA
incl %r14d
je 0x38c6
movq 0x799e(%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 0x2f66
movl %eax, %ebx
movq -0x170(%rbp), %rdi
cmpq %r13, %rdi
je 0x38bf
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x2250
cmpl $-0x1, %ebx
je 0x386e
jmp 0x38f8
movq -0xa8(%rbp), %rsi
cmpq -0xa0(%rbp), %rsi
je 0x38e8
movl -0x2c(%rbp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, -0xa8(%rbp)
jmp 0x38f8
leaq -0xb0(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x6b94
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rbx
cmpq %rbx, %rdi
je 0x3911
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 0x37e2
movq -0xf0(%rbp), %rdi
leaq -0xe0(%rbp), %rax
cmpq %rax, %rdi
movq %rsi, %rbx
je 0x3957
movq -0xe0(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x397c
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x39a1
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rsi
movq -0x150(%rbp), %r12
addq $0x78, %r12
cmpq -0x148(%rbp), %r12
jne 0x368b
movq -0xb0(%rbp), %rbx
movq -0xa8(%rbp), %r14
cmpq %r14, %rbx
leaq -0x80(%rbp), %r15
je 0x39e7
movl (%rbx), %esi
movq 0x78cf(%rip), %rdi      # 0xb2a8
callq 0x5e4e
addq $0x4, %rbx
cmpq %r14, %rbx
jne 0x39d0
leaq 0x7832(%rip), %rdi      # 0xb220
callq 0x21b0
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3a0e
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2250
movq -0x90(%rbp), %rdi
cmpq %r15, %rdi
je 0x3a26
movq -0x80(%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 0x3a75
movq -0x180(%rbp), %rsi
jmp 0x3a68
jmp 0x3a72
movq %rax, %rbx
movq -0x1b0(%rbp), %rdi
cmpq %r15, %rdi
je 0x3a75
movq -0x1a0(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3a75
movq %rax, %rbx
movq %r12, %r15
jmp 0x3bd5
movq %rax, %rbx
leaq -0x130(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3aa4
movq -0x130(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3aa4
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3ac4
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3ac4
jmp 0x3ac1
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x3bed
movq -0x40(%rbp), %rsi
jmp 0x3be5
movq %rax, %rbx
jmp 0x3bba
movq %rax, %rbx
jmp 0x3b37
movq %rax, %rbx
jmp 0x3b15
movq %rax, %rbx
movq -0x118(%rbp), %rdi
leaq -0x108(%rbp), %rax
cmpq %rax, %rdi
je 0x3b15
movq -0x108(%rbp), %rsi
incq %rsi
callq 0x2250
movq -0x138(%rbp), %rdi
leaq -0x128(%rbp), %rax
cmpq %rax, %rdi
je 0x3b37
movq -0x128(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x80(%rbp), %r15
jmp 0x3bba
jmp 0x3b8e
movq %rax, %rbx
jmp 0x3b60
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x3b60
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x80(%rbp), %r15
jmp 0x3bae
movq %rax, %rbx
movq -0x170(%rbp), %rdi
cmpq %r13, %rdi
leaq -0x80(%rbp), %r15
leaq -0x40(%rbp), %r14
je 0x3b99
movq -0x160(%rbp), %rsi
incq %rsi
callq 0x2250
jmp 0x3b99
movq %rax, %rbx
leaq -0x80(%rbp), %r15
leaq -0x40(%rbp), %r14
movq -0x50(%rbp), %rdi
cmpq %r14, %rdi
je 0x3bae
movq -0x40(%rbp), %rsi
incq %rsi
callq 0x2250
leaq -0x140(%rbp), %rdi
callq 0x5ec8
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3bd5
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2250
movq -0x90(%rbp), %rdi
cmpq %r15, %rdi
je 0x3bed
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2250
movq %rbx, %rdi
callq 0x2380