// File: /workspace/github_cpp_makefile_star2_O1/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 0x2374f
movl %esi, %ebp
movq %rdi, %r15
movb $0x1, %r14b
xorb $0x1, %dl
movl %edx, 0x4(%rsp)
movq 0x10(%rbx), %r12
movl 0x14(%r12), %eax
testl %eax, %eax
je 0x23601
cmpl $0x3, %eax
jne 0x23627
cmpb $0x1, 0x10(%r12)
jne 0x23627
movq (%r12), %r12
movzbl 0x2c(%r12), %eax
testl %eax, %eax
je 0x2366b
cmpl $0x1, %eax
jne 0x23668
movb 0x10c(%r12), %al
shlb $0x3, %al
sarb $0x7, %al
andb %al, %r14b
jmp 0x2366b
testb %bpl, %bpl
jne 0x23741
cmpb $0x1, 0x10(%r12)
jne 0x23647
movb $0x0, 0x10(%r12)
movq (%r12), %rdi
callq 0x22700
cmpb $0x1, 0x11(%r12)
jne 0x23741
movb $0x0, 0x11(%r12)
movq %r15, %rdi
xorl %esi, %esi
callq 0x22740
jmp 0x23741
xorl %r14d, %r14d
cmpb $0x1, 0x190(%r15)
jne 0x23696
cmpb $0x0, 0x2d(%r15)
jne 0x2368e
movl $0x2, 0x1c4(%r12)
movb $0x0, 0x2d(%r12)
movq %r12, %rdi
callq 0x23484
movb 0x2c(%r12), %al
testb %al, %al
je 0x23741
cmpb $0x0, 0x2d(%r15)
je 0x236d3
cmpb $0x3, %al
sete %al
orb 0x4(%rsp), %al
jne 0x23741
movl $0x1, 0x1c4(%r12)
orl $0x42000, 0x10c(%r12) # imm = 0x42000
jmp 0x23712
cmpb $0x0, 0x2d(%r12)
je 0x23741
movb $0x0, 0x2d(%r12)
movl 0x10c(%r12), %eax
btl $0x8, %eax
jae 0x23709
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
movl %eax, 0x10c(%r12)
movq %r12, %rdi
movl $0x1, %esi
callq 0x22740
orb $0x20, 0x10d(%r12)
movq 0x148(%r15), %rax
cmpq $0x0, 0x1f8(%r12)
setne %dl
movq 0x38(%rax), %rcx
cmpq %r12, %rcx
sete %sil
orb %dl, %sil
jne 0x23741
movq %rcx, 0x1f8(%r12)
movq %r12, 0x38(%rax)
movq (%rbx), %rbx
cmpq %r13, %rbx
jne 0x235e7
jmp 0x23752
movb $0x1, %r14b
andb $0x1, %r14b
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq