// File: /workspace/github_cpp_makefile_star2_O2/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 $0x38, %rsp
movl %edx, %ebp
movq %rdi, %rbx
leaq 0x28(%rsp), %rax
movq %rsi, (%rax)
addq $0x488, %rdi            # imm = 0x488
movq %rax, %rsi
callq 0x276f0
movq %rdx, 0x30(%rsp)
movq %rax, %r14
leaq 0x10(%rsp), %r12
leaq 0xb(%rsp), %r13
cmpq 0x30(%rsp), %r14
je 0x25987
movl 0x10(%r14), %eax
movl %eax, 0xc(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
andq $0x0, 0x20(%rsp)
movq %r12, %rdi
pushq $0x15
popq %rsi
callq 0x25f74
movb $0x65, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
movb $0x15, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
xorl %r15d, %r15d
cmpl $0x4, %r15d
je 0x2586e
leaq (%rsp,%r15), %rsi
addq $0xc, %rsi
movq %r12, %rdi
callq 0x25ffe
incq %r15
jmp 0x25853
movb %bpl, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
movq %r12, %rdi
pushq $0x15
popq %rsi
callq 0x17940
movq 0x10(%rsp), %rdi
addq $0x7, %rdi
movq 0x28(%rsp), %rsi
callq 0x2572b
movq %rbx, %rdi
movq %r12, %rsi
callq 0x253ac
movq 0x10(%rsp), %rax
cmpq %rax, 0x18(%rsp)
je 0x258b8
movq %rax, 0x18(%rsp)
movq %r12, %rdi
pushq $0x11
popq %rsi
callq 0x25f74
movb $0x64, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
movb $0x11, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
xorl %r15d, %r15d
cmpl $0x4, %r15d
je 0x25901
leaq (%rsp,%r15), %rsi
addq $0xc, %rsi
movq %r12, %rdi
callq 0x25ffe
incq %r15
jmp 0x258e6
movb %bpl, 0xb(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x274c6
movq %r12, %rdi
pushq $0x11
popq %rsi
callq 0x17940
movq 0x10(%rsp), %rdi
addq $0x7, %rdi
movq 0x28(%rsp), %rsi
callq 0x25686
movq %rbx, %rdi
movq %r12, %rsi
callq 0x253ac
movq (%r14), %r14
movq %r12, %rdi
callq 0xc3e8
jmp 0x25804
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
jmp 0x2595e
movq %rdx, %r14
movq %rax, %r15
leaq 0x10(%rsp), %rdi
callq 0xc3e8
movq %r15, %rdi
cmpl $0x2, %r14d
jne 0x25999
callq 0x8200
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a40
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0xaebb