// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::service_event(service_record*, service_event_t)
void control_conn_t::service_event(service_record *service, service_event_t event) noexcept
{
    // For each service handle corresponding to the event, send an information packet.
    auto range = service_key_map.equal_range(service);
    auto &i = range.first;
    auto &end = range.second;
    try {
        while (i != end) {
            uint32_t key = i->second;
            std::vector<char> pkt;

            // There are two types of service event packet: v5+, and the original. For backwards
            // compatibility, we send both. The new packet is sent first since this simplifies
            // things for the client (eg if waiting for an event, the client will receive the
            // packet with the most information first).

            // packet type (byte) + packet length (byte) + event type (byte) + key + status buffer
            constexpr int pktsize5 = 3 + sizeof(key) + STATUS_BUFFER5_SIZE;
            pkt.reserve(pktsize5);
            pkt.push_back((char)cp_info::SERVICEEVENT5);
            pkt.push_back(pktsize5);
            char *p = (char *)&key;
            for (unsigned j = 0; j < sizeof(key); j++) {
                pkt.push_back(*p++);
            }
            pkt.push_back(static_cast<char>(event));
            pkt.resize(pktsize5);
            fill_status_buffer5(pkt.data() + 3 + sizeof(key), service);
            queue_packet(std::move(pkt));

            pkt.clear();

            constexpr int pktsize = 3 + sizeof(key) + STATUS_BUFFER_SIZE;
            pkt.reserve(pktsize);
            pkt.push_back((char)cp_info::SERVICEEVENT);
            pkt.push_back(pktsize);
            p = (char *)&key;
            for (unsigned j = 0; j < sizeof(key); j++) {
                pkt.push_back(*p++);
            }
            pkt.push_back(static_cast<char>(event));
            pkt.resize(pktsize);
            fill_status_buffer(pkt.data() + 3 + sizeof(key), service);
            queue_packet(std::move(pkt));

            ++i;
        }
    }
    catch (std::bad_alloc &exc) {
        do_oom_close();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x40(%rsp), %rax
movq %rsi, (%rax)
addq $0x488, %rdi            # imm = 0x488
movq %rax, %rsi
callq 0x2ce4a
movq %rdx, 0x38(%rsp)
movq %rax, %r14
cmpq 0x38(%rsp), %rax
je 0x2b326
leaq 0x10(%rsp), %r12
leaq 0xf(%rsp), %r13
movl 0x10(%r14), %eax
movl %eax, 0x34(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x15, %esi
movq %r12, %rdi
callq 0x2b854
movb $0x65, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
movb $0x15, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
xorl %r15d, %r15d
leaq (%rsp,%r15), %rdx
addq $0x34, %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2b209
movb (%rdx), %al
movb %al, (%rsi)
incq 0x18(%rsp)
jmp 0x2b211
movq %r12, %rdi
callq 0x2cd1c
incq %r15
cmpl $0x4, %r15d
jne 0x2b1ea
movb %bpl, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
movl $0x15, %esi
movq %r12, %rdi
callq 0x1c190
movq 0x10(%rsp), %rdi
addq $0x7, %rdi
movq 0x40(%rsp), %rsi
callq 0x2b0bd
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2acb2
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x2b266
movq %rax, 0x18(%rsp)
movl $0x11, %esi
movq %r12, %rdi
callq 0x2b854
movb $0x64, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
movb $0x11, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
xorl %r15d, %r15d
leaq (%rsp,%r15), %rdx
addq $0x34, %rdx
movq 0x18(%rsp), %rsi
cmpq 0x20(%rsp), %rsi
je 0x2b2b5
movb (%rdx), %al
movb %al, (%rsi)
incq 0x18(%rsp)
jmp 0x2b2bd
movq %r12, %rdi
callq 0x2cd1c
incq %r15
cmpl $0x4, %r15d
jne 0x2b296
movb %bpl, 0xf(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x2cbf6
movl $0x11, %esi
movq %r12, %rdi
callq 0x1c190
movq 0x10(%rsp), %rdi
addq $0x7, %rdi
movq 0x40(%rsp), %rsi
callq 0x2b017
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2acb2
movq (%r14), %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2b31b
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
cmpq 0x38(%rsp), %r14
jne 0x2b1a1
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
jmp 0x2b349
movq %rdx, %r14
movq %rax, %r15
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2b366
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movq %r15, %rdi
cmpl $0x2, %r14d
jne 0x2b384
callq 0x8210
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a50
jmp 0x2b326
movq %rax, %rdi
callq 0xb74e
nop