// File: /workspace/github_c_makefile_star2_O1/coyove[P]chann/./src/actions/chat.cpp
// Function: websocket::broadcast(mg_connection*)
void broadcast(mg_connection *conn){
        struct ChatData *d = (struct ChatData *) conn->connection_param;
        struct mg_connection *c;

        time_t rawtime;
        time(&rawtime);

        struct History *h = new History();
        strcpy(h->ssid, d->ssid);

        int len = conn->content_len - 4;
        len = len > 1023 ? 1023 : len;
        strncpy(h->message, conn->content + 4, len);
        h->message[len] = 0;

        h->timestamp = rawtime;

        history.push_front(h);
        while(history.size() > configs.global().get<int>("chat::max_histories")){
            struct History *h2 = history.back();
            delete h2;
            history.pop_back();
        }

        for (c = mg_next(server, NULL); c != NULL; c = mg_next(server, c)) {
            struct ChatData *d2 = (struct ChatData *) c->connection_param;
            if (!c->is_websocket || d2->roomID != d->roomID) continue;

            if(strcmp(d->ssid, admin_cookie.c_str()) == 0)
                mg_websocket_printf(c, WEBSOCKET_OPCODE_TEXT, "msg %c Admin %d %.*s",
                          (char) d->roomID, rawtime, conn->content_len - 4, conn->content + 4);
            else
                mg_websocket_printf(c, WEBSOCKET_OPCODE_TEXT, "msg %c %.9s %d %.*s",
                          (char) d->roomID, d->ssid, rawtime, len, h->message);
        }

        //delete [] bufMessage;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
movq 0x290(%rdi), %r13
leaq 0x50(%rsp), %rbx
movq %rbx, %rdi
callq 0xc820
movl $0x448, %edi            # imm = 0x448
callq 0xc1d0
movq %rax, %r15
leaq 0x40(%rax), %r12
movl $0x448, %edx            # imm = 0x448
movq %rax, %rdi
xorl %esi, %esi
callq 0xc360
movq %r15, (%rsp)
movq %r13, 0x20(%rsp)
leaq 0x4(%r13), %rbp
movq %r15, %rdi
movq %rbp, %rsi
callq 0xc490
movl 0x270(%r14), %ecx
addl $-0x4, %ecx
movl $0x3ff, %eax            # imm = 0x3FF
cmpl %eax, %ecx
cmovgel %eax, %ecx
movq %r14, 0x8(%rsp)
movq 0x268(%r14), %rsi
addq $0x4, %rsi
movq %rcx, 0x10(%rsp)
movslq %ecx, %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0xc1c0
movb $0x0, 0x40(%r15,%r13)
movq (%rbx), %rax
movq %rax, 0x440(%r15)
movq 0x6c67d(%rip), %rax     # 0x96da0
cmpq 0x6c67e(%rip), %rax     # 0x96da8
je 0x2a73a
movq %r15, -0x8(%rax)
addq $-0x8, 0x6c668(%rip)    # 0x96da0
jmp 0x2a749
leaq 0x6c64f(%rip), %rdi     # 0x96d90
movq %rsp, %rsi
callq 0x2b068
movq %rbp, 0x18(%rsp)
movq 0x6c683(%rip), %rbp     # 0x96dd8
movq 0x6c65c(%rip), %r13     # 0x96db8
movq 0x6c65d(%rip), %rbx     # 0x96dc0
movq 0x6c65e(%rip), %r15     # 0x96dc8
movq 0x6c63f(%rip), %r12     # 0x96db0
movq 0x6c628(%rip), %rax     # 0x96da0
movq %rax, 0x28(%rsp)
leaq 0x6c65c(%rip), %rdi     # 0x96de0
callq 0x11bfe
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x49a2a(%rip), %rsi     # 0x741cc
leaq 0x49a36(%rip), %rdx     # 0x741df
callq 0xedfa
addq $0x38, %r14
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x12426
movq %rbp, %r14
subq %r13, %r14
shrq $0x3, %r14
cmpq $0x1, %rbp
adcq $-0x1, %r14
movslq (%rax), %r13
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2a7e8
callq 0xc640
shlq $0x6, %r14
subq %r15, %rbx
sarq $0x3, %rbx
subq 0x28(%rsp), %r12
sarq $0x3, %r12
addq %rbx, %r12
addq %r14, %r12
cmpq %r13, %r12
jbe 0x2a849
movq 0x6c5b2(%rip), %rax     # 0x96dc0
cmpq 0x6c5b3(%rip), %rax     # 0x96dc8
jne 0x2a82a
movq 0x6c5ba(%rip), %rax     # 0x96dd8
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rdi
testq %rdi, %rdi
je 0x2a838
callq 0xc640
leaq 0x6c551(%rip), %rdi     # 0x96d90
callq 0x2ae74
jmp 0x2a74e
leaq 0x6c4d0(%rip), %r14     # 0x96d20
movq (%r14), %rdi
xorl %esi, %esi
callq 0x6d05d
testq %rax, %rax
je 0x2a929
movq %rax, %rbx
leaq 0x6c3bb(%rip), %r13     # 0x96c28
leaq 0x49981(%rip), %r12     # 0x741f5
movq 0x18(%rsp), %r15
cmpl $0x0, 0x278(%rbx)
je 0x2a912
movq 0x290(%rbx), %rax
movq 0x20(%rsp), %rcx
movl (%rcx), %ebp
cmpl %ebp, (%rax)
jne 0x2a912
movq (%r13), %rsi
movq %r15, %rdi
callq 0xc950
movsbl %bpl, %ecx
movq 0x50(%rsp), %r9
testl %eax, %eax
je 0x2a8d1
movq (%rsp), %r10
addq $0x40, %r10
movq %rbx, %rdi
movl $0x1, %esi
movq %r12, %rdx
movq %r15, %r8
xorl %eax, %eax
pushq %r10
pushq 0x18(%rsp)
jmp 0x2a909
movq 0x8(%rsp), %rax
movq 0x268(%rax), %r10
movq 0x270(%rax), %rax
addq $-0x4, %rax
addq $0x4, %r10
subq $0x8, %rsp
movq %rbx, %rdi
movl $0x1, %esi
leaq 0x498e1(%rip), %rdx     # 0x741e0
movq %r9, %r8
movq %rax, %r9
xorl %eax, %eax
pushq %r10
callq 0x6a321
addq $0x10, %rsp
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x6d05d
movq %rax, %rbx
testq %rax, %rax
jne 0x2a879
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2a94f
callq 0xc640
movq %rbx, %rdi
callq 0xc760