// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/includes/dinit-client.h
// Function: get_service_description_dirs[abi:cxx11](int, cpbuffer<1024u>&)
inline std::vector<std::string> get_service_description_dirs(int socknum, cpbuffer_t &rbuffer)
{
    using namespace std;

    char buf[1] = { (char)cp_cmd::QUERY_LOAD_MECH };
    write_all_x(socknum, buf, 1);

    wait_for_reply(rbuffer, socknum);

    if (rbuffer[0] != (char)cp_rply::LOADER_MECH) {
        throw dinit_protocol_error();
    }

    // Packet type, load mechanism type, packet size:
    fill_buffer_to(rbuffer, socknum, 2 + sizeof(uint32_t));

    if (rbuffer[1] != SSET_TYPE_DIRLOAD) {
        throw dinit_unknown_sd_conf();
    }

    vector<string> paths;

    uint32_t pktsize;
    rbuffer.extract(&pktsize, 2, sizeof(uint32_t));

    fill_buffer_to(rbuffer, socknum, 2 + sizeof(uint32_t) * 3); // path entries, cwd length

    uint32_t path_entries;  // number of service directories
    rbuffer.extract(&path_entries, 2 + sizeof(uint32_t), sizeof(uint32_t));

    uint32_t cwd_len;
    rbuffer.extract(&cwd_len, 2 + sizeof(uint32_t) * 2, sizeof(uint32_t));
    rbuffer.consume(2 + sizeof(uint32_t) * 3);
    pktsize -= 2 + sizeof(uint32_t) * 3;

    // Read current working directory of daemon:
    std::string dinit_cwd = read_string(socknum, rbuffer, cwd_len);

    // dinit daemon base directory against which service paths are resolved is in dinit_cwd

    for (uint32_t i = 0; i < path_entries; ++i) {
        uint32_t plen;
        fill_buffer_to(rbuffer, socknum, sizeof(uint32_t));
        rbuffer.extract(&plen, 0, sizeof(uint32_t));
        rbuffer.consume(sizeof(uint32_t));
        //paths.push_back(read_string(socknum, rbuffer, plen));
        string sd_rel_path = read_string(socknum, rbuffer, plen);
        paths.push_back(combine_paths(dinit_cwd, sd_rel_path.c_str()));
    }

    return paths;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rdx, %r14
movl %esi, %ebp
movq %rdi, 0x10(%rsp)
leaq 0xf(%rsp), %rsi
movb $0xd, (%rsi)
pushq $0x1
popq %rdx
movl %ebp, %edi
callq 0xb277
movq %r14, %rdi
movl %ebp, %esi
callq 0xb2a9
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x40, (%r14,%rcx)
jne 0xbc84
pushq $0x6
popq %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0xb33a
movl 0x400(%r14), %eax
leal 0x1(%rax), %ecx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
cmpb $0x1, (%r14,%rax)
jne 0xbc95
xorps %xmm0, %xmm0
movq 0x10(%rsp), %rax
movups %xmm0, (%rax)
andq $0x0, 0x10(%rax)
leaq 0x20(%rsp), %rsi
pushq $0x2
popq %rdx
pushq $0x4
popq %rcx
movq %r14, %rdi
callq 0xb3a0
pushq $0xe
popq %rdx
movq %r14, %rdi
movl %ebp, %esi
callq 0xb33a
leaq 0x1c(%rsp), %rsi
pushq $0x6
popq %rdx
pushq $0x4
popq %rbx
movq %r14, %rdi
movl %ebx, %ecx
callq 0xb3a0
leaq 0x24(%rsp), %r15
pushq $0xa
popq %rdx
movq %r14, %rdi
movq %r15, %rsi
movl %ebx, %ecx
callq 0xb3a0
pushq $0xe
popq %rsi
movq %r14, %rdi
callq 0xb41c
addl $-0xe, 0x20(%rsp)
movl (%r15), %ecx
leaq 0x28(%rsp), %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0xc111
xorl %r12d, %r12d
pushq $0x4
popq %r15
leaq 0x48(%rsp), %r13
leaq 0x68(%rsp), %rbx
cmpl 0x1c(%rsp), %r12d
jae 0xbc63
movq %r14, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0xb33a
movq %r14, %rdi
leaq 0x18(%rsp), %rsi
xorl %edx, %edx
movl %r15d, %ecx
callq 0xb3a0
movq %r14, %rdi
movl %r15d, %esi
callq 0xb41c
movl 0x18(%rsp), %ecx
movq %r13, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0xc111
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq %rbx, %rdi
callq 0xbfb1
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0xc2ae
movq %rbx, %rdi
callq 0x4150
movq %r13, %rdi
callq 0x4150
incl %r12d
jmp 0xbbe8
leaq 0x28(%rsp), %rdi
callq 0x4150
movq 0x10(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
callq 0x4190
leaq 0xee6d(%rip), %rsi      # 0x1ab00
jmp 0xbca4
pushq $0x1
popq %rdi
callq 0x4190
leaq 0xf044(%rip), %rsi      # 0x1ace8
movq %rax, %rdi
xorl %edx, %edx
callq 0x44f0
jmp 0xbcb0
movq %rax, %rbx
jmp 0xbce2
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0x4150
jmp 0xbcc7
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x4150
jmp 0xbcd8
jmp 0xbcd5
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x4150
movq 0x10(%rsp), %rdi
callq 0xbcf4
movq %rbx, %rdi
callq 0x4510