// File: davmac314[P]dinit/src/service.cc
// Function: service_record::do_start()
void service_record::do_start() noexcept
{
    bool was_active = service_state != service_state_t::STOPPED;

    desired_state = service_state_t::STARTED;

    if (pinned_stopped) {
        if (!was_active) {
            failed_to_start(false, false);
        }
        return;
    }

    // re-attach any soft dependents, now that we are starting again
    if (!was_active) {
        for (auto dept : dependents) {
            if (!dept->is_hard()) {
                service_state_t dept_state = dept->get_from()->service_state;
                if (!dept->holding_acq
                        && (dept_state == service_state_t::STARTED || dept_state == service_state_t::STARTING)) {
                    dept->holding_acq = true;
                    ++required_by;
                }
            }
        }
    }

    if (was_active) {
        // We're already starting/started, or we are stopping and need to wait for
        // that the complete.
        if (service_state != service_state_t::STOPPING) {
            return;
        }

        if (! can_interrupt_stop()) {
            return;
        }

        // We're STOPPING, and that can be interrupted. Our dependencies might be STOPPING,
        // but if so they are waiting (for us), so they too can be instantly returned to
        // STARTING state.
        notify_listeners(service_event_t::STOPCANCELLED);
    }
    else { // !was_active
        services->service_active(this);
        prop_require = !prop_release;
        prop_release = false;
        if (prop_require) {
            services->add_prop_queue(this);
        }
    }

    initiate_start();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpb $0x0, 0x2c(%rax)
setne %cl
andb $0x1, %cl
movb %cl, -0x9(%rbp)
movb $0x2, 0x2d(%rax)
movl 0x10c(%rax), %eax
shrl %eax
andl $0x1, %eax
testl $0x1, %eax
je 0x4c88f
testb $0x1, -0x9(%rbp)
jne 0x4c88a
movq -0x40(%rbp), %rdi
xorl %edx, %edx
movl %edx, %esi
callq 0x4cf90
jmp 0x4ca09
testb $0x1, -0x9(%rbp)
jne 0x4c94f
movq -0x40(%rbp), %rax
addq $0x130, %rax            # imm = 0x130
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x304d0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x30530
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x30500
testb $0x1, %al
jne 0x4c8d4
jmp 0x4c94d
leaq -0x20(%rbp), %rdi
callq 0x30590
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x4e1f0
movb %al, -0x41(%rbp)
jmp 0x4c8f2
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x4c93d
jmp 0x4c8fb
movq -0x30(%rbp), %rdi
callq 0x30420
movb 0x2c(%rax), %al
movb %al, -0x31(%rbp)
movq -0x30(%rbp), %rax
testb $0x1, 0x11(%rax)
jne 0x4c93b
cmpb $0x2, -0x31(%rbp)
je 0x4c920
cmpb $0x1, -0x31(%rbp)
jne 0x4c93b
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movb $0x1, 0x11(%rcx)
movl 0x110(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x110(%rax)
jmp 0x4c93d
jmp 0x4c93f
leaq -0x20(%rbp), %rdi
callq 0x306a0
jmp 0x4c8c1
jmp 0x4c94f
testb $0x1, -0x9(%rbp)
je 0x4c986
movq -0x40(%rbp), %rax
cmpb $0x3, 0x2c(%rax)
je 0x4c964
jmp 0x4ca09
movq -0x40(%rbp), %rdi
callq 0x4e420
testb $0x1, %al
jne 0x4c976
jmp 0x4ca09
movq -0x40(%rbp), %rdi
movl $0x4, %esi
callq 0x4e2a0
jmp 0x4ca00
movq -0x40(%rbp), %rsi
movq 0x148(%rsi), %rdi
callq 0x4d490
movq -0x40(%rbp), %rax
movl 0x10c(%rax), %ecx
shrl $0xa, %ecx
andl $0x1, %ecx
xorb $-0x1, %cl
andb $0x1, %cl
movzbl %cl, %edx
movl 0x10c(%rax), %ecx
shll $0x9, %edx
andl $0xfffffdff, %ecx       # imm = 0xFFFFFDFF
orl %edx, %ecx
movl %ecx, 0x10c(%rax)
movl 0x10c(%rax), %ecx
andl $0xfffffbff, %ecx       # imm = 0xFFFFFBFF
orl $0x0, %ecx
movl %ecx, 0x10c(%rax)
movl 0x10c(%rax), %eax
shrl $0x9, %eax
andl $0x1, %eax
testl $0x1, %eax
je 0x4c9fe
movq -0x40(%rbp), %rsi
movq 0x148(%rsi), %rdi
callq 0x4e320
jmp 0x4ca00
movq -0x40(%rbp), %rdi
callq 0x4c1e0
addq $0x50, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
nopw (%rax,%rax)