// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/service.cc
// Function: service_record::failed_to_start(bool, bool)
void service_record::failed_to_start(bool depfailed, bool immediate_stop) noexcept
{
    desired_state = service_state_t::STOPPED;

    if (waiting_for_console) {
        services->unqueue_console(this);
        waiting_for_console = false;
    }

    if (start_explicit) {
        start_explicit = false;
        release(false);
    }

    // Cancel start of dependents:
    for (auto & dept : dependents) {
        switch (dept->dep_type) {
        case dependency_type::REGULAR:
        case dependency_type::MILESTONE:
            // If REGULAR and STARTED, we can't have failed to start i.e. we must be started, so
            // we don't worry about that case. If MILESTONE and started the dependency is already
            // satisfied so again we don't need to do anything.
            if (dept->get_from()->service_state == service_state_t::STARTING) {
                dept->get_from()->prop_failure = true;
                services->add_prop_queue(dept->get_from());
            }
            break;
        case dependency_type::WAITS_FOR:
        case dependency_type::SOFT:
        case dependency_type::BEFORE:
        case dependency_type::AFTER:
            if (dept->waiting_on) {
                dept->waiting_on = false;
                dept->get_from()->dependency_started();
            }
        }

        // Always release now, so that our desired state will be STOPPED before we call
        // stopped() below (if we do so). Otherwise it may decide to restart us.
        if (dept->holding_acq) {
            dept->holding_acq = false;
            release(false);
        }
    }

    start_failed = true;
    log_service_failed(get_name(), depfailed);
    notify_listeners(service_event_t::FAILEDSTART);
    pinned_started = false;

    if (immediate_stop) {
        stopped();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %ebp
movl %esi, %r14d
movq %rdi, %rbx
movb $0x0, 0x2d(%rdi)
testb $0x20, 0x10c(%rdi)
je 0x23095
movq 0x1e8(%rbx), %rcx
testq %rcx, %rcx
je 0x2308e
movq 0x148(%rbx), %rdx
leaq 0x1e8(%rbx), %rax
cmpq %rbx, 0x30(%rdx)
jne 0x23065
xorl %esi, %esi
cmpq %rbx, %rcx
cmovneq %rcx, %rsi
movq %rsi, 0x30(%rdx)
movq 0x1e8(%rbx), %rcx
movq 0x1f0(%rbx), %rdx
movq %rdx, 0x1f0(%rcx)
movq 0x1f0(%rbx), %rdx
movq %rcx, 0x1e8(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
andb $-0x21, 0x10c(%rbx)
movl 0x10c(%rbx), %eax
btl $0x8, %eax
jae 0x230b6
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
movl %eax, 0x10c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22740
leaq 0x130(%rbx), %r15
movq 0x130(%rbx), %r12
cmpq %r15, %r12
je 0x23166
movl $0x36, %r13d
movq 0x10(%r12), %rax
movl 0x14(%rax), %ecx
cmpl $0x5, %ecx
ja 0x23140
btl %ecx, %r13d
jae 0x230fa
cmpb $0x1, 0x10(%rax)
jne 0x23140
movb $0x0, 0x10(%rax)
movq (%rax), %rdi
callq 0x22700
jmp 0x23140
movq (%rax), %rax
cmpb $0x1, 0x2c(%rax)
jne 0x23140
orb $0x8, 0x10d(%rax)
movq 0x148(%rbx), %rax
movq 0x10(%r12), %rcx
movq (%rcx), %rcx
cmpq $0x0, 0x1f8(%rcx)
setne %sil
movq 0x38(%rax), %rdx
cmpq %rcx, %rdx
sete %dil
orb %sil, %dil
jne 0x23140
movq %rdx, 0x1f8(%rcx)
movq %rcx, 0x38(%rax)
movq 0x10(%r12), %rax
cmpb $0x1, 0x11(%rax)
jne 0x23159
movb $0x0, 0x11(%rax)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22740
movq (%r12), %r12
cmpq %r15, %r12
jne 0x230d3
orb $-0x80, 0x10d(%rbx)
movq 0x8(%rbx), %rdi
movzbl %r14b, %esi
callq 0x2e8c2
movq 0x160(%rbx), %r14
testq %r14, %r14
je 0x2319c
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl $0x2, %edx
callq *(%rax)
movq (%r14), %r14
jmp 0x23181
andb $-0x5, 0x10c(%rbx)
testb %bpl, %bpl
je 0x231be
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x224b2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop