// File: /workspace/github_c_makefile_star2_O0/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:
subq $0xd8, %rsp
movq %rdi, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq 0x290(%rax), %rax
movq %rax, 0xc8(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0xd980
movl $0x448, %edi            # imm = 0x448
callq 0xd250
movq %rax, %rdi
movq %rdi, 0x58(%rsp)
xorl %esi, %esi
movl $0x448, %edx            # imm = 0x448
callq 0xd430
movq 0x58(%rsp), %rdi
callq 0x4e360
movq 0x58(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
movq 0xc8(%rsp), %rsi
addq $0x4, %rsi
callq 0xd580
movq 0xd0(%rsp), %rax
movq 0x270(%rax), %rax
subq $0x4, %rax
movl %eax, 0xac(%rsp)
cmpl $0x3ff, 0xac(%rsp) # imm = 0x3FF
jle 0x4da53
movl $0x3ff, %eax            # imm = 0x3FF
movl %eax, 0x54(%rsp)
jmp 0x4da5e
movl 0xac(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0xac(%rsp)
movq 0xb0(%rsp), %rdi
addq $0x40, %rdi
movq 0xd0(%rsp), %rax
movq 0x268(%rax), %rsi
addq $0x4, %rsi
movslq 0xac(%rsp), %rdx
callq 0xd240
movq 0xb0(%rsp), %rax
movslq 0xac(%rsp), %rcx
movb $0x0, 0x40(%rax,%rcx)
movq 0xb8(%rsp), %rcx
movq 0xb0(%rsp), %rax
movq %rcx, 0x440(%rax)
leaq 0xa16c0(%rip), %rdi     # 0xef188
leaq 0xb0(%rsp), %rsi
callq 0x4e3b0
leaq 0xa16ac(%rip), %rdi     # 0xef188
callq 0x4e410
movq %rax, 0x38(%rsp)
leaq 0xa16eb(%rip), %rdi     # 0xef1d8
callq 0x146c0
movq %rax, 0x40(%rsp)
leaq 0x87(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0xdc30
movq 0x48(%rsp), %rdx
leaq 0x72677(%rip), %rsi     # 0xc018c
leaq 0x88(%rsp), %rdi
callq 0xdad0
jmp 0x4db24
movq 0x40(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x14720
movl %eax, 0x34(%rsp)
jmp 0x4db3c
movl 0x34(%rsp), %eax
cltq
movq %rax, 0x28(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xdf50
leaq 0x87(%rsp), %rdi
callq 0xdf30
movq 0x28(%rsp), %rcx
movq 0x38(%rsp), %rax
cmpq %rcx, %rax
jbe 0x4dbec
leaq 0xa1611(%rip), %rdi     # 0xef188
callq 0x4e430
movq (%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x4db9e
movq 0x20(%rsp), %rdi
callq 0xd760
leaq 0xa15e3(%rip), %rdi     # 0xef188
callq 0x4e460
jmp 0x4dad5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x4dbda
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xdf50
leaq 0x87(%rsp), %rdi
callq 0xdf30
jmp 0x4dd65
leaq 0xa1525(%rip), %rax     # 0xef118
movq (%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xb4e90
movq %rax, 0xc0(%rsp)
cmpq $0x0, 0xc0(%rsp)
je 0x4dd5d
movq 0xc0(%rsp), %rax
movq 0x290(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0xc0(%rsp), %rax
cmpl $0x0, 0x278(%rax)
je 0x4dc4e
movq 0x60(%rsp), %rax
movl (%rax), %eax
movq 0xc8(%rsp), %rcx
cmpl (%rcx), %eax
je 0x4dc53
jmp 0x4dd39
movq 0xc8(%rsp), %rax
addq $0x4, %rax
movq %rax, 0x18(%rsp)
leaq 0xa13b5(%rip), %rdi     # 0xef020
callq 0xd190
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0xdab0
cmpl $0x0, %eax
jne 0x4dcde
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rax
movl (%rax), %eax
movsbl %al, %ecx
movq 0xb8(%rsp), %r8
movq 0xd0(%rsp), %rax
movq 0x270(%rax), %r9
subq $0x4, %r9
movq 0xd0(%rsp), %rax
movq 0x268(%rax), %rax
addq $0x4, %rax
movl $0x1, %esi
leaq 0x724cf(%rip), %rdx     # 0xc01a0
movq %rax, (%rsp)
movb $0x0, %al
callq 0xb1f80
jmp 0x4dd37
movq 0xc0(%rsp), %rdi
movq 0xc8(%rsp), %rax
movl (%rax), %eax
movsbl %al, %ecx
movq 0xc8(%rsp), %r8
addq $0x4, %r8
movq 0xb8(%rsp), %r9
movl 0xac(%rsp), %r10d
movq 0xb0(%rsp), %rax
addq $0x40, %rax
movl $0x1, %esi
leaq 0x7248e(%rip), %rdx     # 0xc01b5
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0xb1f80
jmp 0x4dd39
leaq 0xa13d8(%rip), %rax     # 0xef118
movq (%rax), %rdi
movq 0xc0(%rsp), %rsi
callq 0xb4e90
movq %rax, 0xc0(%rsp)
jmp 0x4dc07
addq $0xd8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0xd8a0
nop