LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: stop_status_pipe_watcher::fd_event(dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>&, int, int)
rearm stop_status_pipe_watcher::fd_event(eventloop_t &loop, int fd, int flags) noexcept
{
    process_service *sr = service;
    sr->waiting_for_execstat = false;

    run_proc_err exec_status;
    int r = read(get_watched_fd(), &exec_status, sizeof(exec_status));
    deregister(loop);
    close(get_watched_fd());

    if (r > 0) {
        // We read an errno code; exec() failed, and the service startup failed.
        if (sr->stop_pid != -1) {
            log(loglevel_t::ERROR, "Service ", sr->get_name(), ": could not fork for stop command: ",
                    exec_stage_descriptions[static_cast<int>(exec_status.stage)], ": ",
                    strerror(exec_status.st_errno));

            sr->stop_watcher.deregister(event_loop, sr->stop_pid);
            sr->reserved_child_watch = false;
            sr->stop_pid = -1;
            if (sr->pid != -1) {
                if (sr->term_signal != 0) {
                    sr->kill_pg(sr->term_signal);
                }
                if (!sr->tracking_child) {
                    sr->stop_issued = false;
                    sr->stopped();
                }
            }
        }
    }
    else {
        // Nothing to do really but wait for termination - unless it's already happened, so let's
        // check that now:
        if (sr->stop_pid == -1) {
            sr->handle_stop_exit();
        }
    }

    sr->services->process_queues();

    return rearm::REMOVED;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r12
movq %rdi, %r14
movq 0x28(%rdi), %rbx
andl $0xffffff7f, 0x10c(%rbx) # imm = 0xFFFFFF7F
movl 0x1c(%rdi), %edi
movq %rsp, %rsi
movl $0x8, %edx
callq 0x88f0
movq %rax, %r15
movl 0x1c(%r14), %edx
movq %r12, %rdi
movq %r14, %rsi
callq 0xda6a
movl 0x1c(%r14), %edi
callq 0x8b60
movl 0x504(%rbx), %eax
testl %r15d, %r15d
jle 0x23e36
cmpl $-0x1, %eax
je 0x23e43
movslq (%rsp), %r15
leaq 0x21958(%rip), %r12     # 0x456e0
movl 0x4(%rsp), %edi
callq 0x81d0
movq %rax, %r14
leaq 0x11cfd(%rip), %rsi     # 0x35a98
movl $0x3, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0x11cec(%rip), %rdi     # 0x35aa1
callq 0x2e73d
movq (%r12,%r15,8), %rdi
callq 0x2e73d
leaq 0xfe74(%rip), %rdi      # 0x33c3e
callq 0x2e73d
movq %r14, %rdi
callq 0x2e759
leaq 0x540(%rbx), %rsi
movl 0x504(%rbx), %edx
leaq 0x22c45(%rip), %rdi     # 0x46a30
callq 0x25e62
andb $-0x5, 0x4f4(%rbx)
movl $0xffffffff, 0x504(%rbx) # imm = 0xFFFFFFFF
cmpl $-0x1, 0x4d8(%rbx)
je 0x23e43
movl 0x194(%rbx), %esi
testl %esi, %esi
je 0x23e1c
movq %rbx, %rdi
callq 0x278d2
testb $0x8, 0x4f4(%rbx)
jne 0x23e43
andb $-0x3, 0x500(%rbx)
movq %rbx, %rdi
callq 0x224b2
jmp 0x23e43
cmpl $-0x1, %eax
jne 0x23e43
movq %rbx, %rdi
callq 0x255fa
movq 0x148(%rbx), %rdi
callq 0xd8da
movl $0x4, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: ready_notify_watcher::fd_event(dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>&, int, int)
rearm ready_notify_watcher::fd_event(eventloop_t &, int fd, int flags) noexcept
{
    char buf[128];
    if (service->get_state() == service_state_t::STARTING) {
        // can we actually read anything from the notification pipe?
        int r = bp_sys::read(fd, buf, sizeof(buf));
        if (r > 0) {
            if (service->waiting_stopstart_timer) {
                service->process_timer.stop_timer(event_loop);
                service->waiting_stopstart_timer = false;
            }
            service->started();
        }
        else if (r == 0 || errno != EAGAIN) {
            if (service->waiting_stopstart_timer) {
                service->process_timer.stop_timer(event_loop);
                service->waiting_stopstart_timer = false;
            }
            service->set_state(service_state_t::STOPPING);
            service->failed_to_start(false, false);
            service->bring_down();
        }
        service->services->process_queues();
    }
    else {
        // Just keep consuming data from the pipe:
        int r = bp_sys::read(fd, buf, sizeof(buf));
        if (r == 0) {
            // Process closed write end or terminated
            close(fd);
            service->notification_fd = -1;
            return rearm::DISARM;
        }
    }

    return rearm::REARM;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x88, %rsp
movl %edx, %ebp
movq %rdi, %rbx
movq 0x28(%rdi), %rax
cmpb $0x1, 0x2c(%rax)
jne 0x23ed2
movq %rsp, %rsi
movl $0x80, %edx
movl %ebp, %edi
callq 0x88f0
testl %eax, %eax
jle 0x23f0a
movq 0x28(%rbx), %rsi
testb $0x2, 0x4f4(%rsi)
je 0x23ec4
movl 0x3fc(%rsi), %edx
addq $0x3d0, %rsi            # imm = 0x3D0
leaq 0x22b7c(%rip), %rdi     # 0x46a30
callq 0x25df4
movq 0x28(%rbx), %rax
andb $-0x3, 0x4f4(%rax)
movq 0x28(%rbx), %rdi
callq 0x233ac
jmp 0x23f62
movq %rsp, %rsi
movl $0x80, %edx
movl %ebp, %edi
callq 0x88f0
movq %rax, %rcx
xorl %eax, %eax
testl %ecx, %ecx
jne 0x23f74
movl %ebp, %edi
callq 0x8b60
movq 0x28(%rbx), %rax
movl $0xffffffff, 0x4e8(%rax) # imm = 0xFFFFFFFF
movl $0x1, %eax
jmp 0x23f74
je 0x23f16
callq 0x8050
cmpl $0xb, (%rax)
je 0x23f62
movq 0x28(%rbx), %rsi
testb $0x2, 0x4f4(%rsi)
je 0x23f47
movl 0x3fc(%rsi), %edx
addq $0x3d0, %rsi            # imm = 0x3D0
leaq 0x22af9(%rip), %rdi     # 0x46a30
callq 0x25df4
movq 0x28(%rbx), %rax
andb $-0x3, 0x4f4(%rax)
movq 0x28(%rbx), %rdi
movb $0x3, 0x2c(%rdi)
xorl %esi, %esi
xorl %edx, %edx
callq 0x23018
movq 0x28(%rbx), %rdi
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x28(%rbx), %rax
movq 0x148(%rax), %rdi
callq 0xd8da
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: service_child_watcher::status_change(dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>&, int, dasynq::dprivate::proc_status)
dasynq::rearm service_child_watcher::status_change(eventloop_t &loop, pid_t child,
        service_child_watcher::proc_status_t status) noexcept
{
    base_process_service *sr = service;

    sr->pid = -1;
    sr->exit_status = status;

    // Ok, for a process service, any process death which we didn't rig ourselves is a bit... unexpected.
    // Probably, the child died because we asked it to (sr->service_state == STOPPING). But even if we
    // didn't, there's not much we can do.

    // Must stop watch now since handle_exit_status might result in re-launch:
    // (stop_watch instead of deregister, so that we hold watch reservation).
    stop_watch(loop);

    if (sr->waiting_for_execstat) {
        // We still don't have an exec() status from the forked child, wait for that
        // before doing any further processing.
        return dasynq::rearm::NOOP; // hold watch reservation
    }

    if (sr->waiting_stopstart_timer) {
        sr->process_timer.stop_timer(loop);
        sr->waiting_stopstart_timer = false;
    }

    sr->handle_exit_status();
    return dasynq::rearm::NOOP;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq 0x40(%rdi), %rbx
movl $0xffffffff, 0x4d8(%rbx) # imm = 0xFFFFFFFF
movq %rcx, 0x4dc(%rbx)
cmpq $0x0, 0x28(%rdi)
je 0x23fb9
movq %rdi, %rsi
addq $0x20, %rsi
leaq 0x28(%r14), %rdi
callq 0xbb06
testb $-0x80, 0x10c(%rbx)
jne 0x23ff0
testb $0x2, 0x4f4(%rbx)
je 0x23fe7
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
movq %r14, %rdi
callq 0x25df4
andb $-0x3, 0x4f4(%rbx)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x68(%rax)
movl $0x2, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: stop_child_watcher::status_change(dasynq::v2::event_loop<dasynq::null_mutex, dasynq::v2::default_traits<dasynq::null_mutex>>&, int, dasynq::dprivate::proc_status)
dasynq::rearm stop_child_watcher::status_change(eventloop_t &loop, pid_t child,
        stop_child_watcher::proc_status_t status) noexcept
{
    process_service *sr = service;

    sr->stop_pid = -1;
    sr->stop_status = status;
    stop_watch(loop);

    if (sr->waiting_for_execstat) {
        // no exec status yet, wait for that first
        return dasynq::rearm::NOOP;
    }

    sr->handle_stop_exit();
    sr->services->process_queues();
    return dasynq::rearm::NOOP;
}

// Assembly:
pushq %rbx
movq 0x40(%rdi), %rbx
movl $0xffffffff, 0x504(%rbx) # imm = 0xFFFFFFFF
movq %rcx, 0x508(%rbx)
cmpq $0x0, 0x28(%rdi)
je 0x24031
movq %rdi, %rax
addq $0x20, %rax
addq $0x28, %rsi
movq %rsi, %rdi
movq %rax, %rsi
callq 0xbb06
testb $-0x80, 0x10c(%rbx)
jne 0x2404e
movq %rbx, %rdi
callq 0x255fa
movq 0x148(%rbx), %rdi
callq 0xd8da
movl $0x2, %eax
popq %rbx
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: process_service::exec_failed(run_proc_err)
void process_service::exec_failed(run_proc_err errcode) noexcept
{
    log(loglevel_t::ERROR, get_name(), ": execution failed - ",
            exec_stage_descriptions[static_cast<int>(errcode.stage)], ": ", strerror(errcode.st_errno));

    if (waiting_stopstart_timer) {
        process_timer.stop_timer(event_loop);
        waiting_stopstart_timer = false;
    }

    if (notification_fd != -1) {
        readiness_watcher.deregister(event_loop);
        bp_sys::close(notification_fd);
        notification_fd = -1;
    }

    if (get_state() == service_state_t::STARTING) {
        stop_reason = stopped_reason_t::EXECFAILED;
        set_state(service_state_t::STOPPING);
        failed_to_start();
    }
    else {
        // Process service in smooth recovery:
        doing_smooth_recovery = false;
        stop_reason = stopped_reason_t::TERMINATED;
        unrecoverable_stop();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq %esi, %r15
movq %rsi, %rdi
shrq $0x20, %rdi
leaq 0x212b4(%rip), %r12     # 0x456e0
callq 0x81d0
movq %rax, %r14
movq 0x8(%rbx), %rsi
movl $0x3, %edi
callq 0x2e63a
leaq 0x116b7(%rip), %rdi     # 0x35b00
callq 0x2e73d
movq (%r12,%r15,8), %rdi
callq 0x2e73d
leaq 0xf7e0(%rip), %rdi      # 0x33c3e
callq 0x2e73d
movq %r14, %rdi
callq 0x2e759
testb $0x2, 0x4f4(%rbx)
je 0x24494
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
leaq 0x225a8(%rip), %rdi     # 0x46a30
callq 0x25df4
andb $-0x3, 0x4f4(%rbx)
cmpl $-0x1, 0x4e8(%rbx)
je 0x244cb
leaq 0x510(%rbx), %rsi
movl 0x52c(%rbx), %edx
leaq 0x2257f(%rip), %rdi     # 0x46a30
callq 0xda6a
movl 0x4e8(%rbx), %edi
callq 0x8b60
movl $0xffffffff, 0x4e8(%rbx) # imm = 0xFFFFFFFF
cmpb $0x1, 0x2c(%rbx)
jne 0x244f9
movl $0x4, 0x1c4(%rbx)
movb $0x3, 0x2c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x23018
movb $0x0, 0x5b8(%rbx)
movl $0x6, 0x1c4(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2347a
movq %rax, %rdi
callq 0xb8be
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: bgproc_service::exec_failed(run_proc_err)
void bgproc_service::exec_failed(run_proc_err errcode) noexcept
{
    log(loglevel_t::ERROR, get_name(), ": execution failed - ",
            exec_stage_descriptions[static_cast<int>(errcode.stage)], ": ", strerror(errcode.st_errno));

    if (waiting_stopstart_timer) {
        process_timer.stop_timer(event_loop);
        waiting_stopstart_timer = false;
    }

    if (doing_smooth_recovery) {
        doing_smooth_recovery = false;
        stop_reason = stopped_reason_t::TERMINATED;
        unrecoverable_stop();
    }
    else {
        // Only time we execute is for startup:
        stop_reason = stopped_reason_t::EXECFAILED;
        set_state(service_state_t::STOPPING);
        failed_to_start();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq %esi, %r15
movq %rsi, %rdi
shrq $0x20, %rdi
leaq 0x20b22(%rip), %r12     # 0x456e0
callq 0x81d0
movq %rax, %r14
movq 0x8(%rbx), %rsi
movl $0x3, %edi
callq 0x2e63a
leaq 0x10f25(%rip), %rdi     # 0x35b00
callq 0x2e73d
movq (%r12,%r15,8), %rdi
callq 0x2e73d
leaq 0xf04e(%rip), %rdi      # 0x33c3e
callq 0x2e73d
movq %r14, %rdi
callq 0x2e759
testb $0x2, 0x4f4(%rbx)
je 0x24c26
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
leaq 0x21e16(%rip), %rdi     # 0x46a30
callq 0x25df4
andb $-0x3, 0x4f4(%rbx)
cmpb $0x1, 0x5b8(%rbx)
jne 0x24c53
movb $0x0, 0x5b8(%rbx)
movl $0x6, 0x1c4(%rbx)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x2347a
movl $0x4, 0x1c4(%rbx)
movb $0x3, 0x2c(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x23018
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: scripted_service::exec_failed(run_proc_err)
void scripted_service::exec_failed(run_proc_err errcode) noexcept
{
    log(loglevel_t::ERROR, get_name(), ": execution failed - ",
            exec_stage_descriptions[static_cast<int>(errcode.stage)], ": ", strerror(errcode.st_errno));
    auto current_state = get_state();
    if (current_state == service_state_t::STARTING) {
        stop_reason = stopped_reason_t::EXECFAILED;
        failed_to_start();
    }
    else if (current_state == service_state_t::STOPPING) {
        // We've logged the failure, but it's probably better not to leave the service in
        // STOPPING state:
        stopped();
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
movslq %esi, %r15
movq %rsi, %rdi
shrq $0x20, %rdi
leaq 0x207d8(%rip), %r12     # 0x456e0
callq 0x81d0
movq %rax, %r14
movq 0x8(%rbx), %rsi
movl $0x3, %edi
callq 0x2e63a
leaq 0x10bdb(%rip), %rdi     # 0x35b00
callq 0x2e73d
movq (%r12,%r15,8), %rdi
callq 0x2e73d
leaq 0xed04(%rip), %rdi      # 0x33c3e
callq 0x2e73d
movq %r14, %rdi
callq 0x2e759
movzbl 0x2c(%rbx), %eax
cmpl $0x3, %eax
je 0x24f79
cmpl $0x1, %eax
jne 0x24f8c
movl $0x4, 0x1c4(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x23018
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x224b2
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: process_service::kill_with_fire()
void process_service::kill_with_fire() noexcept
{
    base_process_service::kill_with_fire();

    if (stop_pid != -1) {
        log(loglevel_t::WARN, "Service ", get_name(), " stop command, with pid ", pid,
                ", exceeded allowed stop time; killing.");
        pid_t pgid = bp_sys::getpgid(stop_pid);
        if (pgid == -1) {
            // On OpenBSD, not allowed to query pgid of a process in another session, but in that
            // case we know the group anyway:
            pgid = stop_pid;
        }
        bp_sys::kill(-pgid, SIGKILL);
    }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x2790a
cmpl $-0x1, 0x504(%rbx)
je 0x2548b
leaq 0x10685(%rip), %rsi     # 0x35a98
movl $0x2, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0x107f4(%rip), %rdi     # 0x35c21
callq 0x2e73d
movl 0x4d8(%rbx), %ecx
leaq 0x1139d(%rip), %rdx     # 0x367dc
leaq 0xc(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
movq %r14, %rdi
callq 0x2e73d
leaq 0x107d8(%rip), %rdi     # 0x35c3a
callq 0x2e759
movl 0x504(%rbx), %edi
callq 0x8ae0
cmpl $-0x1, %eax
jne 0x2547d
movl 0x504(%rbx), %eax
negl %eax
movl %eax, %edi
movl $0x9, %esi
callq 0x88d0
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/proc-service.cc
// Function: scripted_service::bring_down()
void scripted_service::bring_down() noexcept
{
    if (pid != -1) {
        // We're already running the stop script; nothing to do.
        return;
    }

    if (stop_command.length() == 0) {
        stopped();
    }
    else if (! start_ps_process(stop_arg_parts, false)) {
        // Couldn't execute stop script, but there's not much we can do:
        stopped();
    }
    else {
        // successfully started stop script: start kill timer:
        if (stop_timeout != time_val(0,0)) {
            process_timer.arm_timer_rel(event_loop, stop_timeout);
            waiting_stopstart_timer = true;
        }
    }
}

// Assembly:
pushq %rbx
subq $0x20, %rsp
cmpl $-0x1, 0x4d8(%rdi)
je 0x254a8
addq $0x20, %rsp
popq %rbx
retq
movq %rdi, %rbx
cmpq $0x0, 0x238(%rdi)
je 0x2551e
leaq 0x240(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2680e
testb %al, %al
je 0x2551e
movq 0x488(%rbx), %rax
movq 0x490(%rbx), %rdi
movq %rax, %rcx
orq %rdi, %rcx
je 0x254a2
movl 0x3fc(%rbx), %r9d
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
leaq 0x3d0(%rbx), %rsi
leaq 0x10(%rsp), %rdx
movq %rax, (%rdx)
movq %rdi, 0x8(%rdx)
leaq 0x21526(%rip), %rdi     # 0x46a30
movl $0x1, %r8d
callq 0xdbb6
orb $0x2, 0x4f4(%rbx)
jmp 0x254a2
movq %rbx, %rdi
addq $0x20, %rsp
popq %rbx
jmp 0x224b2
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/proc-service.h
// Function: process_service::handle_stop_exit()
void handle_stop_exit() noexcept
    {
        if (!stop_status.did_exit_clean()) {
            if (stop_status.did_exit()) {
                log(loglevel_t::ERROR, "Service ", get_name(), " stop command terminated with exit code ",
                        stop_status.get_exit_status());
            }
            else if (stop_status.was_signalled()) {
                log(loglevel_t::ERROR, "Service ", get_name(), " stop command terminated due to signal ",
                        stop_status.get_signal());
            }
        }

        if (pid == -1 || !tracking_child) {
            // If service process has already finished, we were just waiting for the stop command
            // process:
            stop_issued = false; // reset for next time
            stopped();
        }
    }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl 0x50c(%rdi), %ebp
testl %ebp, %ebp
je 0x25670
movl 0x508(%rbx), %r14d
leaq 0x1047b(%rip), %rsi     # 0x35a98
movl $0x3, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
cmpl $0x1, %r14d
jne 0x2563f
leaq 0x107b3(%rip), %rdi     # 0x35df0
jmp 0x25646
leaq 0x10530(%rip), %rdi     # 0x35b76
callq 0x2e73d
leaq 0x1118a(%rip), %rdx     # 0x367dc
leaq 0x4(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
movl %ebp, %ecx
xorl %eax, %eax
callq 0x89e0
movq %r14, %rdi
callq 0x2e759
cmpl $-0x1, 0x4d8(%rbx)
je 0x25682
testb $0x8, 0x4f4(%rbx)
jne 0x25691
andb $-0x3, 0x500(%rbx)
movq %rbx, %rdi
callq 0x224b2
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-utmp.h
// Function: clear_utmp_entry(char const*, char const*)
inline void clear_utmp_entry(const char *utmp_id, const char *utmp_line)
{
    struct utmpx record;
    memset(&record, 0, sizeof(record));

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

    struct utmpx *result;

    setutxent();

    // Try to find an existing entry by id/line and copy the process ID:
    if (*utmp_id) {
        result = getutxid(&record);
    }
    else {
        result = getutxline(&record);
    }

    if (result) {
        record.ut_pid = result->ut_pid;
    }

    pututxline(&record);
    endutxent();
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x18(%rsp), %r15
movl $0x180, %edx            # imm = 0x180
movq %r15, %rdi
xorl %esi, %esi
callq 0x8350
movw $0x8, (%r15)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
xorl %esi, %esi
callq 0x8a10
movl (%r12), %eax
movl 0x8(%r12), %ecx
movl %eax, 0x154(%r15)
movl %ecx, 0x158(%r15)
leaq 0x40(%rsp), %rdi
movl $0x4, %edx
movq %rbx, %rsi
callq 0x8310
leaq 0x20(%rsp), %rdi
movl $0x20, %edx
movq %r14, %rsi
callq 0x8310
callq 0x8270
cmpb $0x0, (%rbx)
je 0x25728
leaq 0x18(%rsp), %rdi
callq 0x89c0
jmp 0x25732
leaq 0x18(%rsp), %rdi
callq 0x8ad0
testq %rax, %rax
je 0x2573e
movl 0x4(%rax), %eax
movl %eax, 0x1c(%rsp)
leaq 0x18(%rsp), %rdi
callq 0x80c0
callq 0x8100
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/proc-service.h
// Function: process_service::check_restart()
virtual bool check_restart() noexcept override
    {
        if (max_restart_interval_count != 0) {
            // Check whether we're still in the most recent restart check interval:
            time_val current_time;
            event_loop.get_time(current_time, clock_type::MONOTONIC);
            time_val int_diff = current_time - restart_interval_time;
            if (int_diff < restart_interval) {
                // Within the restart limiting interval; check number of restarts
                if (restart_interval_count >= max_restart_interval_count) {
                    log(loglevel_t::ERROR, "Service ", get_name(), " restarting too quickly; stopping.");
                    set_target_state(service_state_t::STOPPED);
                    return false;
                }
                ++restart_interval_count;
            }
            else {
                // Not within the last limiting interval; start a new interval
                restart_interval_time = current_time;
                restart_interval_count = 1;
            }
        }

        return true;
    }

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movb $0x1, %bpl
cmpl $0x0, 0x470(%rdi)
je 0x2590d
movq %rdi, %rbx
movq %rsp, %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x8560
movq (%r14), %rcx
subq 0x448(%rbx), %rcx
movq 0x8(%r14), %rdx
movq 0x450(%rbx), %rax
movq 0x460(%rbx), %rsi
xorl %edi, %edi
cmpq %rax, %rdx
setl %dil
subq %rdi, %rcx
cmpq %rsi, %rcx
jl 0x258af
leaq 0x3b9aca00(%rdx), %rdi
cmpq %rax, %rdx
cmovgeq %rdx, %rdi
cmpq %rsi, %rcx
jne 0x258f5
subq %rax, %rdi
cmpq 0x468(%rbx), %rdi
jge 0x258f5
movl 0x458(%rbx), %eax
cmpl 0x470(%rbx), %eax
jge 0x258c7
incl %eax
movl %eax, 0x458(%rbx)
jmp 0x2590d
leaq 0x101ca(%rip), %rsi     # 0x35a98
movl $0x3, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0x10531(%rip), %rdi     # 0x35e19
callq 0x2e759
movb $0x0, 0x2d(%rbx)
xorl %ebp, %ebp
jmp 0x2590d
leaq 0x448(%rbx), %rax
movups (%rsp), %xmm0
movups %xmm0, (%rax)
movl $0x1, 0x458(%rbx)
movl %ebp, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1fe62(%rip), %rax     # 0x45788
movq %rax, (%rdi)
testb $0x1, 0x500(%rdi)
je 0x25958
leaq 0x560(%rbx), %rsi
leaq 0x210f0(%rip), %r14     # 0x46a30
leaq 0x28(%r14), %rdi
callq 0x1f22c
leaq 0x550(%rbx), %rsi
movq %r14, %rdi
callq 0xc92c
movq 0x5c0(%rbx), %rax
testq %rax, %rax
je 0x2596f
movq $0x0, 0x188(%rax)
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x25bea
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
movq %rdi, %r14
movl 0x4f0(%rdi), %r15d
movl 0x4ec(%rdi), %eax
movl %eax, %ebx
cmpl $0x2, 0x298(%rdi)
setne %cl
cmpl $-0x1, %eax
sete %al
orb %cl, %al
jne 0x25a63
leaq 0x408(%r14), %rsi
movl 0x424(%r14), %edx
leaq 0x20fd2(%rip), %rdi     # 0x46a30
callq 0xda6a
movq $-0x1, 0x4ec(%r14)
shlq $0x20, %rbx
orq %r15, %rbx
movq %rbx, %rax
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1fdc0(%rip), %rax     # 0x459b8
addq $0x10, %rax
movq %rax, (%rdi)
testb $0x4, 0x4f4(%rdi)
je 0x25c2e
leaq 0x358(%rbx), %rsi
leaq 0x20e1a(%rip), %r14     # 0x46a30
leaq 0x28(%r14), %rdi
callq 0x1f22c
leaq 0x348(%rbx), %rsi
movq %r14, %rdi
callq 0xc92c
leaq 0x3b0(%rbx), %rsi
movl 0x3fc(%rbx), %edx
leaq 0x20dee(%rip), %rdi     # 0x46a30
callq 0x25dac
movq %rbx, %rdi
xorl %esi, %esi
callq 0x1b8fc
movq 0x4b8(%rbx), %rdi
leaq 0x4c8(%rbx), %rax
cmpq %rax, %rdi
je 0x25c6f
movq (%rax), %rsi
incq %rsi
callq 0x8620
movq 0x318(%rbx), %rdi
leaq 0x328(%rbx), %rax
cmpq %rax, %rdi
je 0x25c8d
movq (%rax), %rsi
incq %rsi
callq 0x8620
movq 0x300(%rbx), %rdi
testq %rdi, %rdi
je 0x25ca8
movq 0x310(%rbx), %rsi
subq %rdi, %rsi
callq 0x8620
movq 0x2d8(%rbx), %rdi
testq %rdi, %rdi
je 0x25cc3
movq 0x2e8(%rbx), %rsi
subq %rdi, %rsi
callq 0x8620
movq 0x2a0(%rbx), %rdi
leaq 0x2b0(%rbx), %rax
cmpq %rax, %rdi
je 0x25ce1
movq (%rax), %rsi
incq %rsi
callq 0x8620
movq 0x278(%rbx), %rdi
leaq 0x288(%rbx), %rax
cmpq %rax, %rdi
je 0x25cff
movq (%rax), %rsi
incq %rsi
callq 0x8620
movq 0x258(%rbx), %rdi
leaq 0x268(%rbx), %rax
cmpq %rax, %rdi
je 0x25d1d
movq (%rax), %rsi
incq %rsi
callq 0x8620
movq 0x240(%rbx), %rdi
testq %rdi, %rdi
je 0x25d38
movq 0x250(%rbx), %rsi
subq %rdi, %rsi
callq 0x8620
movq 0x230(%rbx), %rdi
testq %rdi, %rdi
je 0x25d49
callq 0x87c0
movq 0x218(%rbx), %rdi
testq %rdi, %rdi
je 0x25d64
movq 0x228(%rbx), %rsi
subq %rdi, %rsi
callq 0x8620
movq 0x208(%rbx), %rdi
testq %rdi, %rdi
je 0x25d75
callq 0x87c0
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1e714
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
addq $0x20, %rsi
callq 0xd0ae
leaq 0xf(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xdb22
movq %r14, %rdi
movq %rbx, %rsi
callq 0xdad6
movq %r14, %rdi
movq %r15, %rsi
callq 0xdb4e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
xorl %eax, %eax
xorl %r8d, %r8d
cmpl $0x1, %edx
setne %cl
sete %dl
movq 0x20(%rsi), %rsi
cmpq $-0x1, %rsi
je 0x25e42
movb %dl, %r8b
shll $0x5, %r8d
leaq (%rdi,%r8), %r14
addq $0x58, %r14
movb %cl, %al
movl 0x98(%rdi,%rax,4), %ebp
movq (%r14), %rax
movq 0x10(%rax), %r15
movq %r14, %rdi
callq 0xd114
cmpq %rbx, %r15
je 0x25e4d
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %edi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xddaa
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x38, %rsp
movq %rdi, %rbx
leaq 0x18(%rsp), %r14
movl $0x1, %edi
movq %r14, %rsi
callq 0x8560
movq (%r14), %rdx
subq 0x438(%rbx), %rdx
movq 0x8(%r14), %rsi
leaq 0x3b9aca00(%rsi), %rcx
movq 0x440(%rbx), %rdi
movq 0x478(%rbx), %rax
xorl %r8d, %r8d
cmpq %rdi, %rsi
cmovgeq %rsi, %rcx
setl %r8b
subq %rdi, %rcx
subq %r8, %rdx
subq %rdx, %rax
jl 0x26431
jne 0x2643b
cmpq %rcx, 0x480(%rbx)
jg 0x2643b
movq %rbx, %rdi
callq 0x276d2
jmp 0x26498
movq 0x480(%rbx), %rdx
leaq 0x3b9aca00(%rdx), %rdi
xorl %esi, %esi
cmpq %rcx, %rdx
setl %sil
cmovgeq %rdx, %rdi
subq %rcx, %rdi
subq %rsi, %rax
movl 0x3fc(%rbx), %r9d
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
leaq 0x3d0(%rbx), %rsi
leaq 0x28(%rsp), %rdx
movq %rax, (%rdx)
movq %rdi, 0x8(%rdx)
leaq 0x205aa(%rip), %rdi     # 0x46a30
movl $0x1, %r8d
callq 0xdbb6
orb $0x1, 0x4f4(%rbx)
movb $0x1, %al
addq $0x38, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::bring_up()
bool base_process_service::bring_up() noexcept
{
    if (!open_socket()) {
        return false;
    }

    bool start_success;
    if (in_auto_restart) {
        start_success = restart_ps_process();
    }
    else {
        restart_interval_count = 0;
        start_success = start_ps_process(exec_arg_parts,
                onstart_flags.starts_on_console || onstart_flags.shares_console);
        // start_ps_process updates last_start_time, use it also for restart_interval_time:
        restart_interval_time = last_start_time;

        // Arm start timer. (For restarts, this is only done once the restart interval expires).
        if (start_success) {
            if (start_timeout != time_val(0,0)) {
                process_timer.arm_timer_rel(event_loop, start_timeout);
                waiting_stopstart_timer = true;
            }
            else if (waiting_stopstart_timer) {
                process_timer.stop_timer(event_loop);
                waiting_stopstart_timer = false;
            }
        }
    }

    return start_success;
}

// Assembly:
pushq %rbp
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0x26594
testb %al, %al
je 0x26551
testb $0x2, 0x10e(%rbx)
jne 0x26555
movl $0x0, 0x458(%rbx)
leaq 0x218(%rbx), %rsi
movzwl 0x2e(%rbx), %eax
xorl %edx, %edx
testb $0x18, %al
setne %dl
movq %rbx, %rdi
callq 0x2680e
movl %eax, %ebp
movups 0x438(%rbx), %xmm0
movups %xmm0, 0x448(%rbx)
testb %al, %al
je 0x26560
movq 0x498(%rbx), %rax
movq 0x4a0(%rbx), %rdi
movq %rax, %rcx
orq %rdi, %rcx
je 0x26569
movl 0x3fc(%rbx), %r9d
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
leaq 0x3d0(%rbx), %rsi
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
movq %rdi, 0x8(%rdx)
leaq 0x204f3(%rip), %rdi     # 0x46a30
movl $0x1, %r8d
callq 0xdbb6
orb $0x2, 0x4f4(%rbx)
jmp 0x26560
xorl %ebp, %ebp
jmp 0x26560
movq %rbx, %rdi
callq 0x263ce
movb $0x1, %bpl
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
testb $0x2, 0x4f4(%rbx)
je 0x26560
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
leaq 0x204aa(%rip), %rdi     # 0x46a30
callq 0x25df4
andb $-0x3, 0x4f4(%rbx)
jmp 0x26560
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
andb $-0x2, 0x4f4(%rdi)
movb 0x2c(%rdi), %bpl
leaq 0x218(%rdi), %rsi
movl 0x10c(%rdi), %eax
andl $0x40, %eax
shrl $0x6, %eax
movzwl 0x2e(%rdi), %edx
andl $0x10, %edx
shrl $0x4, %edx
orl %eax, %edx
callq 0x2680e
testb %al, %al
je 0x27767
movq 0x498(%rbx), %rax
movq 0x4a0(%rbx), %rdi
movq %rax, %rcx
orq %rdi, %rcx
je 0x27760
movl 0x3fc(%rbx), %r9d
xorps %xmm0, %xmm0
movq %rsp, %rcx
movaps %xmm0, (%rcx)
leaq 0x3d0(%rbx), %rsi
leaq 0x18(%rsp), %rdx
movq %rax, (%rdx)
movq %rdi, 0x8(%rdx)
leaq 0x1f2e2(%rip), %rdi     # 0x46a30
movl $0x1, %r8d
callq 0xdbb6
orb $0x2, 0x4f4(%rbx)
addq $0x28, %rsp
popq %rbx
popq %rbp
retq
movq %rbx, %rdi
cmpb $0x1, %bpl
jne 0x2777e
xorl %esi, %esi
movl $0x1, %edx
callq 0x23018
jmp 0x27783
callq 0x2347a
movq 0x148(%rbx), %rdi
addq $0x28, %rsp
popq %rbx
popq %rbp
jmp 0xd8da
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
testb $0x1, 0x4f4(%rdi)
je 0x277d8
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
leaq 0x1f273(%rip), %rdi     # 0x46a30
callq 0x25df4
andb $-0x2, 0x4f4(%rbx)
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r14
jmp 0x23928
leaq 0xe7d5(%rip), %rsi      # 0x35fb4
movl $0x2, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0xe436(%rip), %rdi      # 0x35c2f
callq 0x2e73d
movl 0x4d8(%rbx), %ecx
leaq 0xefd1(%rip), %rdx      # 0x367dc
movq %rsp, %r14
movl $0xc, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
movq %r14, %rdi
callq 0x2e73d
leaq 0xe7a7(%rip), %rdi      # 0x35fd3
callq 0x2e759
movq %rbx, %rdi
movl $0x2, %esi
callq 0x278d2
movq 0x488(%rbx), %rax
movq 0x490(%rbx), %rdi
movq %rax, %rcx
orq %rdi, %rcx
je 0x27893
movl 0x3fc(%rbx), %r9d
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rcx
movaps %xmm0, (%rcx)
leaq 0x3d0(%rbx), %rsi
movq %rsp, %rdx
movq %rax, (%rdx)
movq %rdi, 0x8(%rdx)
leaq 0x1f1b2(%rip), %rdi     # 0x46a30
movl $0x1, %r8d
callq 0xdbb6
movb 0x4f4(%rbx), %al
orb $0x2, %al
jmp 0x278bd
testb $0x2, 0x4f4(%rbx)
je 0x278c3
movl 0x3fc(%rbx), %edx
leaq 0x3d0(%rbx), %rsi
leaq 0x1f180(%rip), %rdi     # 0x46a30
callq 0x25df4
movb 0x4f4(%rbx), %al
andb $-0x3, %al
movb %al, 0x4f4(%rbx)
movb $0x3, 0x2c(%rbx)
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
pushq %rax
movl %esi, %ebx
movq %rdi, %r14
testb $0x2, 0x2f(%rdi)
movl 0x4d8(%rdi), %edi
jne 0x278fc
callq 0x8ae0
movl %eax, %edi
cmpl $-0x1, %eax
jne 0x278fa
movl 0x4d8(%r14), %edi
negl %edi
movl %ebx, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x88d0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/baseproc-service.cc
// Function: base_process_service::kill_with_fire()
void base_process_service::kill_with_fire() noexcept
{
    if (pid != -1) {
        log(loglevel_t::WARN, "Service ", get_name(), " with pid ", pid,
                " exceeded allowed stop time; killing.");
        kill_pg(SIGKILL);
    }
}

// Assembly:
cmpl $-0x1, 0x4d8(%rdi)
je 0x2798c
pushq %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0xe174(%rip), %rsi      # 0x35a98
movl $0x2, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0xe2f1(%rip), %rdi      # 0x35c2f
callq 0x2e73d
movl 0x4d8(%rbx), %ecx
leaq 0xee8c(%rip), %rdx      # 0x367dc
leaq 0xc(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
movq %r14, %rdi
callq 0x2e73d
leaq 0xe2c8(%rip), %rdi      # 0x35c3b
callq 0x2e759
movq %rbx, %rdi
movl $0x9, %esi
callq 0x278d2
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
andb $-0x3, 0x4f4(%rdi)
cmpb $0x3, 0x2c(%rdi)
jne 0x279b8
movq (%rbx), %rax
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r14
jmpq *0x88(%rax)
cmpl $-0x1, 0x4d8(%rbx)
je 0x27a47
leaq 0xe0cc(%rip), %rsi      # 0x35a98
movl $0x2, %edi
callq 0x2e63a
movq 0x8(%rbx), %rdi
callq 0x2e73d
leaq 0xe249(%rip), %rdi      # 0x35c2f
callq 0x2e73d
movl 0x4d8(%rbx), %ecx
leaq 0xede4(%rip), %rdx      # 0x367dc
leaq 0xc(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
movq %r14, %rdi
callq 0x2e73d
leaq 0xe5c8(%rip), %rdi      # 0x35fe3
callq 0x2e759
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
movl $0x5, 0x1c4(%rbx)
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x23018
addq $0x18, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r14
jmp 0x276d2
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::queue_packet(char const*, unsigned int)
bool control_conn_t::queue_packet(const char *pkt, unsigned size) noexcept
{
    bool was_empty = outbuf.empty();

    // If the queue is empty, we can try to write the packet out now rather than queueing it.
    // If the write is unsuccessful or partial, we queue the remainder.
    if (was_empty) {
        int wr = bp_sys::write(iob.get_watched_fd(), pkt, size);
        if (wr == -1) {
            if (errno == EPIPE) {
                return false;
            }
            if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) {
                log(loglevel_t::WARN, "Error writing to control connection: ", strerror(errno));
                return false;
            }
            // EAGAIN etc: fall through to below
        }
        else {
            if ((unsigned)wr == size) {
                // Ok, all written.
                return true;
            }
            pkt += wr;
            size -= wr;
        }
    }
    
    // Create a vector out of the (remaining part of the) packet:
    try {
        outbuf.emplace_back(pkt, pkt + size);
        outbuf_size += size;
        return true;
    }
    catch (std::bad_alloc &baexc) {
        // Mark the connection bad, and stop reading further requests
        bad_conn_close = true;
        oom_close = true;
        if (was_empty) {
            // We can't send out-of-memory response as we already wrote as much as we
            // could above. Neither can we later send the response since we have currently
            // sent an incomplete packet. All we can do is close the connection.
            return false;
        }
        else {
            return true;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl %edx, %ebp
movq %rdi, %rbx
movq %rsi, (%rsp)
leaq 0x4f0(%rdi), %r14
cmpq %r14, 0x4f0(%rdi)
setne %r12b
jne 0x28065
movl 0x2c(%rbx), %edi
movl %ebp, %edx
callq 0x81e0
cmpl $-0x1, %eax
je 0x28016
movl %ebp, %edx
subl %eax, %edx
jne 0x28053
movb $0x1, %al
xorl %ecx, %ecx
jmp 0x28061
callq 0x8050
movl (%rax), %edi
cmpl $0x4, %edi
je 0x2805f
cmpl $0xb, %edi
je 0x2805f
cmpl $0x20, %edi
je 0x2804d
callq 0x81d0
movq %rax, %r15
leaq 0xe4c4(%rip), %rsi      # 0x364ff
movl $0x2, %edi
callq 0x2e63a
movq %r15, %rdi
callq 0x2e759
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x28061
cltq
addq %rax, (%rsp)
movb $0x1, %cl
movl %edx, %ebp
jmp 0x28061
movb $0x1, %cl
testb %cl, %cl
je 0x28097
movl %ebp, %eax
movq %rsp, %rsi
addq (%rsi), %rax
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
movq %r14, %rdi
callq 0x2e100
movq %rax, %rdi
movq %r14, %rsi
callq 0x8060
incq 0x500(%rbx)
addl %ebp, 0x508(%rbx)
movb $0x1, %al
andb $0x1, %al
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %edx
jne 0x280c3
movq %rax, %rdi
callq 0x8210
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a50
movl %r12d, %eax
jmp 0x28097
movq %rax, %rdi
callq 0xb8be
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
cmpl $0x4, 0x484(%rdi)
ja 0x28a53
movl $0x5, 0x7c(%rbx)
movb $0x1, %al
jmp 0x28b4d
leaq 0x80(%rbx), %r14
movl 0x480(%rbx), %r15d
leal 0x1(%r15), %eax
addl $0xfffffc01, %r15d      # imm = 0xFFFFFC01
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3fd(%r15), %eax
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0x28abc
movl $0x400, %r12d           # imm = 0x400
subl %r15d, %r12d
movl %r15d, %esi
addq %r14, %rsi
leaq 0xc(%rsp), %r13
movq %r13, %rdi
movq %r12, %rdx
callq 0x84d0
addq %r13, %r12
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %r12, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x84d0
jmp 0x28ac7
movl %r15d, %eax
movl (%r14,%rax), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x2ba66
testq %rax, %rax
je 0x28b30
movq %rax, %rdi
callq 0x23800
movq 0x70(%rbx), %rdi
callq 0xd8da
leaq 0xa(%rsp), %rsi
movb $0x32, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
testb %al, %al
je 0x28b4d
movl 0x480(%rbx), %ecx
leal 0x5(%rcx), %edx
addl $0xfffffc05, %ecx       # imm = 0xFFFFFC05
cmpl $0x400, %edx            # imm = 0x400
cmovbl %edx, %ecx
movl %ecx, 0x480(%rbx)
addl $-0x5, 0x484(%rbx)
movl $0x0, 0x7c(%rbx)
jmp 0x28b4d
leaq 0xb(%rsp), %rsi
movb $0x34, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
testb %al, %al
je 0x28b4d
movb $0x1, 0x78(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
nop