// File: /workspace/github_c_makefile_star2_O3/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 0x6aa49(%rip), %rax     # 0x94da0
cmpq 0x6aa4a(%rip), %rax     # 0x94da8
je 0x2a36e
movq %r15, -0x8(%rax)
addq $-0x8, 0x6aa34(%rip)    # 0x94da0
jmp 0x2a37d
leaq 0x6aa1b(%rip), %rdi     # 0x94d90
movq %rsp, %rsi
callq 0x2ac10
movq %rbp, 0x18(%rsp)
movq 0x6aa4f(%rip), %rbp     # 0x94dd8
movq 0x6aa28(%rip), %r13     # 0x94db8
movq 0x6aa29(%rip), %rbx     # 0x94dc0
movq 0x6aa2a(%rip), %r15     # 0x94dc8
movq 0x6aa0b(%rip), %r12     # 0x94db0
movq 0x6a9f4(%rip), %rax     # 0x94da0
movq %rax, 0x28(%rsp)
leaq 0x6aa28(%rip), %rdi     # 0x94de0
callq 0x11bec
movq %rax, %r14
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0x47de6(%rip), %rsi     # 0x721bc
leaq 0x47df2(%rip), %rdx     # 0x721cf
callq 0xedf0
addq $0x38, %r14
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
callq 0x12416
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 0x2a41c
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 0x2a478
movq 0x6a97e(%rip), %rax     # 0x94dc0
cmpq 0x6a97f(%rip), %rax     # 0x94dc8
jne 0x2a45e
movq 0x6a986(%rip), %rax     # 0x94dd8
movq -0x8(%rax), %rax
movl $0x200, %ecx            # imm = 0x200
addq %rcx, %rax
movq -0x8(%rax), %rdi
callq 0xc640
leaq 0x6a922(%rip), %rdi     # 0x94d90
callq 0x2aa16
jmp 0x2a382
leaq 0x6a8a1(%rip), %r14     # 0x94d20
movq (%r14), %rdi
xorl %esi, %esi
callq 0x6b4d1
testq %rax, %rax
je 0x2a558
movq %rax, %rbx
leaq 0x6a78c(%rip), %r13     # 0x94c28
leaq 0x47d42(%rip), %r12     # 0x721e5
movq 0x18(%rsp), %r15
cmpl $0x0, 0x278(%rbx)
je 0x2a541
movq 0x290(%rbx), %rax
movl (%rax), %ebp
movq 0x20(%rsp), %rax
cmpl (%rax), %ebp
jne 0x2a541
movq (%r13), %rsi
movq %r15, %rdi
callq 0xc950
movsbl %bpl, %ecx
movq 0x50(%rsp), %r9
testl %eax, %eax
je 0x2a500
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 0x2a538
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 0x47ca2(%rip), %rdx     # 0x721d0
movq %r9, %r8
movq %rax, %r9
xorl %eax, %eax
pushq %r10
callq 0x6877b
addq $0x10, %rsp
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x6b4d1
movq %rax, %rbx
testq %rax, %rax
jne 0x2a4a8
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 0x2a57e
callq 0xc640
movq %rbx, %rdi
callq 0xc760