LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
cmpl $0x4, 0x484(%rdi)
ja 0x292e5
movl $0x5, 0x7c(%rbx)
movb $0x1, %bl
jmp 0x2942f
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 0x2934e
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 0x29359
movl %r15d, %eax
movl (%r14,%rax), %eax
movl %eax, 0xc(%rsp)
movl 0x480(%rbx), %eax
leal 0x5(%rax), %ecx
addl $0xfffffc05, %eax       # imm = 0xFFFFFC05
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x480(%rbx)
addl $-0x5, 0x484(%rbx)
movl $0x0, 0x7c(%rbx)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x2ba66
testq %rax, %rax
je 0x293a2
movq %rax, %r14
cmpq $0x10000, 0x10(%rax)    # imm = 0x10000
jb 0x293bb
leaq 0x10(%rsp), %rsi
movb $0x33, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
movl %eax, %ebx
jmp 0x2942f
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
xorl %r15d, %r15d
movq %r15, 0x20(%rsp)
movl $0xc, %edi
callq 0x8600
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
leaq 0xc(%rax), %rcx
movq %rcx, 0x20(%rsp)
movq %r15, (%rax)
movl $0x0, 0x8(%rax)
movq %rcx, 0x18(%rsp)
movw $0x46, (%rax)
leaq 0x2(%rax), %rdi
movq %r14, %rsi
callq 0x2b163
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ada4
movl %eax, %ebx
movq (%r14), %rdi
testq %rdi, %rdi
je 0x2942f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x29459
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movq %rbx, %rdi
callq 0x8ab0
nop
// File: /workspace/github_cpp_makefile_star2_O1/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 %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
cmpl $0x4, 0x484(%rdi)
ja 0x29489
movl $0x5, 0x7c(%rbx)
movb $0x1, %bl
jmp 0x295d0
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 0x294f2
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 0x294fd
movl %r15d, %eax
movl (%r14,%rax), %eax
movl %eax, 0xc(%rsp)
movl 0x480(%rbx), %eax
leal 0x5(%rax), %ecx
addl $0xfffffc05, %eax       # imm = 0xFFFFFC05
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x480(%rbx)
addl $-0x5, 0x484(%rbx)
movl $0x0, 0x7c(%rbx)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0x2ba66
testq %rax, %rax
je 0x29546
movq %rax, %r14
cmpq $0x10000, 0x10(%rax)    # imm = 0x10000
jb 0x2955f
leaq 0x10(%rsp), %rsi
movb $0x33, (%rsi)
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
movl %eax, %ebx
jmp 0x295d0
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x10, %edi
callq 0x8600
movq %rax, 0x10(%rsp)
movq %rax, 0x18(%rsp)
leaq 0x10(%rax), %rcx
movq %rcx, 0x20(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rax)
movq %rcx, 0x18(%rsp)
movw $0x46, (%rax)
leaq 0x2(%rax), %rdi
movq %r14, %rsi
callq 0x2b212
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ada4
movl %eax, %ebx
movq (%r14), %rdi
testq %rdi, %rdi
je 0x295d0
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movl %ebx, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x295fa
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movq %rbx, %rdi
callq 0x8ab0
// File: /workspace/github_cpp_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movl 0x480(%rdi), %eax
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x480(%rdi)
decl 0x484(%rdi)
leaq 0x8(%rdi), %rax
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
movl $0x98, %edi
addq 0x1b995(%rip), %rdi     # 0x45f70
leaq 0x8(%rsp), %r14
movq %rdi, (%r14)
movq %r14, %rdx
callq 0x2c682
movb $0x32, (%r14)
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x27fd2
addq $0x18, %rsp
popq %rbx
popq %r14
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::queue_packet(std::vector<char, std::allocator<char>>&&)
bool control_conn_t::queue_packet(std::vector<char> &&pkt) noexcept
{
    bool was_empty = outbuf.empty();
    
    if (was_empty) {
        outpkt_index = 0;
        // We can try sending the packet immediately:
        int wr = bp_sys::write(iob.get_watched_fd(), pkt.data(), 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 == pkt.size()) {
                // Ok, all written.
                return true;
            }
            outpkt_index = wr;
        }
    }
    
    try {
        outbuf.emplace_back(std::move(pkt));
        outbuf_size += pkt.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
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x4f0(%rdi), %r15
cmpq %r15, 0x4f0(%rdi)
setne %bpl
jne 0x2ae44
movl $0x0, 0x50c(%rbx)
movl 0x2c(%rbx), %edi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
subq %rsi, %rdx
callq 0x81e0
cmpl $-0x1, %eax
je 0x2adfb
movl %eax, %ecx
movq 0x8(%r14), %rdx
subq (%r14), %rdx
cmpq %rdx, %rcx
jne 0x2ae38
movb $0x1, %al
xorl %ecx, %ecx
jmp 0x2ae40
callq 0x8050
movl (%rax), %edi
cmpl $0x4, %edi
je 0x2ae3e
cmpl $0xb, %edi
je 0x2ae3e
cmpl $0x20, %edi
je 0x2ae32
callq 0x81d0
movq %rax, %r12
leaq 0xb6df(%rip), %rsi      # 0x364ff
movl $0x2, %edi
callq 0x2e63a
movq %r12, %rdi
callq 0x2e759
xorl %ecx, %ecx
xorl %eax, %eax
jmp 0x2ae40
movl %eax, 0x50c(%rbx)
movb $0x1, %cl
testb %cl, %cl
je 0x2ae61
movq %r15, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x2e198
movl 0x8(%r14), %eax
subl (%r14), %eax
addl %eax, 0x508(%rbx)
movb $0x1, %al
andb $0x1, %al
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x2, %edx
jne 0x2ae88
movq %rax, %rdi
callq 0x8210
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a50
movl %ebp, %eax
jmp 0x2ae61
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::allocate_service_handle(service_record*)
handle_t control_conn_t::allocate_service_handle(service_record *record)
{
    // Try to find a unique handle (integer) in a single pass. Since the map is ordered, we can search until
    // we find a gap in the handle values.
    handle_t candidate = 0;
    for (auto p : key_service_map) {
        if (p.first == candidate) ++candidate;
        else break;
    }

    bool is_unique = (service_key_map.find(record) == service_key_map.end());

    // The following operations perform allocation (can throw std::bad_alloc). If an exception occurs we
    // must undo any previous actions:
    if (is_unique) {
        record->add_listener(this);
    }
    
    try {
        key_service_map[candidate] = record;
        service_key_map.insert(std::make_pair(record, candidate));
    }
    catch (...) {
        if (is_unique) {
            record->remove_listener(this);
        }

        key_service_map.erase(candidate);
    }
    
    return candidate;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl $0x0, 0x4(%rsp)
movq 0x4d8(%rdi), %rax
leaq 0x4c8(%rdi), %r15
cmpq %r15, %rax
je 0x2aee2
movl $0x1, %r12d
leal -0x1(%r12), %ecx
cmpl 0x20(%rax), %ecx
jne 0x2aee2
movl %r12d, 0x4(%rsp)
movq %rax, %rdi
callq 0x8420
incl %r12d
cmpq %r15, %rax
jne 0x2aec3
movq 0x488(%rbx), %rsi
movq 0x490(%rbx), %rdi
xorl %r9d, %r9d
movq %r14, %rax
xorl %edx, %edx
divq %rdi
movq (%rsi,%rdx,8), %rax
testq %rax, %rax
je 0x2af42
movq (%rax), %r8
movq %rax, %r9
cmpq %r14, 0x8(%r8)
je 0x2af42
movq %rdx, %rcx
movq %r8, %r10
movq (%r8), %r8
testq %r8, %r8
je 0x2af3f
movq 0x8(%r8), %rsi
movq %rsi, %rax
xorl %edx, %edx
divq %rdi
movl $0x0, %r9d
cmpq %rcx, %rdx
jne 0x2af42
movq %r10, %r9
cmpq %r14, %rsi
jne 0x2af13
jmp 0x2af42
xorl %r9d, %r9d
testq %r9, %r9
je 0x2af51
cmpq $0x0, (%r9)
sete %bpl
jmp 0x2af54
movb $0x1, %bpl
leaq 0x4c0(%rbx), %r15
testb %bpl, %bpl
je 0x2af7c
leaq 0x18(%rsp), %rsi
movq %rbx, (%rsi)
leaq 0x150(%r14), %rdi
leaq 0x8(%rsp), %rdx
movq %rdi, (%rdx)
callq 0x2ca68
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x2be4a
leaq 0x488(%rbx), %rdi
movq %r14, (%rax)
movl 0x4(%rsp), %eax
leaq 0x8(%rsp), %rdx
movq %r14, (%rdx)
movl %eax, 0x8(%rdx)
xorl %esi, %esi
callq 0x2ddd6
movl 0x4(%rsp), %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2afbc
movq %rax, %rdi
callq 0x8210
testb %bpl, %bpl
je 0x2afd4
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2ba46
leaq 0x4(%rsp), %rsi
movq %r15, %rdi
callq 0x2bca4
callq 0x8a50
jmp 0x2afa9
movq %rax, %rbx
callq 0x8a50
movq %rbx, %rdi
callq 0x8ab0
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::check_dependents(service_record*, bool&)
bool control_conn_t::check_dependents(service_record *service, bool &had_dependents)
{
    std::vector<char> reply_pkt;
    size_t num_depts = 0;

    for (service_dep *dep : service->get_dependents()) {
        if (dep->dep_type == dependency_type::REGULAR && dep->holding_acq) {
            num_depts++;
            // find or allocate a service handle
            handle_t dept_handle = allocate_service_handle(dep->get_from());
            if (reply_pkt.empty()) {
                // packet type, size
                reply_pkt.reserve(1 + sizeof(size_t) + sizeof(handle_t));
                reply_pkt.resize(1 + sizeof(size_t));
                reply_pkt[0] = (char)cp_rply::DEPENDENTS;
            }
            auto old_size = reply_pkt.size();
            reply_pkt.resize(old_size + sizeof(handle_t));
            memcpy(reply_pkt.data() + old_size, &dept_handle, sizeof(dept_handle));
        }
    }

    if (num_depts != 0) {
        // There are affected dependents
        had_dependents = true;
        memcpy(reply_pkt.data() + 1, &num_depts, sizeof(num_depts));
        return queue_packet(std::move(reply_pkt));
    }

    had_dependents = false;
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %rbx
xorps %xmm0, %xmm0
movaps %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x130(%rsi), %r14
addq $0x130, %r15            # imm = 0x130
xorl %r13d, %r13d
cmpq %r15, %r14
je 0x2b0ae
movq 0x10(%r14), %rax
cmpl $0x0, 0x14(%rax)
jne 0x2b0a9
cmpb $0x1, 0x11(%rax)
jne 0x2b0a9
movq (%rax), %rsi
movq %rbx, %rdi
callq 0x2ae90
movl %eax, %ebp
movq (%rsp), %rax
cmpq 0x8(%rsp), %rax
jne 0x2b088
movl $0xd, %esi
movq %rsp, %rdi
callq 0x2b9b4
movl $0x9, %esi
movq %rsp, %rdi
callq 0x1c132
movq (%rsp), %rax
movb $0x41, (%rax)
movq 0x8(%rsp), %r12
subq (%rsp), %r12
leaq 0x4(%r12), %rsi
movq %rsp, %rdi
callq 0x1c132
incq %r13
movq (%rsp), %rax
movl %ebp, (%rax,%r12)
movq (%r14), %r14
jmp 0x2b03a
testq %r13, %r13
je 0x2b0d1
movq 0x20(%rsp), %rax
movb $0x1, (%rax)
movq %rsp, %rsi
movq (%rsi), %rax
movq %r13, 0x1(%rax)
movq %rbx, %rdi
callq 0x2ada4
movl %eax, %ebx
jmp 0x2b0db
movq 0x20(%rsp), %rax
movb $0x0, (%rax)
movb $0x1, %bl
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2b0f1
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b104
movq %rax, %rbx
movq (%rsp), %rdi
testq %rdi, %rdi
je 0x2b11d
movq 0x10(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movq %rbx, %rdi
callq 0x8ab0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: fill_status_buffer(char*, service_record*)
static void fill_status_buffer(char *buffer, service_record *service)
{
    buffer[0] = static_cast<char>(service->get_state());
    buffer[1] = static_cast<char>(service->get_target_state());

    pid_t proc_pid = service->get_pid();

    char b0 = service->is_waiting_for_console() ? 1 : 0;
    b0 |= service->has_console() ? 2 : 0;
    b0 |= service->was_start_skipped() ? 4 : 0;
    b0 |= service->is_marked_active() ? 8 : 0;
    b0 |= (proc_pid != -1) ? 16 : 0;
    buffer[2] = b0;
    buffer[3] = static_cast<char>(service->get_stop_reason());

    buffer[4] = 0; // (if exec failed, these are replaced with stage)
    buffer[5] = 0;

    if (proc_pid != -1) {
        memcpy(buffer + 6, &proc_pid, sizeof(proc_pid));
    }
    else {
        // These values only make sense in STOPPING/STOPPED, but we'll fill them in regardless:
        if (buffer[3] == (char)stopped_reason_t::EXECFAILED) {
            base_process_service *bsp = (base_process_service *)service;
            run_proc_err exec_err = bsp->get_exec_err_info();
            uint16_t stage = (uint16_t)exec_err.stage;
            memcpy(buffer + 4, &stage, 2);
            memcpy(buffer + 6, &exec_err.st_errno, sizeof(int));
        }
        else {
            auto exit_status_ps = service->get_exit_status();
            // There is no portable way to derive the correct exit status value corresponding
            // to any condition except for a clean exit (0) which is the most important anyway.
            // We'll use -1 for any other status although this may not be valid.
            int exit_status = exit_status_ps.did_exit_clean() ? 0 : -1;
            memcpy(buffer + 6, &exit_status, sizeof(exit_status));
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb 0x2c(%rsi), %al
movb %al, (%rdi)
movb 0x2d(%rsi), %al
movb %al, 0x1(%rdi)
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
cmpl $-0x1, %eax
setne %cl
movl 0x10c(%r14), %edx
movl %edx, %esi
shrb $0x5, %sil
movl %esi, %edi
andb $0x2, %dil
andb $0x1, %sil
movl %edx, %r8d
shrl $0xe, %r8d
andb $0x4, %r8b
shrl $0x5, %edx
andb $0x8, %dl
shlb $0x4, %cl
orb %sil, %cl
orb %dil, %cl
orb %r8b, %cl
orb %dl, %cl
movb %cl, 0x2(%rbx)
movb 0x1c4(%r14), %cl
movb %cl, 0x3(%rbx)
movw $0x0, 0x4(%rbx)
cmpl $-0x1, %eax
je 0x2b1da
movl %eax, 0x6(%rbx)
jmp 0x2b20a
cmpb $0x4, %cl
jne 0x2b1f3
movq 0x4f8(%r14), %rax
movw %ax, 0x4(%rbx)
shrq $0x20, %rax
movl %eax, 0x6(%rbx)
jmp 0x2b20a
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
shrq $0x20, %rax
xorl %ecx, %ecx
negq %rax
sbbl %ecx, %ecx
movl %ecx, 0x6(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: fill_status_buffer5(char*, service_record*)
static void fill_status_buffer5(char *buffer, service_record *service)
{
    buffer[0] = static_cast<char>(service->get_state());
    buffer[1] = static_cast<char>(service->get_target_state());

    pid_t proc_pid = service->get_pid();

    char b0 = service->is_waiting_for_console() ? 1 : 0;
    b0 |= service->has_console() ? 2 : 0;
    b0 |= service->was_start_skipped() ? 4 : 0;
    b0 |= service->is_marked_active() ? 8 : 0;
    b0 |= (proc_pid != -1) ? 16 : 0;
    buffer[2] = b0;
    buffer[3] = static_cast<char>(service->get_stop_reason());

    buffer[4] = 0; // (if exec failed, these are replaced with stage)
    buffer[5] = 0;

    if (proc_pid != -1) {
        memcpy(buffer + 6, &proc_pid, sizeof(proc_pid));
        unsigned remains = STATUS_BUFFER5_SIZE - (6 + sizeof(proc_pid));
        memset(buffer + 6 + sizeof(proc_pid), 0, remains);
    }
    else {
        // These values only make sense in STOPPING/STOPPED, but we'll fill them in regardless:
        if (buffer[3] == (char)stopped_reason_t::EXECFAILED) {
            base_process_service *bsp = (base_process_service *)service;
            run_proc_err exec_err = bsp->get_exec_err_info();
            uint16_t stage = (uint16_t)exec_err.stage;
            memcpy(buffer + 4, &stage, 2);
            memcpy(buffer + 6, &exec_err.st_errno, sizeof(int));
            unsigned remains = STATUS_BUFFER5_SIZE - (6 + sizeof(int));
            memset(buffer + 6 + sizeof(proc_pid), 0, remains);
        }
        else {
            auto exit_status = service->get_exit_status();
            int xs_si_code = exit_status.get_si_code();
            int xs_si_status = exit_status.get_si_status();
            memcpy(buffer + 6, &xs_si_code, sizeof(xs_si_code));
            memcpy(buffer + 6 + sizeof(xs_si_code), &xs_si_status, sizeof(xs_si_status));
        }
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movb 0x2c(%rsi), %al
movb %al, (%rdi)
movb 0x2d(%rsi), %al
movb %al, 0x1(%rdi)
movq (%rsi), %rax
movq %rsi, %rdi
callq *0x48(%rax)
movl 0x10c(%r14), %ecx
movl %ecx, %edx
shrb $0x5, %dl
movl %edx, %esi
andb $0x2, %sil
andb $0x1, %dl
movl %ecx, %edi
shrl $0xe, %edi
andb $0x4, %dil
shrl $0x5, %ecx
andb $0x8, %cl
cmpl $-0x1, %eax
setne %r8b
shlb $0x4, %r8b
orb %dl, %r8b
orb %sil, %r8b
orb %dil, %r8b
orb %cl, %r8b
xorl %ecx, %ecx
movb %r8b, 0x2(%rbx)
movb 0x1c4(%r14), %dl
movb %dl, 0x3(%rbx)
movw $0x0, 0x4(%rbx)
cmpl $-0x1, %eax
jne 0x2b2ac
cmpb $0x4, %dl
jne 0x2b29c
movq 0x4f8(%r14), %rax
movw %ax, 0x4(%rbx)
shrq $0x20, %rax
jmp 0x2b2ac
movq (%r14), %rax
movq %r14, %rdi
callq *0x50(%rax)
movq %rax, %rcx
shrq $0x20, %rcx
movl %eax, 0x6(%rbx)
movl %ecx, 0xa(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdi, %rbx
movl 0x8(%rdx), %eax
incl %eax
movw %ax, 0xe(%rsp)
movq (%rdx), %r14
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movzwl %ax, %esi
addq $0x5, %rsi
callq 0x2b9b4
leaq 0xd(%rsp), %rsi
movb $0x66, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x2ce2c
leaq 0xd(%rsp), %rsi
movb $0x5, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x2ce2c
leaq 0xd(%rsp), %rsi
movb %bpl, (%rsi)
leaq 0x10(%rsp), %rdi
callq 0x2ce2c
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
leaq 0x10(%rsp), %rcx
leaq 0xe(%rsp), %rdx
callq 0x2d9f0
leaq 0x10(%rsp), %rdi
movq 0x8(%rdi), %rsi
movzwl 0xe(%rsp), %ecx
addq %r14, %rcx
movq %r14, %rdx
callq 0x2d810
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2ada4
movq (%r14), %rdi
testq %rdi, %rdi
je 0x2b5b1
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
addq $0x28, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b5c6
jmp 0x2b5c6
jmp 0x2b5c6
jmp 0x2b5c6
jmp 0x2b5c6
movq %rdx, %r15
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2b5e3
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
movq %r14, %rdi
cmpl $0x2, %r15d
jne 0x2b601
callq 0x8210
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a50
jmp 0x2b5b1
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::data_ready()
bool control_conn_t::data_ready() noexcept
{
    int fd = iob.get_watched_fd();
    
    int r = rbuf.fill(fd);
    
    // Note file descriptor is non-blocking
    if (r == -1) {
        if (errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) {
            if (errno != ECONNRESET) {
                log(loglevel_t::WARN, "Error reading from control connection: ", strerror(errno));
            }
            return true;
        }
        return false;
    }
    
    if (r == 0) {
        return true;
    }
    
    // complete packet?
    while (rbuf.get_length() >= chklen) {
        try {
            if (!process_packet() || bad_conn_close) {
                return false;
            }
        }
        catch (std::bad_alloc &baexc) {
            do_oom_close();
            return false;
        }

        chklen = std::max(chklen, 1u);
    }

    if (rbuf.get_length() == rbuf.get_size()) {
        // Too big packet
        log(loglevel_t::WARN, "Received too-large control packet; dropping connection");
        bad_conn_close = true;
    }
    
    return false;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl 0x2c(%rdi), %esi
addq $0x80, %rdi
callq 0x2beae
movb $0x1, %bpl
cmpl $-0x1, %eax
je 0x2b68e
testl %eax, %eax
je 0x2b6e1
movl 0x484(%rbx), %eax
cmpl 0x7c(%rbx), %eax
jb 0x2b670
movq %rbx, %rdi
callq 0x27d3c
testb %al, %al
je 0x2b6df
cmpb $0x0, 0x78(%rbx)
jne 0x2b6df
movl 0x7c(%rbx), %ecx
cmpl $0x1, %ecx
adcl $0x0, %ecx
movl %ecx, 0x7c(%rbx)
movl 0x484(%rbx), %eax
cmpl %ecx, %eax
jae 0x2b640
cmpl $0x400, %eax            # imm = 0x400
jne 0x2b6df
leaq 0xaecf(%rip), %rsi      # 0x3654d
movl $0x2, %edi
callq 0x2e562
movb $0x1, 0x78(%rbx)
jmp 0x2b6df
callq 0x8050
movl (%rax), %edi
cmpl $0x4, %edi
je 0x2b6df
cmpl $0xb, %edi
je 0x2b6df
cmpl $0x68, %edi
je 0x2b6e1
callq 0x81d0
movq %rax, %rbx
leaq 0xae72(%rip), %rsi      # 0x36525
movl $0x2, %edi
callq 0x2e63a
movq %rbx, %rdi
callq 0x2e759
jmp 0x2b6e1
cmpl $0x2, %edx
jne 0x2b6ea
movq %rax, %rdi
callq 0x8210
movw $0x101, 0x78(%rbx)      # imm = 0x101
callq 0x8a50
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/control.cc
// Function: control_conn_t::send_data()
bool control_conn_t::send_data() noexcept
{
    if (outbuf.empty() && bad_conn_close) {
        if (oom_close) {
            // Send oom response
            char oomBuf[] = { (char)cp_rply::OOM };
            bp_sys::write(iob.get_watched_fd(), oomBuf, 1);
        }
        return true;
    }
    
    vector<char> & pkt = outbuf.front();
    char *data = pkt.data();
    int written = bp_sys::write(iob.get_watched_fd(), data + outpkt_index, pkt.size() - outpkt_index);
    if (written == -1) {
        if (errno == EPIPE) {
            // read end closed
            return true;
        }
        else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
            // spurious readiness notification?
            return false;
        }
        else {
            log(loglevel_t::ERROR, "Error writing to control connection: ", strerror(errno));
            return true;
        }
    }

    outpkt_index += written;
    if (outpkt_index == pkt.size()) {
        // We've finished this packet, move on to the next:
        outbuf_size -= pkt.size();
        outbuf.pop_front();
        outpkt_index = 0;
        if (oom_close) {
            // remain active, try to send cp_rply::OOM shortly
            return false;
        }
        if (outbuf.empty() && bad_conn_close) {
            return true;
        }
    }
    
    // more to send
    return false;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x4f0(%rdi), %r14
movq 0x4f0(%rdi), %r15
cmpq %r14, %r15
jne 0x2b73b
cmpb $0x1, 0x78(%rbx)
jne 0x2b73b
movb $0x1, %bpl
cmpb $0x1, 0x79(%rbx)
jne 0x2b7c2
movl 0x2c(%rbx), %edi
leaq 0xad59(%rip), %rsi      # 0x36485
movl $0x1, %edx
callq 0x81e0
jmp 0x2b7c2
movl 0x2c(%rbx), %edi
movl 0x50c(%rbx), %esi
addq 0x10(%r15), %rsi
movq 0x18(%r15), %rdx
subq %rsi, %rdx
callq 0x81e0
cmpl $-0x1, %eax
je 0x2b7a7
addl 0x50c(%rbx), %eax
movl %eax, 0x50c(%rbx)
movq 0x18(%r15), %rcx
subq 0x10(%r15), %rcx
cmpq %rax, %rcx
jne 0x2b7c0
subl %ecx, 0x508(%rbx)
movq 0x4f0(%rbx), %rsi
movq %r14, %rdi
callq 0x2e1ea
movl $0x0, 0x50c(%rbx)
cmpb $0x0, 0x79(%rbx)
jne 0x2b7c0
cmpq %r14, (%r14)
jne 0x2b7c0
movb $0x1, %bpl
cmpb $0x0, 0x78(%rbx)
je 0x2b7c0
jmp 0x2b7c2
callq 0x8050
movl (%rax), %edi
cmpl $0x4, %edi
je 0x2b7c0
movb $0x1, %bpl
cmpl $0x20, %edi
je 0x2b7c2
cmpl $0xb, %edi
jne 0x2b7cf
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
callq 0x81d0
movq %rax, %rbx
leaq 0xad21(%rip), %rsi      # 0x364ff
movl $0x3, %edi
callq 0x2e63a
movq %rbx, %rdi
callq 0x2e759
jmp 0x2b7c2
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1a41d(%rip), %rax     # 0x45c28
movq %rax, (%rdi)
leaq 0x1a443(%rip), %rax     # 0x45c58
movq %rax, 0x8(%rdi)
leaq 0x10(%rdi), %rsi
movl 0x2c(%rdi), %ebp
movq 0x68(%rdi), %rdi
movl %ebp, %edx
callq 0x2e21e
movl %ebp, %edi
callq 0x8b60
leaq 0x8(%rbx), %r14
movq 0x498(%rbx), %r15
testq %r15, %r15
je 0x2b853
movq 0x8(%r15), %rdi
movq %rbx, %rsi
callq 0x2ba46
movq (%r15), %r15
jmp 0x2b83d
leaq 0x488(%rbx), %r15
leaq 0x1d5af(%rip), %rdi     # 0x48e10
movq %r14, %rsi
callq 0x2bf02
leaq 0x1b32c(%rip), %rax     # 0x46b9c
decl (%rax)
leaq 0x4f0(%rbx), %rdi
callq 0xce70
addq $0x4c0, %rbx            # imm = 0x4C0
movq %rbx, %rdi
callq 0xceb4
movq %r15, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xcf04
movq %rax, %rdi
callq 0xb8be
nop
// 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_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 %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0xa0(%rdi), %edi
movl $0x2, %esi
xorl %ecx, %ecx
callq 0x8860
leaq 0xf(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0xdb22
movq %r14, %rdi
movq %rbx, %rsi
callq 0x2e270
movq %r14, %rdi
movq %r15, %rsi
callq 0xdb4e
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/../dasynq/include/dasynq.h
// Function: dasynq::v2::dprivate::event_dispatch<dasynq::v2::epoll_traits, dasynq::v2::default_traits<dasynq::null_mutex>>::issue_delete(dasynq::v2::dprivate::base_bidi_fd_watcher*)
void issue_delete(base_bidi_fd_watcher *watcher) noexcept
        {
            lock.lock();
            
            if (watcher->active) {
                watcher->deleteme = true;
                release_watcher(watcher);
            }
            else {
                dequeue_watcher(watcher);
                release_watcher(watcher);
                watcher->read_removed = true;
            }
            
            base_watcher *secondary = &(watcher->out_watcher);
            if (secondary->active) {
                secondary->deleteme = true;
                release_watcher(watcher);
            }
            else {
                dequeue_watcher(secondary);
                release_watcher(watcher);
                watcher->write_removed = true;
            }
            
            if (watcher->read_removed && watcher->write_removed) {
                lock.unlock();
                watcher->watch_removed();
            }
            else {
                lock.unlock();
            }
        }

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movb 0xc(%rsi), %al
testb $0x1, %al
jne 0x2e2a9
leaq 0x10(%rbx), %r15
movq 0x10(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x2e298
movq %r14, %rdi
callq 0xc67c
movq %r14, %rdi
movq %r15, %rsi
callq 0xc92c
orb $0x1, 0x48(%rbx)
jmp 0x2e2ba
orb $0x2, %al
movb %al, 0xc(%rbx)
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0xc92c
movb 0x34(%rbx), %al
testb $0x1, %al
jne 0x2e2e5
movq 0x38(%rbx), %rsi
cmpq $-0x1, %rsi
je 0x2e2d3
movq %r14, %rdi
callq 0xc67c
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0xc92c
orb $0x2, 0x48(%rbx)
jmp 0x2e2f6
orb $0x2, %al
movb %al, 0x34(%rbx)
leaq 0x10(%rbx), %rsi
movq %r14, %rdi
callq 0xc92c
movb 0x48(%rbx), %al
notb %al
testb $0x3, %al
jne 0x2e30d
movq (%rbx), %rax
movq %rbx, %rdi
popq %rbx
popq %r14
popq %r15
jmpq *0x20(%rax)
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: enable_console_log(bool)
void enable_console_log(bool enable) noexcept
{
    bool log_to_console = ! log_stream[DLOG_CONS].is_release_set();
    if (enable && ! log_to_console) {
        // Set non-blocking IO:
        int flags = fcntl(STDOUT_FILENO, F_GETFL, 0);
        fcntl(STDOUT_FILENO, F_SETFL, flags | O_NONBLOCK);
        // Activate watcher:
        log_stream[DLOG_CONS].init(STDOUT_FILENO);
        log_stream[DLOG_CONS].set_enabled(event_loop, true);
    }
    else if (! enable && log_to_console) {
        log_stream[DLOG_CONS].flush_for_release();
    }
}

// Assembly:
pushq %rax
movb 0x19a52(%rip), %al      # 0x47dca
movl %eax, %ecx
andb %dil, %cl
cmpb $0x1, %cl
jne 0x2e3d7
movl $0x1, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x8390
orl $0x800, %eax            # imm = 0x800
movl $0x1, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x8390
movl $0x1, 0x1aa31(%rip)     # 0x48de8
movb $0x0, 0x19a0c(%rip)     # 0x47dca
leaq 0x199db(%rip), %rdi     # 0x47da0
leaq 0x18664(%rip), %rsi     # 0x46a30
movl $0x1, %edx
popq %rax
jmp 0xd9d0
orb %dil, %al
jne 0x2e411
movb $0x1, 0x199e7(%rip)     # 0x47dca
movl 0x1a9ff(%rip), %esi     # 0x48de8
leaq 0x199b0(%rip), %rdi     # 0x47da0
callq 0x2ea04
cmpl $0x3, %eax
je 0x2e413
cmpl $0x1, %eax
jne 0x2e411
leaq 0x1999a(%rip), %rdi     # 0x47da0
leaq 0x18623(%rip), %rsi     # 0x46a30
xorl %edx, %edx
jmp 0x2e3d1
popq %rax
retq
movl 0x199a3(%rip), %edx     # 0x47dbc
leaq 0x18610(%rip), %rdi     # 0x46a30
leaq 0x19979(%rip), %rsi     # 0x47da0
popq %rax
jmp 0xda6a
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: discard_console_log_buffer()
void discard_console_log_buffer() noexcept
{
    // Only discard if more than a second has passed since we released the console.
    dasynq::time_val current_time;
    event_loop.get_time(current_time, clock_type::MONOTONIC);
    if (current_time - release_time >= dasynq::time_val(1, 0)) {
        log_stream[DLOG_CONS].discard();
    }
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsp, %rbx
movl $0x1, %edi
movq %rbx, %rsi
callq 0x8560
movq (%rbx), %rcx
movq 0x8(%rbx), %rdx
subq 0x18819(%rip), %rcx     # 0x46d38
movq 0x1881a(%rip), %rax     # 0x46d40
xorl %esi, %esi
cmpq %rax, %rdx
setl %sil
subq %rsi, %rcx
cmpq $0x1, %rcx
jg 0x2e551
leaq 0x3b9aca00(%rdx), %rsi
cmpq %rax, %rdx
cmovgeq %rdx, %rsi
cmpq $0x1, %rcx
jne 0x2e55c
subq %rax, %rsi
js 0x2e55c
movq $0x0, 0x1a884(%rip) # 0x48de0
addq $0x10, %rsp
popq %rbx
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: void do_log<char const*, char const*, char const*>(loglevel_t, bool, char const*, char const*, char const*)
static void do_log(loglevel_t lvl, bool to_cons, T ... args) noexcept
{
    log_current_line[DLOG_CONS] = (lvl >= log_level[DLOG_CONS]) && to_cons;
    log_current_line[DLOG_MAIN] = (lvl >= log_level[DLOG_MAIN]);
    push_to_log(DLOG_CONS, args...);
    
    if (log_current_line[DLOG_MAIN]) {
        if (log_format_syslog[DLOG_MAIN]) {
            char svcbuf[10];
            snprintf(svcbuf, 10, "<%d>", LOG_DAEMON | log_level_to_syslog_level(lvl));
            push_to_log(DLOG_MAIN, svcbuf, args...);
        }
        else {
            push_to_log(DLOG_MAIN, args...);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdx, %rbx
movl %edi, %ebp
cmpl %edi, 0x1814d(%rip)     # 0x466cc
setle %al
andb %sil, %al
cmpl %edi, 0x1813d(%rip)     # 0x466c8
movb %al, 0x1a868(%rip)      # 0x48df9
setle 0x1a860(%rip)           # 0x48df8
leaq 0x8031(%rip), %rsi      # 0x365d0
leaq 0x557a(%rip), %rcx      # 0x33b20
movl $0x1, %edi
callq 0x2ed69
cmpb $0x1, 0x1a841(%rip)     # 0x48df8
jne 0x2e60c
cmpb $0x1, 0x18111(%rip)     # 0x466d1
jne 0x2e615
movl $0x1a, %ecx
cmpl $0x3, %ebp
ja 0x2e5d8
movl %ebp, %eax
leaq 0x7feb(%rip), %rcx      # 0x365c0
movl (%rcx,%rax,4), %ecx
leaq 0x7ff9(%rip), %rdx      # 0x365d8
leaq 0x6(%rsp), %r14
movl $0xa, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
leaq 0x7fd6(%rip), %rsi      # 0x365d0
leaq 0x551f(%rip), %rcx      # 0x33b20
movq %r14, %rdi
movq %rbx, %rdx
callq 0x2ee55
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x7fb4(%rip), %rsi      # 0x365d0
leaq 0x54fd(%rip), %rcx      # 0x33b20
xorl %edi, %edi
movq %rbx, %rdx
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
jmp 0x2ed69
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: log_msg_begin(loglevel_t, char const*)
void log_msg_begin(loglevel_t lvl, const char *msg) noexcept
{
    log_current_line[DLOG_CONS] = lvl >= log_level[DLOG_CONS];
    log_current_line[DLOG_MAIN] = lvl >= log_level[DLOG_MAIN];

    // Prepend the syslog priority level string ("<N>") for the main log:
    if (log_current_line[DLOG_MAIN]) {
        if (log_format_syslog[DLOG_MAIN]) {
            char svcbuf[10];
            snprintf(svcbuf, 10, "<%d>", LOG_DAEMON | log_level_to_syslog_level(lvl));
            do_log_part(DLOG_MAIN, svcbuf);
        }
    }

    for (int i = 0; i < DLOG_NUM; i++) {
        do_log_part(i, "dinit: ");
        do_log_part(i, msg);
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl %edi, 0x18084(%rip)     # 0x466cc
setle 0x1a7aa(%rip)           # 0x48df9
movq %rsi, %rbx
cmpl %edi, 0x18070(%rip)     # 0x466c8
setle 0x1a799(%rip)           # 0x48df8
jg 0x2e6a5
cmpb $0x1, 0x18069(%rip)     # 0x466d1
jne 0x2e6a5
movl $0x1a, %ecx
cmpl $0x3, %edi
ja 0x2e680
movl %edi, %eax
leaq 0x7f43(%rip), %rcx      # 0x365c0
movl (%rcx,%rax,4), %ecx
leaq 0x7f51(%rip), %rdx      # 0x365d8
leaq 0x6(%rsp), %r14
movl $0xa, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x89e0
xorl %edi, %edi
movq %r14, %rsi
callq 0x2e6d2
xorl %ebp, %ebp
leaq 0x7f22(%rip), %r14      # 0x365d0
movl %ebp, %edi
movq %r14, %rsi
callq 0x2e6d2
movl %ebp, %edi
movq %rbx, %rsi
callq 0x2e6d2
incl %ebp
cmpl $0x1, %ebp
je 0x2e6ae
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: do_log_part(int, char const*)
static void do_log_part(int idx, const char *arg) noexcept
{
    if (log_current_line[idx]) {
        int amount = sum_length(arg);
        if (log_stream[idx].get_free() >= amount) {
            append(log_stream[idx], arg);
        }
        else {
            // we have to discard the message
            log_stream[idx].rollback_msg();
            log_current_line[idx] = false;
            log_stream[idx].mark_discarded();
        }
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movl %edi, %r14d
leaq 0x1a717(%rip), %r15     # 0x48df8
cmpb $0x1, (%r14,%r15)
jne 0x2e72a
movq %rsi, %rbx
movq %rsi, %rdi
callq 0x8230
imulq $0x1050, %r14, %rcx     # imm = 0x1050
leaq 0x1864f(%rip), %rdx     # 0x46d50
leaq (%rdx,%rcx), %rdi
movl $0x1000, %esi           # imm = 0x1000
subl 0x1040(%rcx,%rdx), %esi
cmpl %eax, %esi
jge 0x2e730
movl 0x1044(%rdi), %eax
movl %eax, 0x1040(%rdi)
movb $0x0, (%r14,%r15)
movb $0x1, 0x29(%rdi)
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rsi
popq %rbx
popq %r14
popq %r15
jmp 0x2ecd9
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: log_msg_end(char const*)
void log_msg_end(const char *msg) noexcept
{
    for (int i = 0; i < DLOG_NUM; i++) {
        do_log_part(i, msg);
        do_log_part(i, "\n");
        do_log_commit(i);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x185e2(%rip), %r14     # 0x46d50
xorl %r15d, %r15d
leaq 0x53a8(%rip), %r12      # 0x33b20
leaq 0x1a679(%rip), %rbp     # 0x48df8
leaq 0x182aa(%rip), %r13     # 0x46a30
movl %r15d, %edi
movq %rbx, %rsi
callq 0x2e6d2
movl %r15d, %edi
movq %r12, %rsi
callq 0x2e6d2
cmpb $0x1, (%r15,%rbp)
jne 0x2e7d2
cmpl $0x0, 0x1044(%r14)
movl 0x1040(%r14), %eax
movl %eax, 0x1044(%r14)
jne 0x2e7d2
cmpb $0x0, 0x2a(%r14)
jne 0x2e7d2
movq %r14, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xd9d0
incq %r15
addq $0x1050, %r14           # imm = 0x1050
cmpq $0x1, %r15
je 0x2e786
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: void do_log_main<char const*, char const*, char const*>(loglevel_t, char const*, char const*, char const*)
static void do_log_main(loglevel_t lvl, T ... args) noexcept
{
    if (lvl < log_level[DLOG_MAIN]) {
        return;
    }

    log_current_line[DLOG_CONS] = false;
    log_current_line[DLOG_MAIN] = true;

    if (log_format_syslog[DLOG_MAIN]) {
        char svcbuf[10];
        snprintf(svcbuf, 10, "<%d>", LOG_DAEMON | LOG_NOTICE);
        push_to_log(DLOG_MAIN, svcbuf, args...);
    }
    else {
        push_to_log(DLOG_MAIN, args...);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
cmpl %edi, 0x17e7c(%rip)     # 0x466c8
jg 0x2e89b
movq %rdx, %rbx
movq %rsi, %r14
movw $0x1, 0x1a59b(%rip)     # 0x48df8
cmpb $0x1, 0x17e6d(%rip)     # 0x466d1
jne 0x2e8a5
leaq 0x7d6b(%rip), %rdx      # 0x365d8
leaq 0x6(%rsp), %r15
movl $0xa, %esi
movq %r15, %rdi
movl $0x1d, %ecx
xorl %eax, %eax
callq 0x89e0
leaq 0x7d5a(%rip), %rsi      # 0x365e7
movq %r15, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x2ee55
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
leaq 0x7d3b(%rip), %rsi      # 0x365e7
xorl %edi, %edi
movq %r14, %rdx
movq %rbx, %rcx
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
jmp 0x2ed69
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: (anonymous namespace)::buffered_log_stream::watch_removed()
void buffered_log_stream::watch_removed() noexcept
{
    if (fd > STDERR_FILENO) {
        bp_sys::close(fd);
    }
    fd = -1;
    release = true; // prevent attempt to enable watch

    // Here we rely on there only being two logs, console and "main"; we can check if we are the
    // main log via identity:
    if (&log_stream[DLOG_MAIN] == this) {
        external_log_open = false;
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movl 0x1048(%rdi), %edi
cmpl $0x3, %edi
jl 0x2e9d6
callq 0x8b60
movl $0xffffffff, 0x1048(%rbx) # imm = 0xFFFFFFFF
movb $0x1, 0x2a(%rbx)
leaq 0x18365(%rip), %rax     # 0x46d50
cmpq %rax, %rbx
jne 0x2e9fa
leaq 0x181a1(%rip), %rax     # 0x46b98
movb $0x0, (%rax)
popq %rbx
retq
movq %rax, %rdi
callq 0xb8be
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: (anonymous namespace)::buffered_log_stream::release_console()
void buffered_log_stream::release_console()
{
    if (release) {
        int flags = fcntl(1, F_GETFL, 0);
        fcntl(1, F_SETFL, flags & ~O_NONBLOCK);
        if (services != nullptr) {
            services->pull_console_queue();
        }
        if (release) {
            // release still set, we didn't immediately get the console back; record the
            // time at which we released:
            event_loop.get_time(release_time, clock_type::MONOTONIC);
        }
    }
}

// Assembly:
cmpb $0x1, 0x2a(%rdi)
jne 0x2ecd8
pushq %rbx
movq %rdi, %rbx
movl $0x1, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x8390
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl $0x1, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x8390
movq 0x1a13a(%rip), %rdi     # 0x48df0
testq %rdi, %rdi
je 0x2ecc0
callq 0x239d6
cmpb $0x1, 0x2a(%rbx)
popq %rbx
jne 0x2ecd8
leaq 0x1806a(%rip), %rsi     # 0x46d38
movl $0x1, %edi
jmp 0x8560
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-log.cc
// Function: void push_to_log<char const*, char const*, char const*>(int, char const*, char const*, char const*)
static void push_to_log(int idx, T ... args) noexcept
{
    if (! log_current_line[idx]) return;
    int amount = sum_length(args...);
    if (log_stream[idx].get_free() >= amount) {
        append(log_stream[idx], args...);
        log_stream[idx].commit_msg();
    }
    else {
        log_stream[idx].mark_discarded();
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, %ebp
leaq 0x1a07b(%rip), %rax     # 0x48df8
cmpb $0x1, (%rbp,%rax)
jne 0x2ee24
movq %rcx, %rbx
movq %rdx, %r14
movq %rsi, %r15
movq %rsi, %rdi
callq 0x8230
movq %rax, %r12
movq %r14, %rdi
callq 0x8230
movq %rax, %r13
movq %rbx, %rdi
callq 0x8230
addl %r12d, %r13d
addl %eax, %r13d
imulq $0x1050, %rbp, %rax     # imm = 0x1050
leaq 0x17f8d(%rip), %rcx     # 0x46d50
leaq (%rcx,%rax), %r12
movl $0x1000, %edx           # imm = 0x1000
subl 0x1040(%rax,%rcx), %edx
cmpl %r13d, %edx
jge 0x2ede0
movb $0x1, 0x29(%r12)
jmp 0x2ee24
movq %r12, %rdi
movq %r15, %rsi
callq 0x2ecd9
movq %r12, %rdi
movq %r14, %rsi
callq 0x2ecd9
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2ecd9
cmpl $0x0, 0x1044(%r12)
movl 0x1040(%r12), %eax
movl %eax, 0x1044(%r12)
jne 0x2ee24
cmpb $0x0, 0x2a(%r12)
je 0x2ee33
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x17bf6(%rip), %rsi     # 0x46a30
movq %r12, %rdi
movl $0x1, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd9d0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-main.cc
// Function: main
int main(int argc, char **argv)
{
    try {
        return dinit_main(argc, argv);
    }
    catch (std::bad_alloc &badalloc) {
        std::cout << "dinit: out-of-memory during initialisation" << std::endl;
        return 1;
    }
    catch (std::system_error &syserr) {
        std::cout << "dinit: unexpected system error during initialisation: " << syserr.what() << std::endl;
        return 1;
    }
    catch (...) {
        std::cout << "dinit: unexpected error during initialisation" << std::endl;
        return 1;
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
callq 0x94bc
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rdx, %r14
movq %rax, %rdi
cmpl $0x3, %r14d
jne 0x2f020
callq 0x8210
movq 0x16f7f(%rip), %rdi     # 0x45f80
leaq 0x777b(%rip), %rsi      # 0x36783
movl $0x2a, %edx
callq 0x86c0
movq 0x16f67(%rip), %rdi     # 0x45f80
callq 0x82b0
jmp 0x2f08c
callq 0x8210
cmpl $0x2, %r14d
jne 0x2f068
movq %rax, %rbx
movq 0x16f4b(%rip), %rdi     # 0x45f80
leaq 0x7710(%rip), %rsi      # 0x3674c
movl $0x36, %edx
callq 0x86c0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x16f2a(%rip), %rdi     # 0x45f80
movq %rax, %rsi
callq 0x85e0
movq %rax, %rdi
callq 0x82b0
jmp 0x2f08c
movq 0x16f11(%rip), %rdi     # 0x45f80
leaq 0x76a8(%rip), %rsi      # 0x3671e
movl $0x2d, %edx
callq 0x86c0
movq 0x16ef9(%rip), %rdi     # 0x45f80
callq 0x82b0
callq 0x8a50
movl $0x1, %eax
jmp 0x2efe1
movq %rax, %rbx
callq 0x8a50
jmp 0x2f0b7
movq %rax, %rbx
callq 0x8a50
jmp 0x2f0b7
movq %rax, %rbx
callq 0x8a50
movq %rbx, %rdi
callq 0x8ab0
movq %rax, %rdi
callq 0xb8be
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/run-child-proc.cc
// Function: move_fd(int, int)
static int move_fd(int fd, int dest)
{
    if (fd == -1) return -1;
    if (fd == dest) return 0;

    if (dup2(fd, dest) == -1) {
        return -1;
    }

    close(fd);
    return 0;
}

// Assembly:
pushq %rbp
pushq %rbx
pushq %rax
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
cmpl $-0x1, %edi
je 0x2fcf6
movl %edi, %ebp
cmpl %esi, %edi
je 0x2fcf4
movl %ebp, %edi
callq 0x8590
cmpl $-0x1, %eax
je 0x2fcf6
movl %ebp, %edi
callq 0x8b60
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq