// File: /workspace/github_cpp_makefile_star2_O1/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 0xfa1c
testq %rax, %rax
je 0xac6f
movq %rax, %r15
movl $0x40, %edi
callq 0xee48
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 0xcad0(%rip), %rsi      # 0x176c8
movq %r12, %rdi
callq 0xc41e
movq (%r14), %rsi
movl 0x8(%r14), %edx
movq %r12, %rdi
callq 0xc0a8
leaq 0xcae2(%rip), %rsi      # 0x176f8
movq %r12, %rdi
callq 0xc41e
cmpl $0x0, 0xd8(%rbx)
je 0xacad
leaq 0xcaec(%rip), %rsi      # 0x1771e
movq %r12, %rdi
callq 0xc41e
movslq 0xd8(%rbx), %rsi
movq %r12, %rdi
callq 0xc342
leaq 0xcac9(%rip), %rsi      # 0x17719
movq %r12, %rdi
callq 0xc41e
movq 0xd0(%rbx), %rsi
movl 0xd8(%rbx), %edx
movq %r12, %rdi
callq 0xc0a8
jmp 0xacbc
movq 0x48(%rbx), %rax
testb $0x4, 0x20(%rax)
je 0xaf02
callq 0x16531
testq %rax, %rax
je 0xae61
movq %rax, %r15
movq %rax, %rdi
callq 0x8130
movq 0x13333(%rip), %rdi     # 0x1dfd0
movq %r15, %rsi
movq %rax, %rdx
callq 0x8350
jmp 0xae7f
leaq 0xca54(%rip), %rsi      # 0x17708
movq %r12, %rdi
callq 0xc41e
leaq 0x58(%r15), %rdi
movq %rdi, -0x38(%rbp)
callq 0x83f0
testl %eax, %eax
jne 0xaf38
movq 0x80(%r15), %r14
testq %r14, %r14
je 0xae0a
movl $0x6, %r15d
movq 0x18(%r14), %r13
cmpl $0x1, 0xcc(%r13)
jne 0xad7a
leaq 0x50(%r13), %r12
movq %r12, %rdi
callq 0x83f0
testl %eax, %eax
jne 0xaf31
cmpl $0x1, 0xcc(%r13)
jne 0xad72
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 0xadc9
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x1c0(%r13)
jmp 0xadd9
movq %r12, %rdi
callq 0x8240
cmpb $0x1, 0xf1(%r13)
jne 0xadfd
movq -0x30(%rbp), %rax
lock
incl 0x3c(%rax)
movq 0x1c0(%r13), %rax
movq 0x1d0(%r13), %rcx
addq $-0x8, %rcx
cmpq %rcx, %rax
je 0xadb4
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
addq $0x8, 0x1c0(%r13)
jmp 0xadfd
addq $0x190, %r13            # imm = 0x190
movq %r13, %rdi
leaq -0x30(%rbp), %rsi
callq 0xcad2
jmp 0xadfd
leaq 0x190(%r13), %rdi
leaq -0x30(%rbp), %rsi
callq 0xcad2
movl (%r13), %eax
testb $0x2, %al
jne 0xadfd
orl $0x2, %eax
movl %eax, (%r13)
movq 0x30(%r13), %rdi
addq $0x60, %rdi
movq %r13, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0xc7c6
movq 0x10(%r14), %r14
testq %r14, %r14
jne 0xace7
addq $0x18, %rbx
leaq 0xc424(%rip), %rsi      # 0x17239
movq %rbx, %rdi
callq 0x9ee0
movq %rbx, %rdi
movl $0x1, %esi
callq 0x9f54
movq -0x30(%rbp), %rax
lock
decl 0x3c(%rax)
jne 0xae53
movq -0x30(%rbp), %rbx
testq %rbx, %rbx
je 0xae53
leaq 0x28(%rbx), %rdi
callq 0xc536
movl $0x40, %esi
movq %rbx, %rdi
callq 0x8320
movq -0x38(%rbp), %rdi
callq 0x8240
jmp 0xaf22
movq 0x13168(%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 0x1314a(%rip), %r15     # 0x1dfd0
leaq 0xc81e(%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 0xc468
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 0xaf02
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8320
addq $0x18, %rbx
leaq 0xc7ad(%rip), %rsi      # 0x176ba
movq %rbx, %rdi
callq 0x9ee0
movq %rbx, %rdi
movl $0xffff80a7, %esi       # imm = 0xFFFF80A7
callq 0x9f54
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 0xaf6d
movq -0x48(%rbp), %rsi
incq %rsi
callq 0x8320
jmp 0xaf6d
jmp 0xaf61
jmp 0xaf61
movq %rax, %rbx
movq -0x38(%rbp), %rdi
callq 0x8240
movq %rbx, %rdi
callq 0x84a0
nop