// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/service.cc
// Function: service_record::stop_dependents(bool, bool)
bool service_record::stop_dependents(bool for_restart, bool restart_deps) noexcept
{
    // We are in either STARTED or STARTING states.
    bool all_deps_stopped = true;
    for (auto dept : dependents) {
        if (dept->is_hard()) {
            service_record *dep_from = dept->get_from();

            if (!dep_from->is_fundamentally_stopped()) {
                // Note we check *first* since if the dependent service is not stopped,
                // 1. We will issue a stop to it shortly and
                // 2. It will notify us when stopped, at which point the stop_check_dependents()
                //    check is run anyway.
                all_deps_stopped = false;
            }

            if (force_stop) {
                // If this service is to be forcefully stopped, dependents must also be.
                if (desired_state == service_state_t::STOPPED) {
                    // If our target state was forced to STOPPED, this is a failure
                    dep_from->stop_reason = stopped_reason_t::DEPFAILED;
                    dep_from->unrecoverable_stop();
                }
                else {
                    dep_from->forced_stop();
                }
            }

            if (dep_from->get_state() != service_state_t::STOPPED) {
                if (desired_state == service_state_t::STOPPED) {
                    if (dep_from->desired_state != service_state_t::STOPPED) {
                        // if we don't want to restart, don't restart dependent
                        dep_from->desired_state = service_state_t::STOPPED;
                        if (dep_from->start_explicit) {
                            dep_from->start_explicit = false;
                            dep_from->release(true);
                        }
                        dep_from->prop_stop = true;
                        services->add_prop_queue(dep_from);
                    }
                }
                else if (restart_deps && dep_from->get_state() != service_state_t::STOPPING) {
                    // restart dependent and propagate restart to all their hard dependents.
                    dep_from->stop_reason = stopped_reason_t::DEPRESTART;
                    dep_from->in_user_restart = true;
                    dep_from->prop_stop = true;
                    services->add_prop_queue(dep_from);
                }
            }
        }
        // Note that soft dependencies are retained if restarting, but otherwise
        // they are broken.
        else if (!for_restart) {
            if (dept->waiting_on) {
                // Note, milestone which is still waiting is considered a hard dependency and
                // is handled above. This is therefore a true soft dependency, and we can just
                // break the dependency link.
                dept->waiting_on = false;
                dept->get_from()->dependency_started();
            }
            if (dept->holding_acq) {
                dept->holding_acq = false;
                release(false);
            }
        }
    }

    return all_deps_stopped;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0x130(%rdi), %r13
movq 0x130(%rdi), %rbx
cmpq %r13, %rbx
je 0x23a4a
movl %esi, %ebp
movq %rdi, %r14
movb $0x1, %r15b
xorb $0x1, %dl
movl %edx, 0x4(%rsp)
movq 0x10(%rbx), %r12
movl 0x14(%r12), %eax
testl %eax, %eax
je 0x238f7
cmpl $0x3, %eax
jne 0x23984
cmpb $0x1, 0x10(%r12)
jne 0x23984
movq (%r12), %r12
movzbl 0x2c(%r12), %eax
testl %eax, %eax
je 0x23919
cmpl $0x1, %eax
jne 0x23916
movl 0x10c(%r12), %eax
testb $0x10, %al
jne 0x23919
xorl %r15d, %r15d
cmpb $0x1, 0x190(%r14)
jne 0x23944
cmpb $0x0, 0x2d(%r14)
jne 0x2393c
movl $0x2, 0x1c4(%r12)
movb $0x0, 0x2d(%r12)
movq %r12, %rdi
callq 0x2376c
movb 0x2c(%r12), %al
testb %al, %al
je 0x23a3c
cmpb $0x0, 0x2d(%r14)
je 0x239c2
cmpb $0x3, %al
sete %al
orb 0x4(%rsp), %al
jne 0x23a3c
movl $0x1, 0x1c4(%r12)
orl $0x42000, 0x10c(%r12) # imm = 0x42000
jmp 0x23a0d
testb %bpl, %bpl
jne 0x23a3c
cmpb $0x1, 0x10(%r12)
jne 0x239a4
movb $0x0, 0x10(%r12)
movq (%r12), %rdi
callq 0x229e4
cmpb $0x1, 0x11(%r12)
jne 0x23a3c
movb $0x0, 0x11(%r12)
movq %r14, %rdi
xorl %esi, %esi
callq 0x22a24
jmp 0x23a3c
cmpb $0x0, 0x2d(%r12)
je 0x23a3c
movb $0x0, 0x2d(%r12)
movl 0x10c(%r12), %eax
btl $0x8, %eax
jae 0x23a00
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
movl %eax, 0x10c(%r12)
movq %r12, %rdi
movl $0x1, %esi
callq 0x22a24
movl 0x10c(%r12), %eax
orl $0x2000, %eax           # imm = 0x2000
movl %eax, 0x10c(%r12)
movq 0x148(%r14), %rax
cmpq $0x0, 0x1f8(%r12)
setne %dl
movq 0x38(%rax), %rcx
cmpq %r12, %rcx
sete %sil
orb %dl, %sil
jne 0x23a3c
movq %rcx, 0x1f8(%r12)
movq %r12, 0x38(%rax)
movq (%rbx), %rbx
cmpq %r13, %rbx
jne 0x238d5
jmp 0x23a4d
movb $0x1, %r15b
andb $0x1, %r15b
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop