// File: /workspace/github_cpp_makefile_star2_O2/davmac314[P]dinit/src/dinit-monitor.cc
// Function: read_var_and_issue(int, cpbuffer<1024u>&, unsigned long, std::unordered_set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::vector<stringview, std::allocator<stringview>>&, bool&, char const*, char const*)
static size_t read_var_and_issue(int socknum, cpbuffer_t &rbuffer, size_t dsz, const std::unordered_set<std::string> &varset,
        std::string &enval, std::vector<stringview> &command_parts, bool &issued, const char* str_set, const char *str_unset)
{
    enval.clear();
    issued = false;
    while (dsz > 0) {
        auto colen = rbuffer.get_contiguous_length(rbuffer.get_ptr(0));
        auto chlen = std::min((size_t)colen, dsz);
        for (unsigned i = 0; i < chlen; ++i) {
            if (rbuffer[i] != '\0') {
                continue;
            }
            enval.append(rbuffer.get_ptr(0), rbuffer.get_ptr(0) + i);
            rbuffer.consume(i + 1);
            issued = issue_var(enval, varset, command_parts, str_set, str_unset);
            return dsz - i - 1;
        }
        // copy what we have so far and fill some more
        enval.append(rbuffer.get_ptr(0), rbuffer.get_ptr(0) + chlen);
        rbuffer.consume(chlen);
        dsz -= chlen;
        if (dsz == 0) {
            // didn't find null terminator, malformed
            throw dinit_protocol_error();
        }
        if (rbuffer.get_length() == 0) {
            fill_some(rbuffer, socknum);
        }
    }
    // unreachable
    throw dinit_protocol_error();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r9, 0x10(%rsp)
movq %r8, %r13
movq %rcx, 0x18(%rsp)
movq %rdx, %rbx
movq %rsi, %r12
movl %edi, 0xc(%rsp)
movq 0x80(%rsp), %rdx
andq $0x0, 0x8(%r8)
movq (%r8), %rax
xorl %ecx, %ecx
movb %cl, (%rax)
movb %cl, (%rdx)
movq %rbx, %rax
subq $0x1, %rax
jb 0x373d
incq %rax
movq %rax, 0x20(%rsp)
movl 0x400(%r12), %eax
movl $0xfffffc00, %r15d      # imm = 0xFFFFFC00
leal (%rax,%r15), %esi
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %esi
addq %r12, %rsi
movq %r12, %rdi
callq 0x48c6
movl %eax, %ebp
cmpq %rbp, %rbx
movq %rbp, %r14
cmovbq %rbx, %r14
movl 0x400(%r12), %eax
leal (%rax,%r15), %ecx
xorl %r15d, %r15d
cmpl %r14d, %r15d
jae 0x3603
leal (%rax,%r15), %edx
leal (%rcx,%r15), %esi
cmpl $0x400, %edx            # imm = 0x400
cmovbl %edx, %esi
cmpb $0x0, (%r12,%rsi)
je 0x3659
incq %r15
jmp 0x35e1
leal -0x400(%rax), %esi
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %esi
addq %r12, %rsi
leaq (%rsi,%r14), %rdx
movq %r13, %rdi
callq 0x4902
movq %r12, %rdi
movl %r14d, %esi
callq 0x3f0e
cmpq %rbp, 0x20(%rsp)
jbe 0x373d
subq %r14, %rbx
cmpl $0x0, 0x404(%r12)
jne 0x358c
movq %r12, %rdi
movl 0xc(%rsp), %esi
callq 0x4917
jmp 0x358c
leal -0x400(%rax), %esi
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %esi
addq %r12, %rsi
leaq (%rsi,%r15), %rdx
movq %r13, %rdi
callq 0x4902
leal 0x1(%r15), %esi
movq %r12, %rdi
callq 0x3f0e
pushq $0x3d
popq %rsi
movq %r13, %rdi
xorl %edx, %edx
callq 0x22d0
movq %rax, %r14
cmpq $-0x1, %rax
jne 0x369c
movq 0x8(%r13), %r14
movq (%r13), %r12
movb $0x0, (%r12,%r14)
movq 0x18(%rsp), %rbp
cmpq $0x0, 0x18(%rbp)
je 0x36e2
leaq 0x28(%rsp), %rdi
leaq 0xb(%rsp), %rdx
movq %r12, %rsi
callq 0x3f40
movq %rbp, %rdi
leaq 0x28(%rsp), %rsi
callq 0x4970
movq %rax, %rbp
leaq 0x28(%rsp), %rdi
callq 0x2100
testq %rbp, %rbp
je 0x3719
cmpq 0x8(%r13), %r14
jne 0x36f7
movq %r12, %rdi
xorl %esi, %esi
movq 0x90(%rsp), %rdx
jmp 0x370b
addq %r12, %r14
incq %r14
movq %r12, %rdi
movq %r14, %rsi
movq 0x88(%rsp), %rdx
movq 0x10(%rsp), %rcx
callq 0x376b
movb $0x1, %al
jmp 0x371b
xorl %eax, %eax
movq 0x80(%rsp), %rcx
movb %al, (%rcx)
notq %r15
addq %rbx, %r15
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rdi
callq 0x2120
leaq 0x65dc(%rip), %rsi      # 0x9d28
movq %rax, %rdi
xorl %edx, %edx
callq 0x23b0
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x2100
movq %rbx, %rdi
callq 0x23d0