// File: /workspace/github_cpp_makefile_star2_O3/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)
movl 0x10c(%rdi), %eax
testb $0x20, %al
je 0x23395
movq 0x1e8(%rbx), %rcx
testq %rcx, %rcx
je 0x2338c
movq 0x148(%rbx), %rdx
leaq 0x1e8(%rbx), %rax
cmpq %rbx, 0x30(%rdx)
jne 0x2336b
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 %rcx, 0x1e8(%rdx)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movl 0x10c(%rbx), %eax
andl $-0x21, %eax
movl %eax, 0x10c(%rbx)
btl $0x8, %eax
jae 0x233b0
andl $0xfffffeff, %eax       # imm = 0xFFFFFEFF
movl %eax, 0x10c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22a24
leaq 0x130(%rbx), %r15
movq 0x130(%rbx), %r12
cmpq %r15, %r12
je 0x23460
movl $0x36, %r13d
movq 0x10(%r12), %rax
movl 0x14(%rax), %ecx
cmpl $0x5, %ecx
ja 0x2343a
btl %ecx, %r13d
jae 0x233f4
cmpb $0x1, 0x10(%rax)
jne 0x2343a
movb $0x0, 0x10(%rax)
movq (%rax), %rdi
callq 0x229e4
jmp 0x2343a
movq (%rax), %rax
cmpb $0x1, 0x2c(%rax)
jne 0x2343a
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 0x2343a
movq %rdx, 0x1f8(%rcx)
movq %rcx, 0x38(%rax)
movq 0x10(%r12), %rax
cmpb $0x1, 0x11(%rax)
jne 0x23453
movb $0x0, 0x11(%rax)
movq %rbx, %rdi
xorl %esi, %esi
callq 0x22a24
movq (%r12), %r12
cmpq %r15, %r12
jne 0x233cd
orb $-0x80, 0x10d(%rbx)
movq 0x8(%rbx), %rdi
movzbl %r14b, %esi
callq 0x2e6af
movq 0x160(%rbx), %r14
testq %r14, %r14
je 0x23496
movq 0x8(%r14), %rdi
movq (%rdi), %rax
movq %rbx, %rsi
movl $0x2, %edx
callq *(%rax)
movq (%r14), %r14
jmp 0x2347b
andb $-0x5, 0x10c(%rbx)
testb %bpl, %bpl
je 0x234b8
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22792
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop