// File: /workspace/github_cpp_makefile_star2_O1/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 $0x78, %rsp
movq %r9, 0x20(%rsp)
movq %rcx, 0x28(%rsp)
movq %rdx, %r14
movq %rsi, %r13
movl %edi, %r15d
movq 0xb0(%rsp), %rdx
movq $0x0, 0x8(%r8)
movq (%r8), %rax
xorl %ecx, %ecx
movb %cl, (%rax)
movb %cl, (%rdx)
leaq 0x400(%rsi), %rax
movq %rax, 0x68(%rsp)
movq %r8, 0x18(%rsp)
movl %edi, 0xc(%rsp)
testq %r14, %r14
je 0x4165
movl 0x400(%r13), %eax
movl 0x404(%r13), %edi
leal -0x400(%rax), %edx
cmpl $0x400, %eax            # imm = 0x400
movl %eax, %esi
cmovael %edx, %esi
leaq (%rsi,%r13), %rcx
testl %edi, %edi
je 0x3eb5
leal (%rdi,%rax), %r8d
cmpl $0x400, %r8d            # imm = 0x400
leal -0x400(%rdi,%rax), %edi
cmovbl %r8d, %edi
leal (%rdi,%r13), %r8d
cmpl %esi, %edi
cmovbel 0x68(%rsp), %r8d
subl %ecx, %r8d
jmp 0x3eb8
xorl %r8d, %r8d
cmpq %r8, %r14
movq %r8, %rbx
cmovbq %r14, %rbx
movq %r8, 0x70(%rsp)
testq %r8, %r8
setne %r12b
je 0x4082
cmpl $0x400, %eax            # imm = 0x400
cmovbl %eax, %edx
cmpb $0x0, (%r13,%rdx)
je 0x3f23
leal 0x1(%rax), %edx
addl $0xfffffc01, %eax       # imm = 0xFFFFFC01
xorl %esi, %esi
leaq 0x1(%rsi), %r15
cmpq %r15, %rbx
seta %r12b
jbe 0x407d
leal (%rdx,%rsi), %edi
addl %eax, %esi
cmpl $0x400, %edi            # imm = 0x400
cmovbl %edi, %esi
cmpb $0x0, (%r13,%rsi)
movq %r15, %rsi
jne 0x3eee
movq %r14, 0x30(%rsp)
leal 0x1(%r15), %r14d
jmp 0x3f31
movq %r14, 0x30(%rsp)
movl $0x1, %r14d
xorl %r15d, %r15d
movq 0x18(%rsp), %rbp
movq 0x8(%rbp), %rsi
movq %rbp, %rdi
xorl %edx, %edx
movq %r15, %r8
callq 0x2220
movl 0x400(%r13), %eax
leal (%rax,%r14), %ecx
cmpl $0x400, %ecx            # imm = 0x400
leal -0x400(%rax,%r14), %eax
cmovbl %ecx, %eax
movl %eax, 0x400(%r13)
subl %r14d, 0x404(%r13)
movq %rbp, %rdi
movl $0x3d, %esi
xorl %edx, %edx
callq 0x22a0
cmpq $-0x1, %rax
jne 0x3f8a
movq 0x8(%rbp), %rax
movq (%rbp), %rsi
movq %rax, 0x60(%rsp)
movb $0x0, (%rsi,%rax)
movq 0x28(%rsp), %rax
movq 0x18(%rax), %rcx
testq %rcx, %rcx
movq 0x30(%rsp), %r14
movq %rsi, 0x10(%rsp)
je 0x3fd8
leaq 0x48(%rsp), %rax
movq %rax, 0x38(%rsp)
testq %rsi, %rsi
movq %rcx, 0x58(%rsp)
je 0x3fdd
movq %rsi, %rdi
callq 0x20e0
movq 0x10(%rsp), %rsi
movq %rax, %rdx
addq %rsi, %rdx
jmp 0x3fe2
movb $0x1, %bpl
jmp 0x4008
movl $0x1, %edx
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
callq 0x4bd2
movq 0x28(%rsp), %rdi
movq %rbp, %rsi
callq 0x5490
testq %rax, %rax
setne %bpl
movq 0x58(%rsp), %rcx
testq %rcx, %rcx
je 0x4029
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4029
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2200
testb %bpl, %bpl
movq 0x10(%rsp), %rdi
je 0x4067
movq 0x18(%rsp), %rax
movq 0x60(%rsp), %rsi
cmpq 0x8(%rax), %rsi
jne 0x404f
xorl %esi, %esi
movq 0xc0(%rsp), %rdx
jmp 0x405d
addq %rdi, %rsi
incq %rsi
movq 0xb8(%rsp), %rdx
movq 0x20(%rsp), %rcx
callq 0x419f
movq 0xb0(%rsp), %rax
movb %bpl, (%rax)
notq %r15
addq %r14, %r15
movq %r15, 0x10(%rsp)
movl 0xc(%rsp), %r15d
testb %r12b, %r12b
jne 0x4114
movl 0x400(%r13), %eax
movl $0xfffffc00, %ebp       # imm = 0xFFFFFC00
leal (%rax,%rbp), %ecx
movl $0x400, %edx            # imm = 0x400
cmpl %edx, %eax
cmovbl %eax, %ecx
addq %r13, %rcx
movq 0x18(%rsp), %rdi
movq 0x8(%rdi), %rsi
xorl %edx, %edx
movq %rbx, %r8
callq 0x2220
movl 0x400(%r13), %eax
addl %ebx, %eax
leal (%rax,%rbp), %ecx
movl $0x400, %edx            # imm = 0x400
cmpl %edx, %eax
cmovbl %eax, %ecx
movl %ecx, 0x400(%r13)
movl 0x404(%r13), %eax
movl %eax, %ecx
subl %ebx, %ecx
movl %ecx, 0x404(%r13)
cmpq 0x70(%rsp), %r14
jbe 0x4165
subq %rbx, %r14
cmpl %ebx, %eax
jne 0x4114
movq %r13, %rdi
movl %r15d, %esi
callq 0x55a8
testl %eax, %eax
je 0x4131
jg 0x4114
callq 0x2040
cmpl $0x4, (%rax)
je 0x40f7
jmp 0x4143
testb %r12b, %r12b
je 0x3e5f
movq 0x10(%rsp), %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edi
callq 0x2100
movl $0x0, (%rax)
jmp 0x4154
movq %rax, %rbx
movl $0x4, %edi
callq 0x2100
movl (%rbx), %ecx
movl %ecx, (%rax)
leaq 0x5c0d(%rip), %rsi      # 0x9d68
movq %rax, %rdi
xorl %edx, %edx
callq 0x2390
movl $0x1, %edi
callq 0x2100
leaq 0x5bb2(%rip), %rsi      # 0x9d28
jmp 0x415b
movq %rax, %rbx
movq 0x38(%rsp), %rdi
leaq 0x48(%rsp), %rax
cmpq %rax, %rdi
je 0x4197
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x2200
movq %rbx, %rdi
callq 0x23b0