// File: /workspace/github_cpp_makefile_star2_O3/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 %rcx, 0x18(%rsp)
movq %rdx, %rbx
movq 0x80(%rsp), %rdx
movq $0x0, 0x8(%r8)
movq %r8, 0x8(%rsp)
movq (%r8), %rax
xorl %ecx, %ecx
movb %cl, (%rax)
movb %cl, (%rdx)
testq %rbx, %rbx
je 0x3e5b
movq %rsi, %r12
movl %edi, %r13d
leaq 0x400(%rsi), %rax
movq %rax, 0x20(%rsp)
movl 0x400(%r12), %eax
movl 0x404(%r12), %edi
leal -0x400(%rax), %edx
cmpl $0x400, %eax            # imm = 0x400
movl %eax, %esi
cmovael %edx, %esi
leaq (%rsi,%r12), %rcx
testl %edi, %edi
je 0x3dca
leal (%rdi,%rax), %r8d
cmpl $0x400, %r8d            # imm = 0x400
leal -0x400(%rdi,%rax), %edi
cmovbl %r8d, %edi
leal (%r12,%rdi), %r15d
cmpl %esi, %edi
cmovbel 0x20(%rsp), %r15d
subl %ecx, %r15d
cmpq %r15, %rbx
movq %r15, %rbp
cmovbq %rbx, %rbp
testl %r15d, %r15d
je 0x3dcc
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %edx
cmpb $0x0, (%r12,%rdx)
je 0x3fb1
leal 0x1(%rax), %edx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
xorl %r14d, %r14d
leal 0x1(%r14), %esi
cmpl %ebp, %esi
jae 0x3dd4
leal (%rdx,%r14), %esi
leal (%rax,%r14), %edi
cmpl $0x400, %esi            # imm = 0x400
cmovbl %esi, %edi
incq %r14
cmpb $0x0, (%r12,%rdi)
jne 0x3da2
jmp 0x3e71
xorl %ebp, %ebp
xorl %r15d, %r15d
xorl %r14d, %r14d
jmp 0x3dd7
movl %ebp, %r14d
movq 0x8(%rsp), %rdi
movq 0x8(%rdi), %rsi
xorl %edx, %edx
movq %rbp, %r8
callq 0x2220
movl 0x400(%r12), %ecx
movl 0x404(%r12), %eax
leal (%rcx,%r14), %edx
cmpl $0x400, %edx            # imm = 0x400
leal -0x400(%rcx,%r14), %ecx
cmovbl %edx, %ecx
movl %ecx, 0x400(%r12)
movl %eax, %ecx
subl %r14d, %ecx
movl %ecx, 0x404(%r12)
cmpq %r15, %rbx
jbe 0x3e5b
cmpl %r14d, %eax
jne 0x3e52
movq %r12, %rdi
movl %r13d, %esi
callq 0x5396
testl %eax, %eax
je 0x3fbf
jg 0x3e52
callq 0x2040
cmpl $0x4, (%rax)
je 0x3e2e
jmp 0x3fd1
subq %rbp, %rbx
jne 0x3d28
movl $0x1, %edi
callq 0x2100
leaq 0x4ebc(%rip), %rsi      # 0x8d28
jmp 0x3fea
leal 0x1(%r14), %r15d
movq 0x8(%rsp), %rbp
movq 0x8(%rbp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
movq %r14, %r8
callq 0x2220
movl 0x400(%r12), %eax
leal (%rax,%r15), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%rax,%r15), %eax
cmovbl %ecx, %eax
movl %eax, 0x400(%r12)
subl %r15d, 0x404(%r12)
movq %rbp, %rdi
movl $0x3d, %esi
xorl %edx, %edx
callq 0x22a0
movq %rax, %r12
cmpq $-0x1, %rax
jne 0x3ed4
movq 0x8(%rbp), %r12
movq (%rbp), %r13
movb $0x0, (%r13,%r12)
movq 0x18(%rsp), %r15
cmpq $0x0, 0x18(%r15)
je 0x3f43
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
movq %r13, %rdi
callq 0x20e0
leaq (%rax,%r13), %rdx
leaq 0x28(%rsp), %rbp
movq %rbp, %rdi
movq %r13, %rsi
callq 0x49c6
movq %r15, %rdi
movq %rbp, %rsi
callq 0x527e
movq %rax, %rbp
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x3f39
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
testq %rbp, %rbp
movq 0x8(%rsp), %rbp
je 0x3f8d
cmpq 0x8(%rbp), %r12
jne 0x3f64
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r8
movq %r13, %rdi
xorl %esi, %esi
movq 0x90(%rsp), %rdx
jmp 0x3f84
addq %r13, %r12
incq %r12
movq 0x10(%rsp), %rax
movq (%rax), %rcx
movq 0x8(%rax), %r8
movq %r13, %rdi
movq %r12, %rsi
movq 0x88(%rsp), %rdx
callq 0x401b
movb $0x1, %al
jmp 0x3f8f
xorl %eax, %eax
movq 0x80(%rsp), %rcx
movb %al, (%rcx)
notq %r14
addq %r14, %rbx
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %r15d
xorl %r14d, %r14d
jmp 0x3e75
movl $0x4, %edi
callq 0x2100
movl $0x0, (%rax)
jmp 0x3fe3
movq %rax, %r14
movl $0x4, %edi
callq 0x2100
movl (%r14), %ecx
movl %ecx, (%rax)
leaq 0x4d7e(%rip), %rsi      # 0x8d68
movq %rax, %rdi
xorl %edx, %edx
callq 0x2390
movq %rax, %rbx
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rax
cmpq %rax, %rdi
je 0x4013
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x23b0