// File: /workspace/github_cpp_makefile_star2_O3/lega911[P]ijson/src/connect.cpp
// Function: Connect::pub(ISlice&)
void Connect::pub(ISlice &name) {
    QueueLine *ql = server->get_queue(name);
    if(!ql) {
        if(server->log & 4) std::cout << ltime() << "404 no method " << name.as_string() << std::endl;
        this->send.status("404 Not Found")->done(-32601);
        return;
    }

    auto *dm = new DirectMessage();
    dm->link();
    Buffer *data = &dm->data;
    data->add("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nName: ");
    data->add(name);
    data->add("\r\nAsync: true\r\n");
    if(body.size() == 0) {
        data->add("Content-Length: 0\r\n\r\n");
    } else {
        data->add("Content-Length: ");
        data->add_number(body.size());
        data->add("\r\n\r\n");
        data->add(body);
    };

    LOCK _l(ql->workers.lock);
    auto *item = ql->workers.head;
    for(;item;item=item->next) {
        auto *worker = item->conn;

        bool send = false;
        if(worker->status == Status::worker_wait_job) {
            worker->mutex.lock();
            if(worker->status == Status::worker_wait_job) {
                worker->status = Status::busy;
                send = true;
            }
            worker->mutex.unlock();
        };

        if(send) {
            if(worker->worker_mode) worker->status = Status::worker_mode_async;
            else worker->status = Status::net;

            dm->link();
            worker->direct_message.push_back(dm);
            worker->write_mode(true);
        } else if(worker->noid) {
            dm->link();
            worker->direct_message.push_back(dm);
        }
    }
    this->send.status("200 OK")->done(1);
    if(dm->unlink() == 0) delete dm;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x48(%rdi), %rdi
movq (%rsi), %rsi
movl 0x8(%r14), %edx
xorl %ecx, %ecx
callq 0xf926
testq %rax, %rax
je 0xacd1
movq %rax, %r15
movl $0x40, %edi
callq 0xed4c
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movups %xmm0, 0x10(%rax)
movups %xmm0, 0x20(%rax)
movups %xmm0, 0x30(%rax)
movq %rax, -0x30(%rbp)
lock
incl 0x3c(%rax)
movq -0x30(%rbp), %r12
addq $0x28, %r12
leaq 0xca6e(%rip), %rsi      # 0x176c8
movq %r12, %rdi
callq 0xc44c
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq %r12, %rdi
callq 0xc102
leaq 0xca80(%rip), %rsi      # 0x176f8
movq %r12, %rdi
callq 0xc44c
cmpl $0x0, 0xd8(%rbx)
je 0xad0f
leaq 0xca8a(%rip), %rsi      # 0x1771e
movq %r12, %rdi
callq 0xc44c
movslq 0xd8(%rbx), %rsi
movq %r12, %rdi
callq 0xc35e
leaq 0xca67(%rip), %rsi      # 0x17719
movq %r12, %rdi
callq 0xc44c
movq 0xd0(%rbx), %rsi
movl 0xd8(%rbx), %edx
movq %r12, %rdi
callq 0xc102
jmp 0xad1e
movq 0x48(%rbx), %rax
testb $0x4, 0x20(%rax)
je 0xaf64
callq 0x163f5
testq %rax, %rax
je 0xaec3
movq %rax, %r15
movq %rax, %rdi
callq 0x8130
movq 0x132d1(%rip), %rdi     # 0x1dfd0
movq %r15, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xaee1
leaq 0xc9f2(%rip), %rsi      # 0x17708
movq %r12, %rdi
callq 0xc44c
leaq 0x58(%r15), %rdi
movq %rdi, -0x38(%rbp)
callq 0x83f0
testl %eax, %eax
jne 0xaf9a
movq 0x80(%r15), %r14
testq %r14, %r14
je 0xae6c
movl $0x6, %r15d
movq 0x18(%r14), %r13
cmpl $0x1, 0xcc(%r13)
jne 0xaddc
leaq 0x50(%r13), %r12
movq %r12, %rdi
callq 0x83f0
testl %eax, %eax
jne 0xaf93
cmpl $0x1, 0xcc(%r13)
jne 0xadd4
movl $0x5, 0xcc(%r13)
movq %r12, %rdi
callq 0x8240
cmpb $0x0, 0xf3(%r13)
movl $0x0, %eax
cmovnel %r15d, %eax
movl %eax, 0xcc(%r13)
movq -0x30(%rbp), %rax
lock
incl 0x3c(%rax)
movq 0x1c0(%r13), %rax
movq 0x1d0(%r13), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0xae2b
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x1c0(%r13)
jmp 0xae3b
movq %r12, %rdi
callq 0x8240
cmpb $0x1, 0xf1(%r13)
jne 0xae5f
movq -0x30(%rbp), %rax
lock
incl 0x3c(%rax)
movq 0x1c0(%r13), %rax
movq 0x1d0(%r13), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0xae16
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x1c0(%r13)
jmp 0xae5f
addq $0x190, %r13            # imm = 0x190
movq %r13, %rdi
leaq -0x30(%rbp), %rsi
callq 0xcad4
jmp 0xae5f
leaq 0x190(%r13), %rdi
leaq -0x30(%rbp), %rsi
callq 0xcad4
movl (%r13), %eax
testb $0x2, %al
jne 0xae5f
orl $0x2, %eax
movl %eax, (%r13)
movq 0x30(%r13), %rdi
addq $0x60, %rdi
movq %r13, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0xc7ba
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0xad49
addq $0x18, %rbx
leaq 0xc3c2(%rip), %rsi      # 0x17239
movq %rbx, %rdi
callq 0x9ec6
movq %rbx, %rdi
movl $0x1, %esi
callq 0x9f3a
movq -0x30(%rbp), %rax
lock
decl 0x3c(%rax)
jne 0xaeb5
movq -0x30(%rbp), %rbx
testq %rbx, %rbx
je 0xaea8
leaq 0x28(%rbx), %rdi
callq 0xc56a
movl $0x40, %esi
movq %rbx, %rdi
callq 0x8320
movq -0x38(%rbp), %rdi
callq 0x8240
jmp 0xaf84
movq 0x13106(%rip), %rax     # 0x1dfd0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
leaq (%rax,%rcx), %rdi
movl 0x20(%rax,%rcx), %esi
orl $0x1, %esi
callq 0x8470
movq 0x130e8(%rip), %r15     # 0x1dfd0
leaq 0xc7bc(%rip), %rsi      # 0x176ab
movl $0xe, %edx
movq %r15, %rdi
callq 0x8350
leaq -0x58(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xc49c
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r15, %rdi
callq 0x8350
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x82f0
movsbl %al, %esi
movq %r14, %rdi
callq 0x8040
movq %rax, %rdi
callq 0x81f0
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaf64
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8320
addq $0x18, %rbx
leaq 0xc74b(%rip), %rsi      # 0x176ba
movq %rbx, %rdi
callq 0x9ec6
movq %rbx, %rdi
movl $0xffff80a7, %esi       # imm = 0xFFFF80A7
callq 0x9f3a
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x81d0
movl %eax, %edi
callq 0x81d0
movq %rax, %rbx
leaq -0x48(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xafcf
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8320
jmp 0xafcf
jmp 0xafc3
jmp 0xafc3
movq %rax, %rbx
movq -0x38(%rbp), %rdi
callq 0x8240
movq %rbx, %rdi
callq 0x84a0
nop