// File: /workspace/github_cpp_makefile_star2_O1/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, 0x18(%rsp)
leaq 0xb(%rsp), %r15
movb $0xd, (%r15)
movl $0x1, %r12d
xorl %ebx, %ebx
movl %r12d, %edx
movl %ebp, %edi
movq %r15, %rsi
callq 0x4100
cmpl $-0x1, %eax
je 0xf859
addl %eax, %ebx
movslq %eax, %rcx
addq %rcx, %r15
subl %eax, %r12d
xorl %ecx, %ecx
jmp 0xf879
callq 0x4040
movl $0x2, %ecx
cmpl $0x4, (%rax)
je 0xf879
testl %ebx, %ebx
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
cmovgl %ebx, %r13d
movl $0x1, %ecx
testb $0x1, %cl
jne 0xf885
testl %r12d, %r12d
jg 0xf838
jmp 0xf888
movl %r13d, %ebx
cmpl $-0x1, %ebx
je 0xfd35
movq %r14, %rdi
movl %ebp, %esi
callq 0xedbd
movl 0x400(%r14), %eax
leal -0x400(%rax), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x40, (%r14,%rcx)
jne 0xfd57
movl $0x1, %r15d
cmpl $0x5, 0x404(%r14)
ja 0xf8df
movq %r14, %rdi
movl %ebp, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %ebx
movl %ebx, %r15d
jg 0xf8bb
cmpl $-0x1, %r15d
je 0xf8ef
testl %r15d, %r15d
jne 0xf8fd
jmp 0xfccd
callq 0x4040
cmpl $0x4, (%rax)
jne 0xfcf1
cmpl $-0x1, %r15d
je 0xf8bb
movl 0x400(%r14), %r15d
leal 0x1(%r15), %eax
leal -0x3ff(%r15), %ecx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ecx
cmpb $0x1, (%r14,%rcx)
jne 0xfd6a
xorps %xmm0, %xmm0
movq 0x18(%rsp), %rcx
movups %xmm0, (%rcx)
leal 0x2(%r15), %eax
addl $0xfffffc02, %r15d      # imm = 0xFFFFFC02
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
movq $0x0, 0x10(%rcx)
leal -0x3fd(%r15), %eax
movl %r15d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xf995
movl $0x400, %ebx            # imm = 0x400
subl %r15d, %ebx
addq %r14, %rsi
leaq 0x14(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4270
addq %r12, %rbx
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4270
jmp 0xf99d
movl (%r14,%rsi), %eax
movl %eax, 0x14(%rsp)
movl $0x1, %r15d
cmpl $0xd, 0x404(%r14)
ja 0xf9c1
movq %r14, %rdi
movl %ebp, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %ebx
movl %ebx, %r15d
jg 0xf99d
cmpl $-0x1, %r15d
je 0xf9d1
testl %r15d, %r15d
jne 0xf9df
jmp 0xfcdf
callq 0x4040
cmpl $0x4, (%rax)
jne 0xfd13
cmpl $-0x1, %r15d
je 0xf99d
movl 0x400(%r14), %r15d
leal 0x6(%r15), %eax
addl $0xfffffc06, %r15d      # imm = 0xFFFFFC06
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3fd(%r15), %eax
movl %r15d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xfa46
movl $0x400, %ebx            # imm = 0x400
subl %r15d, %ebx
addq %r14, %rsi
leaq 0x4(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4270
addq %r12, %rbx
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4270
jmp 0xfa4e
movl (%r14,%rsi), %eax
movl %eax, 0x4(%rsp)
movl 0x400(%r14), %r15d
leal 0xa(%r15), %eax
addl $0xfffffc0a, %r15d      # imm = 0xFFFFFC0A
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %r15d
leal -0x3fd(%r15), %eax
movl %r15d, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xfaaf
movl $0x400, %ebx            # imm = 0x400
subl %r15d, %ebx
addq %r14, %rsi
leaq 0x10(%rsp), %r12
movq %r12, %rdi
movq %rbx, %rdx
callq 0x4270
addq %r12, %rbx
addl $0xfffffc04, %r15d      # imm = 0xFFFFFC04
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x4270
jmp 0xfab7
movl (%r14,%rsi), %eax
movl %eax, 0x10(%rsp)
movl 0x400(%r14), %eax
leal 0xe(%rax), %ecx
addl $0xfffffc0e, %eax       # imm = 0xFFFFFC0E
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x400(%r14)
addl $-0xe, 0x404(%r14)
addl $-0xe, 0x14(%rsp)
movl 0x10(%rsp), %ecx
leaq 0x68(%rsp), %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x10481
cmpl $0x0, 0x4(%rsp)
je 0xfc67
xorl %r12d, %r12d
leaq 0x48(%rsp), %r13
movl %ebp, 0x24(%rsp)
movl $0x1, %r15d
cmpl $0x3, 0x404(%r14)
ja 0xfb31
movq %r14, %rdi
movl %ebp, %esi
callq 0xeffc
testl %eax, %eax
cmovlel %eax, %ebx
movl %ebx, %r15d
jg 0xfb0d
cmpl $-0x1, %r15d
je 0xfb41
testl %r15d, %r15d
jne 0xfb4f
jmp 0xfc99
callq 0x4040
cmpl $0x4, (%rax)
jne 0xfcab
cmpl $-0x1, %r15d
je 0xfb0d
movl 0x400(%r14), %eax
leal -0x400(%rax), %ebx
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %ebx
leal -0x3fd(%rbx), %eax
movl %ebx, %esi
cmpl $0xfffffbfe, %eax       # imm = 0xFFFFFBFE
ja 0xfbb8
movl $0x400, %r15d           # imm = 0x400
subl %ebx, %r15d
addq %r14, %rsi
movq %r13, %rbp
leaq 0xc(%rsp), %r13
movq %r13, %rdi
movq %r15, %rdx
callq 0x4270
addq %r13, %r15
movq %rbp, %r13
movl 0x24(%rsp), %ebp
addl $0xfffffc04, %ebx       # imm = 0xFFFFFC04
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x4270
jmp 0xfbc0
movl (%r14,%rsi), %eax
movl %eax, 0xc(%rsp)
leaq 0x28(%rsp), %rbx
movl 0x400(%r14), %eax
leal 0x4(%rax), %ecx
addl $0xfffffc04, %eax       # imm = 0xFFFFFC04
cmpl $0x400, %ecx            # imm = 0x400
cmovbl %ecx, %eax
movl %eax, 0x400(%r14)
addl $-0x4, 0x404(%r14)
movl 0xc(%rsp), %ecx
movq %r13, %rdi
movl %ebp, %esi
movq %r14, %rdx
callq 0x10481
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq %rbx, %rdi
callq 0x1023a
movq 0x18(%rsp), %rdi
movq %rbx, %rsi
callq 0x1067e
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xfc3d
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xfc59
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42f0
incl %r12d
cmpl 0x4(%rsp), %r12d
jb 0xfb0d
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfc82
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x18(%rsp), %rax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xfcbc
movq %rax, %rbx
movl $0x4, %edi
callq 0x4190
movl (%rbx), %ecx
movl %ecx, (%rax)
leaq 0xce7d(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xfd02
movl $0x4, %edi
callq 0x4190
movl $0x0, (%rax)
jmp 0xfd24
movq %rax, %rbx
movl $0x4, %edi
callq 0x4190
movl (%rbx), %ecx
movl %ecx, (%rax)
leaq 0xce37(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
movq %rax, %rbx
movl $0x4, %edi
callq 0x4190
movl (%rbx), %ecx
movl %ecx, (%rax)
leaq 0xce15(%rip), %rsi      # 0x1cb40
movq %rax, %rdi
xorl %edx, %edx
callq 0x44d0
movl $0x4, %edi
callq 0x4190
movq %rax, %rbx
callq 0x4040
movl (%rax), %eax
movl %eax, (%rbx)
leaq 0xcdfe(%rip), %rsi      # 0x1cb50
movq %rbx, %rdi
jmp 0xfd0c
movl $0x1, %edi
callq 0x4190
leaq 0xcd98(%rip), %rsi      # 0x1cb00
jmp 0xfd09
movl $0x1, %edi
callq 0x4190
leaq 0xcf6d(%rip), %rsi      # 0x1cce8
jmp 0xfd09
jmp 0xfd7f
movq %rax, %r14
jmp 0xfde6
jmp 0xfdc8
movq %rax, %r14
jmp 0xfdaa
movq %rax, %r14
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0xfdaa
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xfdcb
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0xfdcb
movq %rax, %r14
leaq 0x78(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xfde6
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x42f0
movq 0x18(%rsp), %rdi
callq 0xfdf8
movq %r14, %rdi
callq 0x44f0