// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_reload_service()
bool control_conn_t::process_reload_service()
{
    using std::string;

    constexpr int pkt_size = 1 + sizeof(handle_t);

    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }

    // 1 byte: packet type
    // 4 bytes: service handle

    handle_t handle;
    rbuf.extract((char *) &handle, 1, sizeof(handle));

    service_record *service = find_service_for_key(handle);
    if (service == nullptr) {
        // Service handle is bad
        char badreq_rep[] = { (char)cp_rply::BADREQ };
        if (! queue_packet(badreq_rep, 1)) return false;
        bad_conn_close = true;
        return true;
    }

    if (!service->has_lone_ref(false)) {
        // Cannot unload: has other references
        char nak_rep[] = { (char)cp_rply::NAK };
        if (! queue_packet(nak_rep, 1)) return false;
    }
    else {
        try {
            // drop handle
            key_service_map.erase(handle);
            service_key_map.erase(service);

            // reload
            service->remove_listener(this);
            services->reload_service(service);
            services->process_queues();

            // send ack
            char ack_buf[] = { (char) cp_rply::ACK };
            if (! queue_packet(ack_buf, 1)) return false;
        }
        catch (service_load_exc &slexc) {
            log(loglevel_t::ERROR, "Could not reload service ", slexc.service_name, ": ",
                    slexc.exc_description);
            char nak_rep[] = { (char)cp_rply::NAK };
            if (! queue_packet(nak_rep, 1)) return false;
        }
    }

    // Clear the packet from the buffer
    rbuf.consume(pkt_size);
    chklen = 0;
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x4, 0x484(%rdi)
ja 0x28d07
movl $0x5, 0x7c(%rbx)
jmp 0x28e63
leaq 0x80(%rbx), %r14
movl 0x480(%rbx), %r15d
leal 0x1(%r15), %eax
addl $0xfffffc01, %r15d      # imm = 0xFFFFFC01
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3fd(%r15), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x28d70
movl $0x400, %r12d           # imm = 0x400
subl %r15d, %r12d
movl %r15d, %esi
addq %r14, %rsi
movq %rsp, %r13
movq %r13, %rdi
movq %r12, %rdx
callq 0x84d0
leaq (%rsp,%r12), %rdi
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %r14, %rsi
movq %r15, %rdx
callq 0x84d0
movl (%r13), %esi
jmp 0x28d7a
movl %r15d, %eax
movl (%r14,%rax), %esi
movl %esi, (%rsp)
movq %rbx, %rdi
callq 0x2b906
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x28da6
movq 0x160(%rax), %rax
cmpq $0x0, (%rax)
je 0x28dcc
leaq 0x6(%rsp), %rsi
movb $0x33, (%rsi)
jmp 0x28e27
leaq 0x7(%rsp), %rsi
movb $0x34, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x28036
testb %al, %al
je 0x28e65
movb $0x1, 0x78(%rbx)
jmp 0x28e65
leaq 0x4c0(%rbx), %r14
movq %rsp, %rsi
movq %r14, %rdi
callq 0x2d098
movq %r14, %rdi
movq %rax, %rsi
callq 0x2d116
leaq 0x488(%rbx), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2cf84
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x2b8e6
movq 0x70(%rbx), %rdi
movq 0x8(%rsp), %rsi
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x70(%rbx), %rdi
callq 0xd37e
leaq 0x5(%rsp), %rsi
movb $0x32, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x28036
testb %al, %al
je 0x28e89
movl 0x480(%rbx), %eax
leal 0x5(%rax), %ecx
addl $0xfffffc05, %eax       # imm = 0xFFFFFC05
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x480(%rbx)
addl $-0x5, 0x484(%rbx)
movl $0x0, 0x7c(%rbx)
movb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rdi
cmpl $0x1, %edx
jne 0x28e8d
movl %edx, %esi
movq %rbx, %rdx
callq 0x8ebb
testb $0x1, %al
jne 0x28e38
xorl %eax, %eax
jmp 0x28e65
callq 0x8ab0