LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinitctl.cc
// Function: issue_load_service(int, char const*, bool)
static int issue_load_service(int socknum, const char *service_name, bool find_only)
{
    // Build buffer;
    srvname_len_t srvname_len = strlen(service_name);
    int bufsize = 3 + srvname_len;
    
    std::unique_ptr<char[]> ubuf(new char[bufsize]);
    auto buf = ubuf.get();

    buf[0] = (char)(find_only ? cp_cmd::FINDSERVICE : cp_cmd::LOADSERVICE);
    memcpy(buf + 1, &srvname_len, sizeof(srvname_len));
    memcpy(buf + 3, service_name, srvname_len);

    write_all_x(socknum, buf, bufsize);
    
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edx, %r12d
movq %rsi, %r15
movl %edi, %ebp
movq %rsi, %rdi
callq 0x4150
movq %rax, %r13
movzwl %r13w, %r14d
addl $0x3, %r14d
movq %r14, %rdi
callq 0x4030
movq %rax, %rbx
movb $0x2, %al
subb %r12b, %al
movb %al, (%rbx)
movw %r13w, 0x1(%rbx)
leaq 0x3(%rbx), %rdi
movzwl %r13w, %edx
movq %r15, %rsi
callq 0x4270
xorl %r12d, %r12d
movq %rbx, %r15
movl %r14d, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xd611
addl %eax, %r12d
movslq %eax, %rcx
addq %rcx, %r15
subl %eax, %r14d
xorl %ecx, %ecx
jmp 0xd632
callq 0x4040
movl $0x2, %ecx
cmpl $0x4, (%rax)
je 0xd632
testl %r12d, %r12d
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmovgl %r12d, %r13d
movl $0x1, %ecx
testb $0x1, %cl
jne 0xd63e
testl %r14d, %r14d
jg 0xd5ef
jmp 0xd641
movl %r13d, %r12d
cmpl $-0x1, %r12d
je 0xd65d
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x43a0
movl $0x4, %edi
callq 0x4190
movq %rax, %r14
callq 0x4040
movl (%rax), %eax
movl %eax, (%r14)
leaq 0xf4d5(%rip), %rsi      # 0x1cb50
movq %r14, %rdi
xorl %edx, %edx
callq 0x44d0
jmp 0xd687
movq %rax, %r14
movq %rbx, %rdi
callq 0x43a0
movq %r14, %rdi
callq 0x44f0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinitctl.cc
// Function: print_termination_details(int)
static void print_termination_details(int exit_status)
{
    using std::cout;

    if (WIFSIGNALED(exit_status)) {
        cout << "signalled - signal ";
        cout << WTERMSIG(exit_status);
    }
    else if (WIFEXITED(exit_status)) {
        cout << "exited - status ";
        cout << WEXITSTATUS(exit_status);
    }
    else {
        cout << "unknown reason";
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
andl $0x7f, %ebx
movl %ebx, %eax
shll $0x18, %eax
addl $0x1000000, %eax        # imm = 0x1000000
cmpl $0x2000000, %eax        # imm = 0x2000000
jl 0xde22
movq 0xf1a1(%rip), %r14      # 0x1cfa8
leaq 0x8792(%rip), %rsi      # 0x165a0
movl $0x13, %edx
movq %r14, %rdi
callq 0x4330
movq %r14, %rdi
movl %ebx, %esi
jmp 0xde6a
testl %ebx, %ebx
je 0xde45
movq 0xf17b(%rip), %rdi      # 0x1cfa8
leaq 0x8791(%rip), %rsi      # 0x165c5
movl $0xe, %edx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x4330
movl %edi, %ecx
movq 0xf15a(%rip), %r14      # 0x1cfa8
leaq 0x875f(%rip), %rsi      # 0x165b4
movl $0x10, %edx
movq %r14, %rdi
movl %ecx, %ebx
callq 0x4330
movzbl %bh, %esi
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x44e0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::signal_name_to_number(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
inline int signal_name_to_number(const std::string &signame) noexcept
{
    int sig = -1;
    for (const auto &signal: signal_to_int_map) {
        if (signal.first == signame) {
            sig = signal.second;
            break;
        }
    }
    return sig;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl $0x8, %r15d
leaq 0xe6f4(%rip), %r14      # 0x1cb90
movq -0x8(%r15,%r14), %rsi
movq %rbx, %rdi
callq 0x40b0
testl %eax, %eax
jne 0xe4b1
movl (%r15,%r14), %ebp
testl %eax, %eax
je 0xe4c5
leaq 0x10(%r15), %rax
cmpq $0xa8, %r15
movq %rax, %r15
jne 0xe49c
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-client.h
// Function: get_passed_cfd()
inline int get_passed_cfd()
{
    int socknum = -1;
    char * dinit_cs_fd_env = getenv("DINIT_CS_FD");
    if (dinit_cs_fd_env != nullptr) {
        char * endptr;
        long int cfdnum = strtol(dinit_cs_fd_env, &endptr, 10);
        if (endptr != dinit_cs_fd_env) {
            socknum = (int) cfdnum;
            // Set blocking mode (and validate file descriptor):
            errno = 0;
            int sock_flags = fcntl(socknum, F_GETFL, 0);
            if (sock_flags == -1 && errno != 0) {
                socknum = 0;
            }
            else {
                fcntl(socknum, F_SETFL, sock_flags & ~O_NONBLOCK);
            }
        }
    }
    return socknum;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
leaq 0x797b(%rip), %rdi      # 0x15ef8
callq 0x4380
testq %rax, %rax
je 0xe5e3
movq %rax, %r14
movq %rsp, %r15
movq %rax, %rdi
movq %r15, %rsi
movl $0xa, %edx
callq 0x4410
cmpq %r14, (%r15)
je 0xe5e3
movq %rax, %rbx
callq 0x4040
movq %rax, %r14
movl $0x0, (%rax)
xorl %ebp, %ebp
movl %ebx, %edi
movl $0x3, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x41f0
cmpl $-0x1, %eax
je 0xe5f5
andl $0xfffff7ff, %eax       # imm = 0xFFFFF7FF
movl %ebx, %edi
movl $0x4, %esi
movl %eax, %edx
xorl %eax, %eax
callq 0x41f0
movl %ebx, %ebp
jmp 0xe5e8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x0, (%r14)
jne 0xe5e8
jmp 0xe5ca
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-client.h
// Function: write_all_x(int, void const*, int)
inline int write_all(int fd, const void *buf, int count)
{
    const char *cbuf = static_cast<const char *>(buf);
    int w = 0;
    while (count > 0) {
        int r = write(fd, cbuf, count);
        if (r == -1) {
            if (errno == EINTR) continue;
            return (w > 0) ? w : r;
        }
        w += r;
        cbuf += r;
        count -= r;
    }
    return w;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
testl %edx, %edx
jle 0xed8d
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %ebp
xorl %r15d, %r15d
movl %ebx, %edx
movl %ebp, %edi
movq %r14, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xed58
addl %eax, %r15d
movslq %eax, %rcx
addq %rcx, %r14
subl %eax, %ebx
xorl %ecx, %ecx
jmp 0xed79
callq 0x4040
movl $0x2, %ecx
cmpl $0x4, (%rax)
je 0xed79
testl %r15d, %r15d
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmovgl %r15d, %r12d
movl $0x1, %ecx
testb $0x1, %cl
jne 0xed84
testl %ebx, %ebx
jg 0xed38
jmp 0xed87
movl %r12d, %r15d
cmpl $-0x1, %r15d
je 0xed96
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0xdd9d(%rip), %rsi      # 0x1cb50
movq %rbx, %rdi
xorl %edx, %edx
callq 0x44d0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-client.h
// Function: fill_buffer_to(cpbuffer<1024u>&, int, int)
inline void fill_buffer_to(cpbuffer_t &buf, int fd, int rlength)
{
    do {
        int r = buf.fill_to(fd, rlength);
        if (r == -1) {
            if (errno != EINTR) {
                throw cp_read_exception(errno);
            }
        }
        else if (r == 0) {
            throw cp_read_exception(0);
        }
        else {
            return;
        }
    }
    while (true);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movl $0x1, %r12d
cmpl %ebx, 0x404(%r14)
jae 0xefa0
movq %r14, %rdi
movl %ebp, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %r15d
movl %r15d, %r12d
jg 0xef7c
cmpl $-0x1, %r12d
je 0xefad
testl %r12d, %r12d
jne 0xefb7
jmp 0xefc6
callq 0x4040
cmpl $0x4, (%rax)
jne 0xefd8
cmpl $-0x1, %r12d
je 0xef7c
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xefea
movq %rax, %r15
movl $0x4, %edi
callq 0x4190
movl (%r15), %ecx
movl %ecx, (%rax)
leaq 0xdb4f(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-client.h
// Function: wait_for_info(cpbuffer<1024u>&, int)
inline void wait_for_info(cpbuffer_t &rbuffer, int fd)
{
    fill_buffer_to(rbuffer, fd, 2);

    if (rbuffer[0] < 100) {
        throw cp_read_exception(0);
    }

    int pktlen = (unsigned char) rbuffer[1];
    fill_buffer_to(rbuffer, fd, pktlen);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %esi, %ebx
movq %rdi, %r14
movl $0x1, %ebp
cmpl $0x1, 0x404(%r14)
ja 0xf73a
movq %r14, %rdi
movl %ebx, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %r15d
movl %r15d, %ebp
jg 0xf716
cmpl $-0x1, %ebp
je 0xf748
testl %ebp, %ebp
jne 0xf756
jmp 0xf7d7
callq 0x4040
cmpl $0x4, (%rax)
jne 0xf7e9
cmpl $-0x1, %ebp
je 0xf716
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x63, (%r14,%rcx)
jle 0xf7d7
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movzbl (%r14,%rax), %ebp
movl $0x1, %r12d
cmpl %ebp, 0x404(%r14)
jae 0xf7b1
movq %r14, %rdi
movl %ebx, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %r15d
movl %r15d, %r12d
jg 0xf78d
cmpl $-0x1, %r12d
je 0xf7be
testl %r12d, %r12d
jne 0xf7c8
jmp 0xf7d7
callq 0x4040
cmpl $0x4, (%rax)
jne 0xf7e9
cmpl $-0x1, %r12d
je 0xf78d
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xf7fb
movq %rax, %r15
movl $0x4, %edi
callq 0x4190
movl (%r15), %ecx
movl %ecx, (%rax)
leaq 0xd33e(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/file-input-stack.h
// Function: file_input_stack::push(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, dio::istream&&, int)
void push(std::string file_name, dio::istream &&file, int parent_dir_fd)
    {
        try {
            input_stack.emplace(std::move(file), std::move(file_name), 0, parent_dir_fd);
        }
        catch (...) {
            // we accept ownership of 'parent_dir_fd' at call:
            bp_sys::close(parent_dir_fd);
            throw;
        }
    }

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rsi, %rax
leaq 0x8(%rsp), %r8
movl %ecx, (%r8)
leaq 0xc(%rsp), %rcx
movl $0x0, (%rcx)
movq %rdx, %rsi
movq %rax, %rdx
callq 0x111fa
addq $0x10, %rsp
popq %rbx
retq
movq %rax, %rdi
callq 0x4130
movl 0x8(%rsp), %edi
callq 0x4560
callq 0x4440
movq %rax, %rbx
callq 0x44b0
movq %rbx, %rdi
callq 0x44f0
movq %rax, %rdi
callq 0xe564
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-util.h
// Function: combine_paths[abi:cxx11](string_view, char const*)
inline std::string combine_paths(string_view p1, const char *p2)
{
    if (*p2 == 0) return (std::string)p1;
    if (p1.empty()) return std::string(p2);

    if (p2[0] == '/') return p2;

    if (*(p1.rbegin()) == '/') return (std::string)p1 + p2;
    return (std::string)p1 + '/' + p2;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movb (%rcx), %al
testb %al, %al
je 0x10275
movq %rcx, %r14
testq %rdx, %rdx
je 0x1025a
cmpb $0x2f, %al
jne 0x10296
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq %r14, %rdi
callq 0x4150
leaq (%rax,%r14), %rdx
movq %rbx, %rdi
movq %r14, %rsi
jmp 0x10282
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xec92
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
leaq (%rsi,%rdx), %rax
cmpb $0x2f, -0x1(%rsi,%rdx)
jne 0x102e8
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %rax, %rdx
callq 0xec92
movq %r15, %rdi
movq %r14, %rsi
callq 0x4540
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x10342
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x10348
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x28(%rsp), %r15
movq %r15, %rdi
movq %rax, %rdx
callq 0xec92
movq 0x8(%r15), %rsi
movl $0x1, %ecx
movq %r15, %rdi
xorl %edx, %edx
movl $0x2f, %r8d
callq 0x4510
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x10377
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x1037e
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10287
movq 0x18(%rsp), %rsi
jmp 0x1040b
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x8(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %r14, %rsi
callq 0x4540
leaq 0x10(%rbx), %rdx
movq %rdx, (%rbx)
movq (%rax), %rsi
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rsi
je 0x103c4
movq %rsi, (%rbx)
movq (%rcx), %rdx
movq %rdx, 0x10(%rbx)
jmp 0x103ca
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq 0x8(%rax), %rdx
movq %rdx, 0x8(%rbx)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x103f8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x10287
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0x10287
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x10437
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0x10437
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0x10462
movq 0x38(%rsp), %rsi
jmp 0x1045a
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10462
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
movq %rbx, %rdi
callq 0x44f0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-client.h
// Function: read_string[abi:cxx11](int, cpbuffer<1024u>&, unsigned int)
inline std::string read_string(int socknum, cpbuffer_t &rbuffer, uint32_t length)
{
    int rb_len = rbuffer.get_length();
    if (uint32_t(rb_len) >= length) {
        std::string r = rbuffer.extract_string(0, length);
        rbuffer.consume(length);
        return r;
    }

    std::string r = rbuffer.extract_string(0, rb_len);
    uint32_t rlen = length - rb_len;
    uint32_t clen;
    do {
        rbuffer.reset();
        fill_some(rbuffer, socknum);
        char *bptr = rbuffer.get_ptr(0);
        clen = rbuffer.get_length();
        clen = std::min(clen, rlen);
        r.append(bptr, clen);
        rlen -= clen;
    } while (rlen > 0);

    rbuffer.consume(clen);

    return r;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %ecx, %r15d
movq %rdx, %r14
movq %rdi, %rbx
movl 0x404(%rdx), %ecx
movl %r15d, %r12d
subl %ecx, %r12d
jbe 0x10528
movl %esi, %ebp
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x105ce
movq $0x0, 0x400(%r14)
movq %r14, %rdi
movl %ebp, %esi
callq 0xeffc
testl %eax, %eax
je 0x10574
jg 0x104e4
callq 0x4040
cmpl $0x4, (%rax)
je 0x104c1
jmp 0x10586
movl 0x400(%r14), %eax
movl 0x404(%r14), %r13d
leal -0x400(%rax), %esi
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %esi
addq %r14, %rsi
cmpl %r13d, %r12d
movl %r13d, %r15d
cmovbl %r12d, %r15d
movq %rbx, %rdi
movq %r15, %rdx
callq 0x4070
movl %r12d, %eax
subl %r15d, %eax
cmpl %r13d, %r12d
movl %eax, %r12d
ja 0x104b6
jmp 0x10538
movq %rbx, %rdi
movq %r14, %rsi
xorl %edx, %edx
movl %r15d, %ecx
callq 0x105ce
movl 0x400(%r14), %eax
leal (%rax,%r15), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%rax,%r15), %eax
cmovbl %ecx, %eax
movl %eax, 0x400(%r14)
subl %r15d, 0x404(%r14)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0x10598
movq %rax, %r15
movl $0x4, %edi
callq 0x4190
movl (%r15), %ecx
movl %ecx, (%rax)
leaq 0xc5a1(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
jmp 0x105ab
movq %rax, %r14
movq (%rbx), %rdi
addq $0x10, %rbx
cmpq %rbx, %rdi
je 0x105c5
movq (%rbx), %rsi
incq %rsi
callq 0x42f0
movq %r14, %rdi
callq 0x44f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/cpbuffer.h
// Function: cpbuffer<1024u>::extract_string[abi:cxx11](unsigned int, unsigned int)
std::string extract_string(unsigned index, unsigned length)
    {
        index += cur_idx;
        if (index >= SIZE) index -= SIZE;
        if (index + length > SIZE) {
            std::string r(buf + index, SIZE - index);
            r.insert(r.end(), buf, buf + length - (SIZE - index));
            return r;
        }
        else {
            return std::string(buf + index, length);
        }
    }

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movl %ecx, %r15d
movq %rsi, %r14
movl 0x400(%rsi), %eax
leal (%rax,%rdx), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%rax,%rdx), %eax
cmovbl %ecx, %eax
movq %rdi, %rbx
leal (%rax,%r15), %ecx
addq %rax, %rsi
cmpl $0x401, %ecx            # imm = 0x401
jb 0x1063d
movl $0x400, %r13d           # imm = 0x400
subl %eax, %r13d
leaq 0x10(%rbx), %r12
movq %r12, (%rbx)
leaq (%rsi,%r13), %rdx
movq %rbx, %rdi
callq 0xec92
movq 0x8(%rbx), %rsi
movl %r15d, %r8d
subq %r13, %r8
movq %rbx, %rdi
xorl %edx, %edx
movq %r14, %rcx
callq 0x4320
jmp 0x10652
movl %r15d, %edx
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xec92
movq %rbx, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x10676
movq (%r12), %rsi
incq %rsi
callq 0x42f0
movq %r14, %rdi
callq 0x44f0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-util.h
// Function: readlink_at_str(int, char const*)
inline std::pair<bool, std::vector<char>> readlink_at_str(int dirfd, const char *path) noexcept
{
    struct stat sb;
    if (bp_sys::fstatat(dirfd, path, &sb, AT_SYMLINK_NOFOLLOW) == -1) {
        return {false, {}};
    }

    size_t vec_size = sb.st_size + 1; // add one for nul terminator

    try {
        std::vector<char> vec_str(vec_size);

        try_read_link:

        ssize_t r = bp_sys::readlinkat(dirfd, path, vec_str.data(), vec_size);

        if (r < 0) {
            return {false, {}};
        }

        if ((size_t)r > vec_size) {
            // Our size estimate was off (link changed?), try again
            vec_size = r;
            vec_str.resize(vec_size);
            goto try_read_link;
        }

        // shrink, or even expand (append nul) as necessary
        vec_str.resize(r + 1);

        return {true, std::move(vec_str)};
    }
    catch (std::bad_alloc &) {
        errno = ENOMEM;
        return {false, {}};
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rdx, %rax
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x38(%rsp), %rdx
movl %esi, %edi
movq %rax, 0x30(%rsp)
movq %rax, %rsi
movl $0x100, %ecx            # imm = 0x100
callq 0x40c0
cmpl $-0x1, %eax
je 0x10a00
movq 0x68(%rsp), %r13
incq %r13
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rdx
movq %r13, %rsi
callq 0x10ab2
leaq 0x8(%rbx), %r12
movq 0x10(%rsp), %rdx
movl %ebp, %edi
movq 0x30(%rsp), %rsi
movq %r13, %rcx
callq 0x4080
testq %rax, %rax
js 0x10974
movq %rax, %r15
cmpq %r13, %rax
jbe 0x1099c
movb $0x1, %r14b
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x10b12
movq %r15, %r13
jmp 0x109de
movb $0x0, (%rbx)
xorps %xmm0, %xmm0
movups %xmm0, (%r12)
movq $0x0, 0x10(%r12)
movq %r12, %rdi
xorl %esi, %esi
callq 0x10b3e
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
jmp 0x109db
incq %r15
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x10b12
movb $0x1, (%rbx)
movq 0x10(%rsp), %rax
movq %rax, 0x8(%rbx)
movq 0x18(%rsp), %rax
movq %rax, 0x10(%rbx)
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rbx)
xorps %xmm0, %xmm0
movaps %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
xorl %r14d, %r14d
testb %r14b, %r14b
jne 0x1093e
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x10a25
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
jmp 0x10a25
movb $0x0, (%rbx)
leaq 0x8(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movq $0x0, 0x18(%rbx)
xorl %esi, %esi
callq 0x10b3e
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
movq %rbx, %rax
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r15
movq %rax, %r14
jmp 0x10a61
jmp 0x10a44
movq %rdx, %r15
movq %rax, %r14
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x10a61
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x42f0
movq %r14, %rdi
cmpl $0x2, %r15d
jne 0x10aac
callq 0x4130
callq 0x4040
movl $0xc, (%rax)
movb $0x0, (%rbx)
leaq 0x8(%rbx), %rdi
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rbx)
movq $0x0, 0x18(%rbx)
xorl %esi, %esi
callq 0x10b3e
movq 0x8(%rbx), %rax
movq %rax, 0x10(%rbx)
callq 0x44b0
jmp 0x10a25
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/dinit-util.h
// Function: combine_paths[abi:cxx11](string_view, string_view)
inline std::string combine_paths(string_view p1, string_view p2)
{
    if (p2.empty()) return (std::string)p1;
    if (p1.empty()) return (std::string)p2;

    if (p2[0] == '/') return p2;

    if (*(p1.rbegin()) == '/') return (std::string)p1 + p2;
    return (std::string)p1 + '/' + p2;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
testq %r8, %r8
je 0x10e90
movq %r8, %r14
movq %rcx, %r15
testq %rdx, %rdx
je 0x10e7b
cmpb $0x2f, (%r15)
jne 0x10eb4
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
addq %r15, %r14
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
jmp 0x10e9d
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xec92
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq (%rsi,%rdx), %rax
cmpb $0x2f, -0x1(%rsi,%rdx)
jne 0x10f1b
leaq 0x18(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x8(%rsp), %r12
movq %r12, %rdi
movq %rax, %rdx
callq 0xec92
leaq 0x10(%rbx), %rbp
movq %rbp, (%rbx)
movq (%r12), %rsi
movq 0x8(%r12), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x11564
movq 0x8(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
movq %r15, %rcx
movq %r14, %r8
callq 0x4320
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x10ea2
movq 0x18(%rsp), %rsi
jmp 0x10ff0
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x28(%rsp), %r12
movq %r12, %rdi
movq %rax, %rdx
callq 0xec92
movq 0x8(%r12), %rsi
movl $0x1, %ecx
movq %r12, %rdi
xorl %edx, %edx
movl $0x2f, %r8d
callq 0x4510
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x10f76
movq %rdx, 0x8(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x18(%rsp)
jmp 0x10f7e
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x10(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq 0x10(%rbx), %rbp
movq %rbp, (%rbx)
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x11564
movq 0x8(%rbx), %rsi
movq %rbx, %rdi
xorl %edx, %edx
movq %r15, %rcx
movq %r14, %r8
callq 0x4320
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x10fdd
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x10ea2
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0x10ea2
movq %rax, %r14
movq (%rbx), %rdi
cmpq %rbp, %rdi
je 0x11019
movq (%rbp), %rsi
incq %rsi
callq 0x42f0
jmp 0x11019
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x1104e
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0x1104e
movq %rax, %r14
movq (%rbx), %rdi
cmpq %rbp, %rdi
je 0x11062
movq (%rbp), %rsi
incq %rsi
callq 0x42f0
jmp 0x11062
movq %rax, %r14
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0x11079
movq 0x38(%rsp), %rsi
jmp 0x11071
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r13, %rdi
je 0x11079
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42f0
movq %r14, %rdi
callq 0x44f0
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/options-processing.cc
// Function: service_dir_opt::get_user_home()
const char *service_dir_opt::get_user_home()
{
    if (user_home_path == nullptr) {
        user_home_path = getenv("HOME");
        if (user_home_path == nullptr) {
            struct passwd * pwuid_p = getpwuid(getuid());
            if (pwuid_p != nullptr) {
                user_home_path = pwuid_p->pw_dir;
            }
        }
    }
    return user_home_path;
}

// Assembly:
cmpq $0x0, 0xb320(%rip)      # 0x1d660
jne 0x1237b
pushq %rax
leaq 0x514c(%rip), %rdi      # 0x17496
callq 0x4380
movq %rax, 0xb30a(%rip)      # 0x1d660
testq %rax, %rax
jne 0x12377
callq 0x41a0
movl %eax, %edi
callq 0x4350
testq %rax, %rax
je 0x12377
movq 0x20(%rax), %rax
movq %rax, 0xb2e9(%rip)      # 0x1d660
addq $0x8, %rsp
movq 0xb2de(%rip), %rax      # 0x1d660
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::put(char const*, unsigned long)
int ostream::current_state() noexcept
{
    int bits = 0;
    if (!buf) bits |= io_states::buffer_fail_bit;
    if (io_error) bits |= io_states::io_fail_bit;
    return bits;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x0, 0x10(%rdi)
movq $-0x1, %r13
jne 0x1328d
movq %rdi, %r12
cmpq $0x0, 0x8(%rdi)
je 0x1328d
movq %rdx, %rbx
testq %rdx, %rdx
je 0x1322f
movq %rsi, %r14
movq %rbx, %r15
movq 0x8(%r12), %rbp
movl 0x4004(%rbp), %eax
movl $0x4000, %ecx           # imm = 0x4000
subl %eax, %ecx
cmpq %rcx, %r15
jbe 0x13234
movl 0x4000(%rbp), %edi
leal -0x4000(%rdi), %esi
cmpl $0x4000, %edi           # imm = 0x4000
cmovbl %edi, %esi
leaq (%rsi,%rbp), %rdx
movq %rdx, (%rsp)
testq %rax, %rax
je 0x13149
leaq 0x4000(%rbp), %rcx
leal (%rdi,%rax), %r8d
cmpl $0x4000, %r8d           # imm = 0x4000
leal -0x4000(%rdi,%rax), %edi
cmovbl %r8d, %edi
leal (%rdi,%rbp), %r8d
cmpl %esi, %edi
cmoval %r8d, %ecx
subl %edx, %ecx
jmp 0x1314b
xorl %ecx, %ecx
movq %rcx, 0x8(%rsp)
cmpl %ecx, %eax
jne 0x13161
leaq 0x10(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, (%rax)
jmp 0x1316e
movq %rbp, 0x10(%rsp)
subq %rcx, %rax
movq %rax, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %r15, 0x28(%rsp)
movl (%r12), %edi
movq %rsp, %rsi
movl $0x3, %edx
callq 0x14442
testl %eax, %eax
js 0x131c9
movslq %eax, %rsi
movq 0x8(%r12), %rcx
movl 0x4004(%rcx), %edx
subq %rdx, %rsi
jge 0x131e8
movl 0x4000(%rcx), %esi
leal (%rsi,%rax), %edi
cmpl $0x4000, %edi           # imm = 0x4000
leal -0x4000(%rsi,%rax), %esi
cmovbl %edi, %esi
movl %esi, 0x4000(%rcx)
subl %eax, %edx
movl %edx, 0x4004(%rcx)
jmp 0x13219
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%r12)
movq %rbx, %r13
subq %r15, %r13
movq $-0x1, %rax
cmoveq %rax, %r13
jmp 0x13223
movl 0x4000(%rcx), %eax
leal (%rax,%rdx), %edi
cmpl $0x4000, %edi           # imm = 0x4000
leal -0x4000(%rax,%rdx), %eax
cmovbl %edi, %eax
movl %eax, 0x4000(%rcx)
movl $0x0, 0x4004(%rcx)
subq %rsi, %r15
je 0x1321d
addq %rsi, %r14
movb $0x1, %al
jmp 0x13225
xorl %r15d, %r15d
movq %rbx, %r13
xorl %eax, %eax
testb %al, %al
jne 0x130e1
jmp 0x1328d
xorl %r13d, %r13d
jmp 0x1328d
movl 0x4000(%rbp), %ecx
leal (%rcx,%rax), %edx
movl $0x4000, %r12d          # imm = 0x4000
cmpl %r12d, %edx
leal -0x4000(%rcx,%rax), %edi
cmovbl %edx, %edi
addl %r15d, %eax
movl %eax, 0x4004(%rbp)
subl %edi, %r12d
addq %rbp, %rdi
cmpl %r15d, %r12d
movl %r15d, %edx
cmovbl %r12d, %edx
movq %r14, %rsi
callq 0x4270
subl %r12d, %r15d
jbe 0x1328a
movl %r12d, %eax
addq %rax, %r14
movq %rbp, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4270
movq %rbx, %r13
movq %r13, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::throw_exception_on(int)
void ostream::throw_exception_on(const int states)
{
    if ((states & io_states::buffer_fail_bit) && buffer_failure()) {
        throw std::bad_alloc();
    }
    if ((states & io_states::io_fail_bit) && io_failure()) {
        throw iostream_system_err(io_failure());
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testb $0x2, %sil
je 0x132cb
cmpq $0x0, 0x8(%rbx)
je 0x132d9
testb $0x8, %sil
je 0x132d7
cmpl $0x0, 0x10(%rbx)
jne 0x13307
popq %rbx
retq
movl $0x8, %edi
callq 0x4190
movq 0x9cae(%rip), %rcx      # 0x1cf98
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x9cb8(%rip), %rsi      # 0x1cfb0
movq 0x9c89(%rip), %rdx      # 0x1cf88
movq %rax, %rdi
callq 0x44d0
movl $0x4, %edi
callq 0x4190
movl 0x10(%rbx), %ecx
movl %ecx, (%rax)
leaq 0x9a1b(%rip), %rsi      # 0x1cd38
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::open_nx(char const*)
bool ostream::open_nx(const char *path) noexcept
{
    fd = bp_sys::open(path, O_WRONLY);
    if (fd < 0) {
        io_error = errno;
        return false;
    }

    buf = std::unique_ptr<streambuf>(new(std::nothrow) streambuf);
    if (!buf) {
        bp_sys::close(fd);
        fd = -1;
        return false;
    }

    return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
movl $0x1, %esi
xorl %eax, %eax
callq 0x4250
movl %eax, (%rbx)
testl %eax, %eax
js 0x13372
movq 0x9c22(%rip), %rsi      # 0x1cf78
movl $0x4008, %edi           # imm = 0x4008
callq 0x4580
testq %rax, %rax
je 0x1337e
movq $0x0, 0x4000(%rax)
jmp 0x13380
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
jmp 0x133ad
xorl %eax, %eax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x13397
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
movb $0x1, %al
cmpq $0x0, 0x8(%rbx)
jne 0x133af
movl (%rbx), %edi
callq 0x4560
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
xorl %eax, %eax
popq %rbx
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::open_nx(char const*, int)
bool ostream::open_nx(const char *path, const int flags) noexcept
{
    buf = std::unique_ptr<streambuf>(new(std::nothrow) streambuf);
    if (!buf) return false;

    fd = bp_sys::open(path, O_WRONLY | flags);
    if (fd < 0) {
        io_error = errno;
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x9b8d(%rip), %rsi      # 0x1cf78
movl $0x4008, %edi           # imm = 0x4008
callq 0x4580
testq %rax, %rax
je 0x13407
movq $0x0, 0x4000(%rax)
jmp 0x13409
xorl %eax, %eax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x13420
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
cmpq $0x0, 0x8(%rbx)
je 0x1344a
orl $0x1, %ebp
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x4250
movl %eax, %ecx
movl %eax, (%rbx)
movb $0x1, %al
testl %ecx, %ecx
jns 0x1344c
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::open_nx(char const*, int, unsigned int)
bool ostream::open_nx(const char *path, const int flags, const mode_t mode) noexcept
{
    buf = std::unique_ptr<streambuf>(new(std::nothrow) streambuf);
    if (!buf) return false;

    fd = bp_sys::open(path, O_WRONLY | flags, mode);
    if (fd < 0) {
        io_error = errno;
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %ecx, %ebp
movl %edx, %r14d
movq %rsi, %r15
movq %rdi, %rbx
movq 0x9ae7(%rip), %rsi      # 0x1cf78
movl $0x4008, %edi           # imm = 0x4008
callq 0x4580
testq %rax, %rax
je 0x134ad
movq $0x0, 0x4000(%rax)
jmp 0x134af
xorl %eax, %eax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x134c6
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
cmpq $0x0, 0x8(%rbx)
je 0x134f4
orl $0x1, %r14d
movq %r15, %rdi
movl %r14d, %esi
movl %ebp, %edx
xorl %eax, %eax
callq 0x4250
movl %eax, %ecx
movl %eax, (%rbx)
movb $0x1, %al
testl %ecx, %ecx
jns 0x134f6
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::close_nx()
bool ostream::close_nx() noexcept
{
    if (fd < 0) {
        // Only mark an error if none have been recorded yet:
        if (good()) {
            io_error = EBADF;
        }
        return false;
    }

    if (!flush_nx()) {
        // error state was checked/set by flush_nx() call
        bp_sys::close(fd);
        fd = -1;
        buf.reset();
        return false;
    }

    buf.reset();

    if (bp_sys::close(fd) < 0) {
        io_error = errno;
        fd = -1;
        return false; // Failed
    }

    fd = -1;
    return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
cmpl $0x0, (%rdi)
js 0x1356d
movq %rbx, %rdi
callq 0x135cc
testb %al, %al
je 0x13585
movq 0x8(%rbx), %rdi
movq $0x0, 0x8(%rbx)
testq %rdi, %rdi
je 0x13558
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
movl (%rbx), %edi
callq 0x4560
testl %eax, %eax
js 0x135af
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movb $0x1, %al
jmp 0x135c1
xorl %eax, %eax
cmpl $0x0, 0x10(%rbx)
jne 0x135c1
cmpq $0x0, 0x8(%rbx)
je 0x135c1
movl $0x9, 0x10(%rbx)
jmp 0x135bf
movl (%rbx), %edi
callq 0x4560
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
movq 0x8(%rbx), %rdi
movq $0x0, 0x8(%rbx)
testq %rdi, %rdi
je 0x135bf
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
jmp 0x135bf
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
xorl %eax, %eax
popq %rbx
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::flush_nx()
bool ostream::flush_nx() noexcept
{
    if (!good()) {
        return false;
    }

    while (buf->get_length() > 0) {
        char *ptr = buf->get_ptr(0);
        unsigned len = buf->get_contiguous_length(ptr);

        unsigned iovs_to_write = 1;
        struct iovec bufv[2];

        bufv[0].iov_base = ptr;
        bufv[0].iov_len = len;
        if (buf->get_length() != len) {
            // buffer's data in streambuf is split into two parts in this case because of cpbuffer nature.
            iovs_to_write = 2;
            bufv[1].iov_base = buf->get_buf_base();
            bufv[1].iov_len = buf->get_length() - len;
        }

        ssize_t r = writev_unintr(fd, bufv, iovs_to_write);
        if (r < 0) {
            io_error = errno;
            return false;
        }
        buf->consume(r);
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
xorl %ebp, %ebp
cmpl $0x0, 0x10(%rdi)
jne 0x136c4
movq %rdi, %rbx
cmpq $0x0, 0x8(%rdi)
je 0x136c4
movl $0xffffc000, %r12d      # imm = 0xFFFFC000
movl $0x4000, %r13d          # imm = 0x4000
movq %rsp, %r14
movq 0x8(%rbx), %rcx
movl 0x4004(%rcx), %eax
testl %eax, %eax
sete %bpl
je 0x136c4
leaq 0x4000(%rcx), %rdx
movl 0x4000(%rcx), %esi
leal (%rsi,%r12), %edi
cmpl %r13d, %esi
cmovbl %esi, %edi
addl %eax, %esi
leal (%rsi,%r12), %r8d
cmpl %r13d, %esi
cmovbl %esi, %r8d
leaq (%r8,%rcx), %rsi
cmpl %edi, %r8d
cmovbeq %rdx, %rsi
leaq (%rdi,%rcx), %rdx
subq %rdx, %rsi
movq %rdx, (%rsp)
movl %esi, %edx
movq %rdx, 0x8(%rsp)
movl $0x1, %edx
subl %esi, %eax
je 0x13672
movq %rcx, 0x10(%rsp)
movq %rax, 0x18(%rsp)
movl $0x2, %edx
movl (%rbx), %edi
movq %r14, %rsi
callq 0x14442
movl %eax, %r15d
testl %eax, %eax
js 0x136b1
movq 0x8(%rbx), %rax
movl 0x4000(%rax), %ecx
leal (%rcx,%r15), %edx
cmpl $0x4000, %edx           # imm = 0x4000
leal -0x4000(%rcx,%r15), %ecx
cmovbl %edx, %ecx
movl %ecx, 0x4000(%rax)
subl %r15d, 0x4004(%rax)
jmp 0x136bb
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
testl %r15d, %r15d
jns 0x13603
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0xe564
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::close()
void ostream::close()
{
    bool buf_fail = (fd >= 0 && buf == nullptr);
    bool r = close_nx();
    if (!r) {
        // Failed close_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::io_fail_bit);
        if (buf_fail) {
            throw_exception_on(io_states::buffer_fail_bit);
        }
    }
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
movl (%rdi), %ebp
movq 0x8(%rdi), %r14
callq 0x13528
testb %al, %al
je 0x136f9
popq %rbx
popq %r14
popq %rbp
retq
movq %rbx, %rdi
movl $0x8, %esi
callq 0x132ba
testl %ebp, %ebp
js 0x136f4
testq %r14, %r14
jne 0x136f4
movq %rbx, %rdi
movl $0x2, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x132ba
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(char const*)
void ostream::write(const char *msg)
{
    bool r = write_nx(msg);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x4150
movq %rax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x130a2
cmpq %r15, %rax
jne 0x137bf
popq %rbx
popq %r14
popq %r15
retq
movq %rbx, %rdi
movl $0xa, %esi
popq %rbx
popq %r14
popq %r15
jmp 0x132ba
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void ostream::write(const std::string &msg)
{
    bool r = write_nx(msg);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq (%rsi), %rsi
movq 0x8(%r14), %rdx
callq 0x130a2
cmpq 0x8(%r14), %rax
jne 0x13866
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq %rbx, %rdi
movl $0xa, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x132ba
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(int)
void ostream::write(const int num)
{
    bool r = write_nx(num);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ecx
movq %rdi, %rbx
leaq 0x3ea2(%rip), %rdx      # 0x1777b
leaq 0x4(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4480
movslq %eax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x130a2
cmpq %r15, %rax
je 0x13910
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(unsigned int)
void ostream::write(const unsigned num)
{
    bool r = write_nx(num);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %esi, %ecx
movq %rdi, %rbx
leaq 0x3e02(%rip), %rdx      # 0x1777b
leaq 0x5(%rsp), %r14
movl $0xb, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4480
movslq %eax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x130a2
cmpq %r15, %rax
je 0x139b0
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
addq $0x10, %rsp
popq %rbx
popq %r14
popq %r15
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(long)
void ostream::write(const long num)
{
    bool r = write_nx(num);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rcx
movq %rdi, %rbx
leaq 0x3d64(%rip), %rdx      # 0x1777e
movq %rsp, %r14
movl $0x15, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4480
movslq %eax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x130a2
cmpq %r15, %rax
je 0x13a4f
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write(unsigned long)
void ostream::write(const unsigned long num)
{
    bool r = write_nx(num);
    if (!r) {
        // Failed write_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rsi, %rcx
movq %rdi, %rbx
leaq 0x3cc4(%rip), %rdx      # 0x1777e
movq %rsp, %r14
movl $0x15, %esi
movq %r14, %rdi
xorl %eax, %eax
callq 0x4480
movslq %eax, %r15
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x130a2
cmpq %r15, %rax
je 0x13aef
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
addq $0x20, %rsp
popq %rbx
popq %r14
popq %r15
retq
nop
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write_buf(char const*, unsigned long)
ssize_t ostream::write_buf(const char *msg, size_t len)
{
    ssize_t r = write_buf_nx(msg, len);
    if (r < 0) {
        // Failed write_buf_nx leaves an error state bit set, so this will always throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
    return r;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0x130a2
movq %rax, %r14
testq %rax, %rax
jns 0x13b8b
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::ostream::write_buf(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
ssize_t ostream::write_buf(const std::string &msg)
{
    ssize_t r = write_buf_nx(msg);
    if (r < 0) {
        // Failed write_buf_nx leaves an error state bit set, so this will throw:
        throw_exception_on(io_states::buffer_fail_bit | io_states::io_fail_bit);
    }
    return r;
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
movq %rax, %rsi
callq 0x130a2
movq %rax, %r14
testq %rax, %rax
jns 0x13bd1
movq %rbx, %rdi
movl $0xa, %esi
callq 0x132ba
movq %r14, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::istream::load_into_buf(unsigned int)
int istream::load_into_buf(unsigned len) noexcept
{
    int r;
    do {
        r = buf->fill(fd, len);
    } while (r < 0 && errno == EINTR);
    if (r == 0) {
        eof_state = true;
        return -1;
    }
    if (r < 0) {
        io_error = errno;
        return -1;
    }
    return r;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %esi, %r14d
movq %rdi, %rbx
movq 0x8(%rbx), %rdi
movl (%rbx), %esi
movl %r14d, %edx
callq 0x1447c
movl %eax, %ebp
testl %eax, %eax
jns 0x13c44
callq 0x4040
cmpl $0x4, (%rax)
je 0x13c26
testl %ebp, %ebp
je 0x13c56
jns 0x13c5f
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
jmp 0x13c5a
movb $0x1, 0x14(%rbx)
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
popq %rbx
popq %r14
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::istream::throw_exception_on(int)
void istream::throw_exception_on(const int states)
{
    if ((states & io_states::eof_bit) && eof()) {
        throw iostream_eof();
    }
    if ((states & io_states::buffer_fail_bit) && buffer_failure()) {
        throw std::bad_alloc();
    }
    if ((states & io_states::input_fail_bit) && input_failure()) {
        throw std::bad_alloc();
    }
    if ((states & io_states::io_fail_bit) && io_failure()) {
        throw iostream_system_err(io_failure());
    }
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
testb $0x1, %sil
je 0x13c76
cmpb $0x1, 0x14(%rbx)
je 0x13ccb
testb $0x2, %sil
je 0x13c83
cmpq $0x0, 0x8(%rbx)
je 0x13c9d
testb $0x4, %sil
je 0x13c8f
cmpb $0x1, 0x15(%rbx)
je 0x13c9d
testb $0x8, %sil
je 0x13c9b
cmpl $0x0, 0x10(%rbx)
jne 0x13cde
popq %rbx
retq
movl $0x8, %edi
callq 0x4190
movq 0x92ea(%rip), %rcx      # 0x1cf98
addq $0x10, %rcx
movq %rcx, (%rax)
movq 0x92f4(%rip), %rsi      # 0x1cfb0
movq 0x92c5(%rip), %rdx      # 0x1cf88
movq %rax, %rdi
callq 0x44d0
movl $0x1, %edi
callq 0x4190
leaq 0x9074(%rip), %rsi      # 0x1cd50
jmp 0x13cf4
movl $0x4, %edi
callq 0x4190
movl 0x10(%rbx), %ecx
movl %ecx, (%rax)
leaq 0x9044(%rip), %rsi      # 0x1cd38
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::istream::open_nx(char const*)
bool istream::open_nx(const char *path) noexcept
{
    fd = bp_sys::open(path, O_RDONLY);
    if (fd < 0) {
        io_error = errno;
        return false;
    }

    buf = std::unique_ptr<streambuf>(new(std::nothrow) streambuf);
    if (!buf) {
        bp_sys::close(fd);
        fd = -1;
        return false;
    }

    return true;
}

// Assembly:
pushq %rbx
movq %rdi, %rbx
movq %rsi, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x4250
movl %eax, (%rbx)
testl %eax, %eax
js 0x13d4d
movq 0x9247(%rip), %rsi      # 0x1cf78
movl $0x4008, %edi           # imm = 0x4008
callq 0x4580
testq %rax, %rax
je 0x13d59
movq $0x0, 0x4000(%rax)
jmp 0x13d5b
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
jmp 0x13d88
xorl %eax, %eax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x13d72
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
movb $0x1, %al
cmpq $0x0, 0x8(%rbx)
jne 0x13d8a
movl (%rbx), %edi
callq 0x4560
movl $0xffffffff, (%rbx)     # imm = 0xFFFFFFFF
xorl %eax, %eax
popq %rbx
retq
movq %rax, %rdi
callq 0xe564
// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/dinit-iostream.cc
// Function: dio::istream::open_nx(char const*, int)
bool istream::open_nx(const char *path, const int flags) noexcept
{
    buf = std::unique_ptr<streambuf>(new(std::nothrow) streambuf);
    if (!buf) return false;

    fd = bp_sys::open(path, O_RDONLY | flags);
    if (fd < 0) {
        io_error = errno;
        return false;
    }
    return true;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x91b3(%rip), %rsi      # 0x1cf78
movl $0x4008, %edi           # imm = 0x4008
callq 0x4580
testq %rax, %rax
je 0x13de1
movq $0x0, 0x4000(%rax)
jmp 0x13de3
xorl %eax, %eax
movq 0x8(%rbx), %rdi
movq %rax, 0x8(%rbx)
testq %rdi, %rdi
je 0x13dfa
movl $0x4008, %esi           # imm = 0x4008
callq 0x42f0
cmpq $0x0, 0x8(%rbx)
je 0x13e21
movq %r14, %rdi
movl %ebp, %esi
xorl %eax, %eax
callq 0x4250
movl %eax, %ecx
movl %eax, (%rbx)
movb $0x1, %al
testl %ecx, %ecx
jns 0x13e23
callq 0x4040
movl (%rax), %eax
movl %eax, 0x10(%rbx)
xorl %eax, %eax
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rdi
callq 0xe564