LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: davmac314[P]dinit/src/includes/proc-service.h
// Function: process_service::~process_service()
~process_service() noexcept
    {
        if (reserved_stop_watch) {
            stop_watcher.unreserve(event_loop);
        }
        if (consumer_for != nullptr) {
            consumer_for->set_log_consumer(nullptr);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x5441d(%rip), %rcx     # 0xa7638
addq $0x10, %rcx
movq %rcx, (%rax)
movb 0x500(%rax), %al
andb $0x1, %al
testb $0x1, %al
je 0x53249
movq -0x10(%rbp), %rdi
addq $0x540, %rdi            # imm = 0x540
leaq 0x55920(%rip), %rsi     # 0xa8b60
callq 0x53780
jmp 0x53247
jmp 0x53249
movq -0x10(%rbp), %rax
cmpq $0x0, 0x5c0(%rax)
je 0x5326f
movq -0x10(%rbp), %rax
movq 0x5c0(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x30760
jmp 0x5326d
jmp 0x5326f
movq -0x10(%rbp), %rdi
addq $0x588, %rdi            # imm = 0x588
callq 0x41f50
movq -0x10(%rbp), %rdi
addq $0x540, %rdi            # imm = 0x540
callq 0x41aa0
movq -0x10(%rbp), %rdi
addq $0x510, %rdi            # imm = 0x510
callq 0x41900
movq -0x10(%rbp), %rdi
callq 0x537b0
addq $0x10, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
nopw %cs:(%rax,%rax)
// File: davmac314[P]dinit/src/includes/proc-service.h
// Function: base_process_service::transfer_output_pipe()
std::pair<int,int> transfer_output_pipe() noexcept override
    {
        std::pair<int,int> r { log_input_fd, log_output_fd };
        if (log_type == log_type_id::BUFFER && log_output_fd != -1) {
            log_output_listener.deregister(event_loop);
        }
        log_input_fd = log_output_fd = -1;
        return r;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdx
movq %rdx, -0x18(%rbp)
movq %rdx, %rsi
addq $0x4f0, %rsi            # imm = 0x4F0
addq $0x4ec, %rdx            # imm = 0x4EC
leaq -0x8(%rbp), %rdi
callq 0x31360
jmp 0x53410
movq -0x18(%rbp), %rax
cmpl $0x2, 0x298(%rax)
jne 0x53441
movq -0x18(%rbp), %rax
cmpl $-0x1, 0x4ec(%rax)
je 0x53441
movq -0x18(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
leaq 0x55724(%rip), %rsi     # 0xa8b60
callq 0x17d20
movq -0x18(%rbp), %rax
movl $0xffffffff, 0x4ec(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x4f0(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
addq $0x20, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
nopl (%rax,%rax)
// File: davmac314[P]dinit/src/includes/proc-service.h
// Function: process_service::get_input_fd(int*)
bool get_input_fd(int *input_fd) noexcept override
    {
        if (consumer_for == nullptr) {
            *input_fd = -1;
            return true;
        }

        int cfd = consumer_for->get_output_pipe_fd();
        if (cfd == -1) return false;
        *input_fd = cfd;
        return true;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, 0x5c0(%rax)
jne 0x53502
movq -0x18(%rbp), %rax
movl $0xffffffff, (%rax)     # imm = 0xFFFFFFFF
movb $0x1, -0x1(%rbp)
jmp 0x5352f
movq -0x28(%rbp), %rax
movq 0x5c0(%rax), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movl %eax, -0x1c(%rbp)
cmpl $-0x1, -0x1c(%rbp)
jne 0x53522
movb $0x0, -0x1(%rbp)
jmp 0x5352f
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: davmac314[P]dinit/src/includes/proc-service.h
// Function: base_process_service::~base_process_service()
~base_process_service() noexcept
    {
        if (reserved_child_watch) {
            child_listener.unreserve(event_loop);
        }
        process_timer.deregister(event_loop);
        set_log_mode(log_type_id::NONE);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
leaq 0x540ad(%rip), %rcx     # 0xa7878
addq $0x10, %rcx
movq %rcx, (%rax)
movb 0x4f4(%rax), %al
shrb $0x2, %al
andb $0x1, %al
testb $0x1, %al
je 0x537f8
movq -0x10(%rbp), %rdi
addq $0x338, %rdi            # imm = 0x338
leaq 0x5536d(%rip), %rsi     # 0xa8b60
callq 0x53780
movq -0x10(%rbp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
leaq 0x55356(%rip), %rsi     # 0xa8b60
callq 0x539d0
movq -0x10(%rbp), %rdi
xorl %esi, %esi
callq 0x2fb00
movq -0x10(%rbp), %rdi
addq $0x4b8, %rdi            # imm = 0x4B8
callq 0xade8
movq -0x10(%rbp), %rdi
addq $0x408, %rdi            # imm = 0x408
callq 0x53a00
movq -0x10(%rbp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
callq 0x53a20
movq -0x10(%rbp), %rdi
addq $0x380, %rdi            # imm = 0x380
callq 0x53a40
movq -0x10(%rbp), %rdi
addq $0x338, %rdi            # imm = 0x338
callq 0x53a60
movq -0x10(%rbp), %rdi
addq $0x318, %rdi            # imm = 0x318
callq 0xade8
movq -0x10(%rbp), %rdi
addq $0x300, %rdi            # imm = 0x300
callq 0x42dc0
movq -0x10(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x18ff0
movq -0x10(%rbp), %rdi
addq $0x2a0, %rdi            # imm = 0x2A0
callq 0xade8
movq -0x10(%rbp), %rdi
addq $0x278, %rdi            # imm = 0x278
callq 0xade8
movq -0x10(%rbp), %rdi
addq $0x258, %rdi            # imm = 0x258
callq 0xade8
movq -0x10(%rbp), %rdi
addq $0x240, %rdi            # imm = 0x240
callq 0x177c0
movq -0x10(%rbp), %rdi
addq $0x230, %rdi            # imm = 0x230
callq 0x33120
movq -0x10(%rbp), %rdi
addq $0x218, %rdi            # imm = 0x218
callq 0x177c0
movq -0x10(%rbp), %rdi
addq $0x208, %rdi            # imm = 0x208
callq 0x33120
movq -0x10(%rbp), %rdi
callq 0x3cdc0
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>::deregister(dasynq::v2::dprivate::base_timer_watcher*, dasynq::clock_type)
void deregister(base_timer_watcher *callback, clock_type clock) noexcept
    {
        loop_mech.remove_timer(callback->timer_handle, clock);
        
        waitqueue_node<T_Mutex> qnode;
        get_attn_lock(qnode);
        
        loop_mech.issue_delete(callback);
        
        release_lock(qnode);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
movl -0x14(%rbp), %edx
callq 0x53ae0
movq -0x20(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17e90
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x17e00
movq -0x20(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17f80
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: davmac314[P]dinit/src/includes/dinit-utmp.h
// Function: create_utmp_entry(char const*, char const*, int)
inline bool create_utmp_entry(const char *utmp_id, const char *utmp_line, pid_t pid)
{
    struct utmpx record;
    memset(&record, 0, sizeof(record));

    record.ut_type = INIT_PROCESS;
    record.ut_pid = pid;
    set_current_time(&record);
    strncpy(record.ut_id, utmp_id, sizeof(record.ut_id));
    strncpy(record.ut_line, utmp_line, sizeof(record.ut_line));

    setutxent();
    bool success = (pututxline(&record) != NULL);
    endutxent();

    return success;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
leaq -0x194(%rbp), %rdi
xorl %esi, %esi
movl $0x180, %edx            # imm = 0x180
callq 0xa3a0
movw $0x5, -0x194(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x190(%rbp)
leaq -0x194(%rbp), %rdi
callq 0x17ce0
leaq -0x194(%rbp), %rdi
addq $0x28, %rdi
movq -0x8(%rbp), %rsi
movl $0x4, %edx
callq 0xa370
leaq -0x194(%rbp), %rdi
addq $0x8, %rdi
movq -0x10(%rbp), %rsi
movl $0x20, %edx
callq 0xa370
callq 0xa2e0
leaq -0x194(%rbp), %rdi
callq 0xa0c0
cmpq $0x0, %rax
setne %al
andb $0x1, %al
movb %al, -0x195(%rbp)
callq 0xa120
movb -0x195(%rbp), %al
andb $0x1, %al
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
nop
// File: davmac314[P]dinit/src/../dasynq/include/dasynq/timerfd.h
// Function: dasynq::timer_fd_events<dasynq::v2::child_proc_events<dasynq::v2::dprivate::event_dispatch<dasynq::v2::epoll_traits, dasynq::v2::default_traits<dasynq::null_mutex>>>>::stop_timer_nolock(dasynq::dary_heap<dasynq::timer_data, dasynq::time_val, dasynq::compare_timespec, 4>::handle_t&, dasynq::clock_type)
void stop_timer_nolock(timer_handle_t &timer_id, clock_type clock = clock_type::MONOTONIC) noexcept
    {
        timer_queue_t &queue = this->queue_for_clock(clock);
        int fd = (clock == clock_type::MONOTONIC) ? timerfd_fd : systemtime_fd;
        if (queue.is_queued(timer_id)) {
            bool was_first = (&queue.get_root()) == &timer_id;
            queue.remove(timer_id);
            if (was_first) {
                set_timer_from_queue(fd, queue);
            }
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movl -0x14(%rbp), %esi
callq 0x14e70
movq %rax, -0x20(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x53dac
movq -0x30(%rbp), %rax
movl 0x98(%rax), %eax
movl %eax, -0x34(%rbp)
jmp 0x53db9
movq -0x30(%rbp), %rax
movl 0x9c(%rax), %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x14f10
testb $0x1, %al
jne 0x53dd2
jmp 0x53e08
movq -0x20(%rbp), %rdi
callq 0x1d3e0
cmpq -0x10(%rbp), %rax
sete %al
andb $0x1, %al
movb %al, -0x25(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x14f30
testb $0x1, -0x25(%rbp)
je 0x53e06
movl -0x24(%rbp), %edi
movq -0x20(%rbp), %rsi
callq 0x18920
jmp 0x53e08
addq $0x40, %rsp
popq %rbp
retq
nop
// File: davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>::deregister(dasynq::v2::dprivate::base_child_watcher<dasynq::v2::dprivate::proc_status>*, int)
void deregister(base_child_watcher *callback, pid_t child) noexcept
    {
        loop_mech.remove_child_watch(callback->watch_handle);

        waitqueue_node<T_Mutex> qnode;
        get_attn_lock(qnode);
        
        loop_mech.issue_delete(callback);
        
        release_lock(qnode);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x20(%rbp)
movq -0x10(%rbp), %rsi
addq $0x20, %rsi
callq 0x53e70
movq -0x20(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17e90
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x17e00
movq -0x20(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17f80
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::restart_ps_process()
bool base_process_service::restart_ps_process() noexcept
{
    using time_val = dasynq::time_val;

    time_val current_time;
    event_loop.get_time(current_time, clock_type::MONOTONIC);

    // Check if enough time has lapsed since the previous restart. If not, start a timer:
    time_val tdiff = current_time - last_start_time;
    if (restart_delay <= tdiff) {
        // > restart delay (normally 200ms)
        do_restart();
    }
    else {
        time_val timeout = restart_delay - tdiff;
        process_timer.arm_timer_rel(event_loop, timeout);
        waiting_restart_timer = true;
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x18380
leaq 0x53e0c(%rip), %rdi     # 0xa8b60
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x53720
movq -0x50(%rbp), %rsi
addq $0x438, %rsi            # imm = 0x438
leaq -0x18(%rbp), %rdi
callq 0x1d430
movq -0x50(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
addq $0x478, %rdi            # imm = 0x478
leaq -0x28(%rbp), %rsi
callq 0x1d340
testb $0x1, %al
jne 0x54d9a
jmp 0x54da5
movq -0x50(%rbp), %rdi
callq 0x56970
jmp 0x54e0d
movq -0x50(%rbp), %rdi
addq $0x478, %rdi            # imm = 0x478
leaq -0x28(%rbp), %rsi
callq 0x1d430
movq %rax, %rcx
movq -0x50(%rbp), %rax
movq %rcx, -0x38(%rbp)
movq %rdx, -0x30(%rbp)
addq $0x3b0, %rax            # imm = 0x3B0
movq %rax, -0x58(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x153b0
movq -0x58(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq %rdx, -0x40(%rbp)
leaq 0x53d72(%rip), %rsi     # 0xa8b60
leaq -0x48(%rbp), %rdx
callq 0x18220
movq -0x50(%rbp), %rax
movb 0x4f4(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x4f4(%rax)
movb $0x1, %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::handle_unexpected_termination()
void base_process_service::handle_unexpected_termination() noexcept
{
    // unexpected termination, with possible restart
    stop_reason = stopped_reason_t::TERMINATED;

    // We want to circumvent the normal process of waiting for dependents to stop before we
    // attempt to restart, for two reasons:
    // 1) we can restart more quickly
    // 2) we can use the restart rate-limiting logic from restart_ps_process rather than
    //    the usual start_ps_process (the usual bring-up).
    // But we need to issue a forced stop and process queues, to discover our eventual target
    // state (so we know whether we actually want to restart or not).
    // Note we can't call forced_stop() directly here, because we need to set in_auto_restart in
    // between do_stop() and processing queues (so that it is set correctly if restart occurs):

    force_stop = true;
    do_stop();
    services->process_queues();

    if (get_state() == service_state_t::STOPPING) {
        // We must be waiting for dependents;
        // If we're going to restart, we can kick that off now:
        if (get_target_state() == service_state_t::STARTED && !pinned_stopped) {
            initiate_start();
            services->process_queues();
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
movl $0x6, 0x1c4(%rdi)
movb $0x1, 0x190(%rdi)
xorl %esi, %esi
callq 0x4c440
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rdi
callq 0x173c0
movq -0x10(%rbp), %rdi
callq 0x2f0d0
cmpb $0x3, %al
jne 0x56107
movq -0x10(%rbp), %rdi
callq 0x52d20
cmpb $0x2, %al
jne 0x56105
movq -0x10(%rbp), %rax
movl 0x10c(%rax), %eax
shrl %eax
andl $0x1, %eax
testl $0x1, %eax
jne 0x56105
movq -0x10(%rbp), %rdi
callq 0x4c1e0
movq -0x10(%rbp), %rax
movq 0x148(%rax), %rdi
callq 0x173c0
jmp 0x56107
addq $0x10, %rsp
popq %rbp
retq
nopl (%rax)
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::ensure_log_buffer_backing(unsigned int)
bool base_process_service::ensure_log_buffer_backing(unsigned new_size) noexcept
{
    //  Note: we manage capacity manually to avoid it exceeding maximum
    if (log_buffer.size() < new_size) {
        if (log_buffer.capacity() < new_size) {
            try {
                unsigned new_capacity = std::max((unsigned)log_buffer.capacity() * 2, new_size);
                new_capacity = std::min(new_capacity, log_buf_max);
                log_buffer.reserve(new_capacity);
                log_buffer.resize(new_capacity);
            }
            catch (std::bad_alloc &badalloc) {
                log(loglevel_t::WARN, get_name(), ": cannot increase log buffer; out-of-memory");
                return false;
            }
        }
        else {
            log_buffer.resize(new_size);
        }
    }
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x40(%rbp)
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x196b0
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x563eb
movq -0x40(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x577c0
movl -0x14(%rbp), %ecx
cmpq %rcx, %rax
jae 0x563d0
movq -0x40(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
callq 0x577c0
addl %eax, %eax
movl %eax, -0x1c(%rbp)
leaq -0x1c(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x52bc0
movq %rax, -0x48(%rbp)
jmp 0x56323
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
addq $0x2cc, %rsi            # imm = 0x2CC
leaq -0x18(%rbp), %rdi
callq 0x52c00
movq %rax, -0x50(%rbp)
jmp 0x56346
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x18(%rbp)
addq $0x2d8, %rdi            # imm = 0x2D8
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0x577e0
jmp 0x56366
movq -0x40(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl -0x18(%rbp), %eax
movl %eax, %esi
callq 0x18f60
jmp 0x5637d
jmp 0x563ce
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x56402
movq -0x28(%rbp), %rdi
callq 0xa240
movq -0x40(%rbp), %rdi
movq %rax, -0x38(%rbp)
callq 0x2d420
movq %rax, %rsi
leaq 0x22d25(%rip), %rdx     # 0x790dc
movl $0x2, %edi
callq 0x570b0
movb $0x0, -0x1(%rbp)
callq 0xac30
jmp 0x563cc
jmp 0x563ef
jmp 0x563e9
movq -0x40(%rbp), %rdi
addq $0x2d8, %rdi            # imm = 0x2D8
movl -0x14(%rbp), %eax
movl %eax, %esi
callq 0x18f60
jmp 0x563e7
jmp 0x563e9
jmp 0x563eb
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
movq -0x28(%rbp), %rdi
callq 0xfa30
nopl (%rax,%rax)
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::do_restart()
void base_process_service::do_restart() noexcept
{
    // Actually perform process restart. We may be in smooth recovery (state = STARTED) or this may
    // be a regular restart.

    waiting_restart_timer = false;
    auto service_state = get_state();

    if (!start_ps_process(exec_arg_parts, have_console || onstart_flags.shares_console)) {
        if (service_state == service_state_t::STARTING) {
            failed_to_start();
        }
        else {
            // smooth recovery failure
            unrecoverable_stop();
        }
        services->process_queues();
    }
    else {
        // started process successfully (at least as far as fork)
        if (start_timeout != time_val(0,0)) {
            process_timer.arm_timer_rel(event_loop, start_timeout);
            waiting_stopstart_timer = true;
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movb 0x4f4(%rdi), %al
andb $-0x2, %al
orb $0x0, %al
movb %al, 0x4f4(%rdi)
callq 0x2f0d0
movb %al, %cl
movq -0x48(%rbp), %rax
movb %cl, -0x9(%rbp)
movq %rax, %rcx
addq $0x218, %rcx            # imm = 0x218
movq %rcx, -0x40(%rbp)
movl 0x10c(%rax), %ecx
shrl $0x6, %ecx
andl $0x1, %ecx
movb $0x1, %al
testl $0x1, %ecx
movb %al, -0x31(%rbp)
jne 0x569dc
movq -0x48(%rbp), %rax
movw 0x2e(%rax), %ax
shrw $0x4, %ax
andw $0x1, %ax
movb %al, -0x31(%rbp)
movq -0x40(%rbp), %rsi
movq -0x48(%rbp), %rdi
movb -0x31(%rbp), %al
movzbl %al, %edx
andl $0x1, %edx
callq 0x55400
testb $0x1, %al
jne 0x56a2c
cmpb $0x1, -0x9(%rbp)
jne 0x56a0e
movq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x4cf90
jmp 0x56a17
movq -0x48(%rbp), %rdi
callq 0x4d730
movq -0x48(%rbp), %rax
movq 0x148(%rax), %rdi
callq 0x173c0
jmp 0x56aae
movq -0x48(%rbp), %rax
addq $0x498, %rax            # imm = 0x498
movq %rax, -0x50(%rbp)
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1c100
movq -0x50(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x52e50
testb $0x1, %al
jne 0x56a5d
jmp 0x56aac
movq -0x48(%rbp), %rdi
movq %rdi, %rax
addq $0x3b0, %rax            # imm = 0x3B0
movq %rax, -0x58(%rbp)
addq $0x498, %rdi            # imm = 0x498
callq 0x153b0
movq -0x58(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
leaq 0x520d3(%rip), %rsi     # 0xa8b60
leaq -0x30(%rbp), %rdx
callq 0x18220
movq -0x48(%rbp), %rax
movb 0x4f4(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x4f4(%rax)
jmp 0x56aae
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::interrupt_start()
bool base_process_service::interrupt_start() noexcept
{
    if (waiting_restart_timer) {
        process_timer.stop_timer(event_loop);
        waiting_restart_timer = false;
        return service_record::interrupt_start();
    }
    else {
        log(loglevel_t::WARN, "Interrupting start of service ", get_name(), " with pid ", pid,
                " (with SIGINT).");
        kill_pg(SIGINT);

        if (stop_timeout != time_val(0,0)) {
            process_timer.arm_timer_rel(event_loop, stop_timeout);
            waiting_stopstart_timer = true;
        }
        else if (waiting_stopstart_timer) {
            process_timer.stop_timer(event_loop);
            waiting_stopstart_timer = false;
        }

        set_state(service_state_t::STOPPING);
        return false;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movb 0x4f4(%rax), %al
andb $0x1, %al
testb $0x1, %al
je 0x56b1a
movq -0x38(%rbp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
leaq 0x5206e(%rip), %rsi     # 0xa8b60
callq 0x529f0
movq -0x38(%rbp), %rdi
movb 0x4f4(%rdi), %al
andb $-0x2, %al
orb $0x0, %al
movb %al, 0x4f4(%rdi)
callq 0x4df00
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x56c33
movq -0x38(%rbp), %rdi
callq 0x2d420
movq -0x38(%rbp), %r8
movq %rax, %rdx
addq $0x4d8, %r8             # imm = 0x4D8
movl $0x2, %edi
leaq 0x223ee(%rip), %rsi     # 0x78f2b
leaq 0x22062(%rip), %rcx     # 0x78ba6
leaq 0x223ff(%rip), %r9      # 0x78f4a
callq 0x56c40
movq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x56c90
movq -0x38(%rbp), %rax
addq $0x488, %rax            # imm = 0x488
movq %rax, -0x40(%rbp)
leaq -0x20(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0x1c100
movq -0x40(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x52e50
testb $0x1, %al
jne 0x56b8f
jmp 0x56be0
movq -0x38(%rbp), %rdi
movq %rdi, %rax
addq $0x3b0, %rax            # imm = 0x3B0
movq %rax, -0x48(%rbp)
addq $0x488, %rdi            # imm = 0x488
callq 0x153b0
movq -0x48(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
leaq 0x51fa1(%rip), %rsi     # 0xa8b60
leaq -0x30(%rbp), %rdx
callq 0x18220
movq -0x38(%rbp), %rax
movb 0x4f4(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x4f4(%rax)
jmp 0x56c21
movq -0x38(%rbp), %rax
movb 0x4f4(%rax), %al
shrb %al
andb $0x1, %al
testb $0x1, %al
je 0x56c1f
movq -0x38(%rbp), %rdi
addq $0x3b0, %rdi            # imm = 0x3B0
leaq 0x51f5c(%rip), %rsi     # 0xa8b60
callq 0x529f0
movq -0x38(%rbp), %rax
movb 0x4f4(%rax), %cl
andb $-0x3, %cl
orb $0x0, %cl
movb %cl, 0x4f4(%rax)
jmp 0x56c21
movq -0x38(%rbp), %rdi
movl $0x3, %esi
callq 0x52b70
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nop
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::kill_pg(int)
void base_process_service::kill_pg(int signo) noexcept
{
    if (onstart_flags.signal_process_only) {
        bp_sys::kill(pid, signo);
    }
    else {
        pid_t pgid = bp_sys::getpgid(pid);
        if (pgid == -1) {
            // On some OSes (eg OpenBSD) we aren't allowed to get the pgid of a process in a different
            // session. If the process is in a different session, however, it must be a process group
            // leader and the pgid must equal the process id.
            pgid = pid;
        }
        bp_sys::kill(-pgid, signo);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
movw 0x2e(%rax), %ax
shrw $0x9, %ax
andw $0x1, %ax
testw $0x1, %ax
je 0x56ccd
movq -0x18(%rbp), %rax
movl 0x4d8(%rax), %edi
movl -0xc(%rbp), %esi
callq 0xaa90
jmp 0x56cff
movq -0x18(%rbp), %rax
movl 0x4d8(%rax), %edi
callq 0xad10
movl %eax, -0x10(%rbp)
cmpl $-0x1, -0x10(%rbp)
jne 0x56cf2
movq -0x18(%rbp), %rax
movl 0x4d8(%rax), %eax
movl %eax, -0x10(%rbp)
xorl %edi, %edi
subl -0x10(%rbp), %edi
movl -0xc(%rbp), %esi
callq 0xaa90
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::timer_expired()
void base_process_service::timer_expired() noexcept
{
    waiting_stopstart_timer = false;

    // Timer expires if:
    // We are stopping, including after having startup cancelled (stop timeout, state is STOPPING); We are
    // starting (start timeout, state is STARTING); We are waiting for restart timer before restarting,
    // including smooth recovery (restart timeout, state is STARTING or STARTED).
    if (get_state() == service_state_t::STOPPING) {
        kill_with_fire();
    }
    else if (pid != -1) {
        // Starting, start timed out.
        log(loglevel_t::WARN, "Service ", get_name(), " with pid ", pid,
                " exceeded allowed start time; cancelling.");
        interrupt_start();
        stop_reason = stopped_reason_t::TIMEDOUT;
        failed_to_start(false, false);
    }
    else {
        // STARTING / STARTED, and we have no pid: must be restarting (smooth recovery if STARTED)
        do_restart();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x10(%rbp)
movb 0x4f4(%rdi), %al
andb $-0x3, %al
orb $0x0, %al
movb %al, 0x4f4(%rdi)
callq 0x2f0d0
cmpb $0x3, %al
jne 0x56e0c
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *0x88(%rax)
jmp 0x56e7d
movq -0x10(%rbp), %rax
cmpl $-0x1, 0x4d8(%rax)
je 0x56e72
movq -0x10(%rbp), %rdi
callq 0x2d420
movq -0x10(%rbp), %r8
movq %rax, %rdx
addq $0x4d8, %r8             # imm = 0x4D8
movl $0x2, %edi
leaq 0x21bd3(%rip), %rsi     # 0x78a0f
leaq 0x21d63(%rip), %rcx     # 0x78ba6
leaq 0x22110(%rip), %r9      # 0x78f5a
callq 0x56e90
movq -0x10(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
movq -0x10(%rbp), %rdi
movl $0x5, 0x1c4(%rdi)
xorl %edx, %edx
movl %edx, %esi
callq 0x4cf90
jmp 0x56e7b
movq -0x10(%rbp), %rdi
callq 0x56970
jmp 0x56e7d
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_unpin_service()
bool control_conn_t::process_unpin_service()
{
    using std::string;
    
    constexpr int pkt_size = 1 + sizeof(handle_t);
    
    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }
    
    // 1 byte: packet type
    // 4 bytes: service handle
    
    handle_t handle;
    rbuf.extract((char *) &handle, 1, sizeof(handle));
    
    service_record *service = find_service_for_key(handle);
    if (service == nullptr) {
        // Service handle is bad
        char badreqRep[] = { (char)cp_rply::BADREQ };
        if (! queue_packet(badreqRep, 1)) return false;
        bad_conn_close = true;
        return true;
    }

    service->unpin();
    services->process_queues();
    char ack_buf[] = { (char) cp_rply::ACK };
    if (! queue_packet(ack_buf, 1)) return false;
    
    // Clear the packet from the buffer
    rbuf.consume(pkt_size);
    chklen = 0;
    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x30(%rbp)
movl $0x5, -0x14(%rbp)
addq $0x80, %rdi
callq 0x5e200
cmpl $0x5, %eax
jae 0x59210
movq -0x30(%rbp), %rax
movl $0x5, 0x7c(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x592d7
movq -0x30(%rbp), %rdi
addq $0x80, %rdi
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
movl $0x4, %ecx
callq 0x5e220
movq -0x30(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x5e970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x59278
movq -0x30(%rbp), %rdi
movb 0x201f2(%rip), %al      # 0x79441
movb %al, -0x21(%rbp)
leaq -0x21(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
testb $0x1, %al
jne 0x5926a
movb $0x0, -0x1(%rbp)
jmp 0x592d7
movq -0x30(%rbp), %rax
movb $0x1, 0x78(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x592d7
movq -0x20(%rbp), %rdi
callq 0x4dd20
movq -0x30(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x173c0
movq -0x30(%rbp), %rdi
movb 0x201aa(%rip), %al      # 0x79442
movb %al, -0x22(%rbp)
leaq -0x22(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
testb $0x1, %al
jne 0x592b3
movb $0x0, -0x1(%rbp)
jmp 0x592d7
movq -0x30(%rbp), %rdi
addq $0x80, %rdi
movl $0x5, %esi
callq 0x5e1a0
movq -0x30(%rbp), %rax
movl $0x0, 0x7c(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_service_status()
bool control_conn_t::process_service_status()
{
    constexpr int pkt_size = 1 + sizeof(handle_t);
    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }

    handle_t handle;
    rbuf.extract(&handle, 1, sizeof(handle));
    rbuf.consume(pkt_size);
    chklen = 0;

    service_record *service = find_service_for_key(handle);
    if (service == nullptr || service->get_name().length() > std::numeric_limits<uint16_t>::max()) {
        char nak_rep[] = { (char)cp_rply::NAK };
        return queue_packet(nak_rep, 1);
    }

    // Reply:
    // 1 byte packet type = cp_rply::SERVICESTATUS
    // 1 byte reserved ( = 0)
    // STATUS_BUFFER_SIZE bytes status

    std::vector<char> pkt_buf(2 + STATUS_BUFFER_SIZE);
    pkt_buf[0] = (char)cp_rply::SERVICESTATUS;
    pkt_buf[1] = 0;
    fill_status_buffer(pkt_buf.data() + 2, service);

    return queue_packet(std::move(pkt_buf));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x60(%rbp)
movl $0x5, -0x14(%rbp)
addq $0x80, %rdi
callq 0x5e200
cmpl $0x5, %eax
jae 0x59d93
movq -0x60(%rbp), %rax
movl $0x5, 0x7c(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x59ee7
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
movl $0x4, %ecx
callq 0x5e220
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
movl $0x5, %esi
callq 0x5e1a0
movq -0x60(%rbp), %rdi
movl $0x0, 0x7c(%rdi)
movl -0x18(%rbp), %esi
callq 0x5e970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x59e0d
movq -0x20(%rbp), %rdi
callq 0x2d420
movq %rax, %rdi
callq 0xab20
movq %rax, -0x68(%rbp)
callq 0x5f010
movw %ax, %cx
movq -0x68(%rbp), %rax
movzwl %cx, %ecx
cmpq %rcx, %rax
jbe 0x59e32
movq -0x60(%rbp), %rdi
movb 0x1f635(%rip), %al      # 0x7944c
movb %al, -0x21(%rbp)
leaq -0x21(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x59ee7
leaq -0x41(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0xace0
movq -0x70(%rbp), %rdx
leaq -0x40(%rbp), %rdi
movl $0xc, %esi
callq 0x31420
jmp 0x59e53
leaq -0x41(%rbp), %rdi
callq 0xa790
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x5e950
movq -0x78(%rbp), %rdi
movb $0x46, (%rax)
movl $0x1, %esi
callq 0x5e950
movq -0x78(%rbp), %rdi
movb $0x0, (%rax)
callq 0x31180
movq %rax, %rdi
addq $0x2, %rdi
movq -0x20(%rbp), %rsi
callq 0x5c2b0
jmp 0x59e9c
movq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5bc70
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13f20
jmp 0x59ee7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0xa790
jmp 0x59ef5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13f20
jmp 0x59ef5
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0xacc0
nop
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_service_status5()
bool control_conn_t::process_service_status5()
{
    constexpr int pkt_size = 1 + sizeof(handle_t);
    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }

    handle_t handle;
    rbuf.extract(&handle, 1, sizeof(handle));
    rbuf.consume(pkt_size);
    chklen = 0;

    service_record *service = find_service_for_key(handle);
    if (service == nullptr || service->get_name().length() > std::numeric_limits<uint16_t>::max()) {
        char nak_rep[] = { (char)cp_rply::NAK };
        return queue_packet(nak_rep, 1);
    }

    // Reply:
    // 1 byte packet type = cp_rply::SERVICESTATUS
    // 1 byte reserved ( = 0)
    // STATUS_BUFFER5_SIZE bytes status

    std::vector<char> pkt_buf(2 + STATUS_BUFFER5_SIZE);
    pkt_buf[0] = (char)cp_rply::SERVICESTATUS;
    pkt_buf[1] = 0;
    fill_status_buffer5(pkt_buf.data() + 2, service);

    return queue_packet(std::move(pkt_buf));
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x60(%rbp)
movl $0x5, -0x14(%rbp)
addq $0x80, %rdi
callq 0x5e200
cmpl $0x5, %eax
jae 0x59f43
movq -0x60(%rbp), %rax
movl $0x5, 0x7c(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x5a097
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
movl $0x4, %ecx
callq 0x5e220
movq -0x60(%rbp), %rdi
addq $0x80, %rdi
movl $0x5, %esi
callq 0x5e1a0
movq -0x60(%rbp), %rdi
movl $0x0, 0x7c(%rdi)
movl -0x18(%rbp), %esi
callq 0x5e970
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x59fbd
movq -0x20(%rbp), %rdi
callq 0x2d420
movq %rax, %rdi
callq 0xab20
movq %rax, -0x68(%rbp)
callq 0x5f010
movw %ax, %cx
movq -0x68(%rbp), %rax
movzwl %cx, %ecx
cmpq %rcx, %rax
jbe 0x59fe2
movq -0x60(%rbp), %rdi
movb 0x1f486(%rip), %al      # 0x7944d
movb %al, -0x21(%rbp)
leaq -0x21(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x5a097
leaq -0x41(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0xace0
movq -0x70(%rbp), %rdx
leaq -0x40(%rbp), %rdi
movl $0x10, %esi
callq 0x31420
jmp 0x5a003
leaq -0x41(%rbp), %rdi
callq 0xa790
xorl %eax, %eax
movl %eax, %esi
leaq -0x40(%rbp), %rdi
movq %rdi, -0x78(%rbp)
callq 0x5e950
movq -0x78(%rbp), %rdi
movb $0x46, (%rax)
movl $0x1, %esi
callq 0x5e950
movq -0x78(%rbp), %rdi
movb $0x0, (%rax)
callq 0x31180
movq %rax, %rdi
addq $0x2, %rdi
movq -0x20(%rbp), %rsi
callq 0x5c450
jmp 0x5a04c
movq -0x60(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x5bc70
andb $0x1, %al
movb %al, -0x1(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13f20
jmp 0x5a097
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0xa790
jmp 0x5a0a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x13f20
jmp 0x5a0a5
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0xacc0
nop
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_listenenv()
bool control_conn_t::process_listenenv()
{
    // 1 byte packet type, nothing else
    rbuf.consume(1);

    main_env.add_listener(this);

    char ack_rep[] = { (char)cp_rply::ACK };
    return queue_packet(ack_rep, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x18(%rbp)
addq $0x80, %rdi
movl $0x1, %esi
callq 0x5e1a0
movq -0x18(%rbp), %rsi
addq $0x8, %rsi
leaq 0x4fb6c(%rip), %rdi     # 0xaaf40
callq 0x5f610
movq -0x18(%rbp), %rdi
movb 0x1e076(%rip), %al      # 0x79459
movb %al, -0x9(%rbp)
leaq -0x9(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
andb $0x1, %al
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::process_set_trigger()
bool control_conn_t::process_set_trigger()
{
    // 1 byte packet type
    // handle: service
    // 1 byte trigger value
    constexpr int pkt_size = 2 + sizeof(handle_t);

    if (rbuf.get_length() < pkt_size) {
        chklen = pkt_size;
        return true;
    }

    handle_t handle;
    trigger_val_t trigger_val;

    rbuf.extract(&handle, 1, sizeof(handle));
    rbuf.extract(&trigger_val, 1 + sizeof(handle), sizeof(trigger_val));
    rbuf.consume(pkt_size);
    chklen = 0;

    service_record *service = find_service_for_key(handle);
    if (service == nullptr || service->get_type() != service_type_t::TRIGGERED) {
        char nak_rep[] = { (char)cp_rply::NAK };
        return queue_packet(nak_rep, 1);
    }

    triggered_service *tservice = static_cast<triggered_service *>(service);
    tservice->set_trigger(trigger_val != 0);
    services->process_queues();

    char ack_rep[] = { (char)cp_rply::ACK };
    return queue_packet(ack_rep, 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x48(%rbp)
movl $0x6, -0x14(%rbp)
addq $0x80, %rdi
callq 0x5e200
cmpl $0x6, %eax
jae 0x5b440
movq -0x48(%rbp), %rax
movl $0x6, 0x7c(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x5b52d
movq -0x48(%rbp), %rdi
addq $0x80, %rdi
leaq -0x18(%rbp), %rsi
movl $0x1, %edx
movl $0x4, %ecx
callq 0x5e220
movq -0x48(%rbp), %rdi
addq $0x80, %rdi
leaq -0x19(%rbp), %rsi
movl $0x5, %edx
movl $0x1, %ecx
callq 0x5e220
movq -0x48(%rbp), %rdi
addq $0x80, %rdi
movl $0x6, %esi
callq 0x5e1a0
movq -0x48(%rbp), %rdi
movl $0x0, 0x7c(%rdi)
movl -0x18(%rbp), %esi
callq 0x5e970
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5b4bd
movq -0x28(%rbp), %rdi
callq 0x2d5a0
cmpl $0x5, %eax
je 0x5b4df
movq -0x48(%rbp), %rdi
movb 0x1df93(%rip), %al      # 0x7945a
movb %al, -0x29(%rbp)
leaq -0x29(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
andb $0x1, %al
movb %al, -0x1(%rbp)
jmp 0x5b52d
movq -0x28(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
movzbl -0x19(%rbp), %eax
cmpl $0x0, %eax
setne %al
movzbl %al, %esi
andl $0x1, %esi
callq 0x5f650
movq -0x48(%rbp), %rax
movq 0x70(%rax), %rdi
callq 0x173c0
movq -0x48(%rbp), %rdi
movb 0x1df44(%rip), %al      # 0x7945b
movb %al, -0x39(%rbp)
leaq -0x39(%rbp), %rsi
movl $0x1, %edx
callq 0x58340
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::environ_event(environment*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool)
void control_conn_t::environ_event(environment *env, std::string const &var_and_val, bool overridden) noexcept
{
    // packet type (byte) + packet length (byte) + flags byte + data size + data
    // flags byte can be 1 or 0 for now, 1 if the var was overridden and 0 if fresh
    constexpr int pktsize = 3 + sizeof(envvar_len_t);
    envvar_len_t ln = var_and_val.size() + 1;
    auto *ptr = var_and_val.data();

    try {
        std::vector<char> pkt;
        pkt.reserve(pktsize + ln);
        pkt.push_back((char)cp_info::ENVEVENT);
        pkt.push_back(pktsize);
        pkt.push_back(overridden ? 1 : 0);
        pkt.insert(pkt.end(), (char *)&ln, ((char *)&ln) + sizeof(envvar_len_t));
        pkt.insert(pkt.end(), ptr, ptr + ln);
        queue_packet(std::move(pkt));
    } catch (std::bad_alloc &exc) {
        do_oom_close();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xa0(%rbp)
movl $0x5, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa4e0
incl %eax
movw %ax, -0x22(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa970
movq %rax, -0x30(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x30d60
movq -0x98(%rbp), %rdi
movzwl -0x22(%rbp), %eax
addl $0x5, %eax
movl %eax, %esi
callq 0x5e520
jmp 0x5ca83
movb $0x66, -0x55(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x55(%rbp), %rsi
callq 0x5e600
jmp 0x5ca96
movb $0x5, -0x56(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x56(%rbp), %rsi
callq 0x5e600
jmp 0x5caa9
movb -0x19(%rbp), %al
andb $0x1, %al
movb %al, -0x57(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x57(%rbp), %rsi
callq 0x5e600
jmp 0x5cac0
leaq -0x48(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x5f580
movq %rax, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x5f5b0
movq -0xb0(%rbp), %rdi
leaq -0x20(%rbp), %rcx
movq -0x60(%rbp), %rsi
leaq -0x22(%rbp), %rdx
callq 0x5f720
movq %rax, -0xa8(%rbp)
jmp 0x5cb02
movq -0xa8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0xc0(%rbp)
callq 0x5f580
movq %rax, -0x80(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x5f5b0
movq -0xc0(%rbp), %rdi
movq -0x30(%rbp), %rdx
movzwl -0x22(%rbp), %eax
movq %rdx, %rcx
addq %rax, %rcx
movq -0x78(%rbp), %rsi
callq 0x5f4e0
movq %rax, -0xb8(%rbp)
jmp 0x5cb55
movq -0xa0(%rbp), %rdi
movq -0xb8(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x5bc70
leaq -0x48(%rbp), %rdi
callq 0x13f20
jmp 0x5cbc4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x13f20
movl -0x54(%rbp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x5cbd5
movq -0x50(%rbp), %rdi
callq 0xa240
movq -0xa0(%rbp), %rdi
movq %rax, -0x90(%rbp)
callq 0x5eff0
callq 0xac30
jmp 0x5cbc2
jmp 0x5cbc4
addq $0xc0, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
movq -0x50(%rbp), %rdi
callq 0xfa30
nop
// File: davmac314[P]dinit/src/control.cc
// Function: control_conn_t::~control_conn_t()
control_conn_t::~control_conn_t() noexcept
{
    int fd = iob.get_watched_fd();
    iob.deregister(loop);
    bp_sys::close(fd);
    
    // Clear service listeners
    for (auto p : service_key_map) {
        p.first->remove_listener(this);
    }
    main_env.remove_listener(this);
    
    active_control_conns--;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x48(%rbp)
leaq 0x4ab4d(%rip), %rax     # 0xa7bc8
movq %rax, (%rdi)
leaq 0x4ab73(%rip), %rax     # 0xa7bf8
movq %rax, 0x8(%rdi)
addq $0x10, %rdi
callq 0x5fb70
movl %eax, -0x3c(%rbp)
jmp 0x5d097
movq -0x48(%rbp), %rax
movl -0x3c(%rbp), %ecx
movl %ecx, -0xc(%rbp)
movq %rax, %rdi
addq $0x10, %rdi
movq 0x68(%rax), %rsi
callq 0x5fd70
movl -0xc(%rbp), %edi
callq 0xad80
jmp 0x5d0bb
movq -0x48(%rbp), %rax
addq $0x488, %rax            # imm = 0x488
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5fda0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5f9a0
movq %rax, -0x28(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x5e830
testb $0x1, %al
jne 0x5d0f6
jmp 0x5d126
leaq -0x20(%rbp), %rdi
callq 0x5fdd0
movq -0x48(%rbp), %rsi
movq (%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x38(%rbp), %rdi
callq 0x5e8d0
leaq -0x20(%rbp), %rdi
callq 0x5e800
jmp 0x5d0e3
movq -0x48(%rbp), %rsi
addq $0x8, %rsi
leaq 0x4de0b(%rip), %rdi     # 0xaaf40
callq 0x5fe00
movq -0x48(%rbp), %rdi
leaq 0x4bb87(%rip), %rax     # 0xa8ccc
movl (%rax), %ecx
addl $-0x1, %ecx
leaq 0x4bb7b(%rip), %rax     # 0xa8ccc
movl %ecx, (%rax)
addq $0x4f0, %rdi            # imm = 0x4F0
callq 0x114f0
movq -0x48(%rbp), %rdi
addq $0x4c0, %rdi            # imm = 0x4C0
callq 0x11510
movq -0x48(%rbp), %rdi
addq $0x488, %rdi            # imm = 0x488
callq 0x11530
movq -0x48(%rbp), %rdi
addq $0x10, %rdi
callq 0x11550
addq $0x50, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
nopw (%rax,%rax)
// File: davmac314[P]dinit/src/includes/service.h
// Function: service_record::has_lone_ref(bool)
bool has_lone_ref(bool check_deps = true) noexcept
    {
        if (check_deps) {
            for (auto *dept : dependents) {
                // BEFORE links don't count because they are actually specified via the "to" service i.e.
                // this service. AFTER links don't count because, although they come from the dependent,
                // they do not reflect an actual dependency, just an ordering, and this service can still
                // be unloaded if they exist (and replaced with a placeholder).
                if (!value(dept->dep_type).is_in(dependency_type::BEFORE, dependency_type::AFTER)) {
                    return false;
                }
            }
        }
        auto i = listeners.begin();
        return (++i == listeners.end());
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
testb $0x1, -0x11(%rbp)
je 0x5eb53
movq -0x60(%rbp), %rax
addq $0x130, %rax            # imm = 0x130
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
callq 0x304d0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
callq 0x30530
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x30500
testb $0x1, %al
jne 0x5eae4
jmp 0x5eb51
leaq -0x28(%rbp), %rdi
callq 0x30590
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
addq $0x14, %rdi
callq 0x60870
movq %rax, -0x68(%rbp)
jmp 0x5eb07
movq -0x68(%rbp), %rax
movq %rax, -0x40(%rbp)
movl $0x4, -0x44(%rbp)
movl $0x5, -0x48(%rbp)
leaq -0x40(%rbp), %rdi
leaq -0x44(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x608a0
movb %al, -0x69(%rbp)
jmp 0x5eb33
movb -0x69(%rbp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x5eb3e
jmp 0x5eb44
movb $0x0, -0x1(%rbp)
jmp 0x5eb9a
jmp 0x5eb46
leaq -0x28(%rbp), %rdi
callq 0x306a0
jmp 0x5ead1
jmp 0x5eb53
movq -0x60(%rbp), %rdi
addq $0x150, %rdi            # imm = 0x150
callq 0x4e8e0
movq %rax, -0x50(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x4e9a0
movq -0x60(%rbp), %rdi
movq %rax, -0x78(%rbp)
addq $0x150, %rdi            # imm = 0x150
callq 0x4e910
movq -0x78(%rbp), %rdi
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rsi
callq 0x608f0
andb $0x1, %al
movb %al, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0xfa30
// File: davmac314[P]dinit/src/includes/service.h
// Function: service_record::rm_dep(service_record*, dependency_type)
bool rm_dep(service_record *to, dependency_type dep_type) noexcept
    {
        for (auto i = depends_on.begin(); i != depends_on.end(); ++i) {
            auto & dep = *i;
            if (dep.get_to() == to && dep.dep_type == dep_type) {
                rm_dep(i);
                return true;
            }
        }
        return false;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
movq %rdi, -0x50(%rbp)
addq $0x118, %rdi            # imm = 0x118
callq 0x30240
movq %rax, -0x28(%rbp)
movq -0x50(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
callq 0x30270
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x302a0
testb $0x1, %al
jne 0x5f332
jmp 0x5f386
leaq -0x28(%rbp), %rdi
callq 0x302d0
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rdi
callq 0x3cda0
cmpq -0x18(%rbp), %rax
jne 0x5f379
movq -0x38(%rbp), %rax
movl 0x14(%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x5f379
movq -0x50(%rbp), %rdi
movq -0x28(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rsi
callq 0x43500
movq %rax, -0x48(%rbp)
movb $0x1, -0x1(%rbp)
jmp 0x5f38a
jmp 0x5f37b
leaq -0x28(%rbp), %rdi
callq 0x30330
jmp 0x5f30b
movb $0x0, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop
// File: davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>::deregister(dasynq::v2::dprivate::base_bidi_fd_watcher*, int)
void deregister(base_bidi_fd_watcher *callback, int fd) noexcept
    {
        if (backend_traits_t::has_separate_rw_fd_watches) {
            loop_mech.remove_bidi_fd_watch(fd);
        }
        else {
            loop_mech.remove_fd_watch(fd, callback->watch_flags);
        }
        
        waitqueue_node<T_Mutex> qnode;
        get_attn_lock(qnode);
        
        dispatch_t & ed = (dispatch_t &) loop_mech;
        ed.issue_delete(callback);
        
        release_lock(qnode);
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x28(%rbp)
movl -0x14(%rbp), %esi
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
callq 0x12e00
movq -0x28(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17e90
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x6af80
movq -0x28(%rbp), %rdi
leaq -0x15(%rbp), %rsi
callq 0x17f80
addq $0x30, %rsp
popq %rbp
retq
nop