// File: /workspace/github_cpp_makefile_star2_O1/davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::read_setting_value(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, dinit_load::setting_op_t, file_pos_ref, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>&, __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::__cxx11::list<std::pair<unsigned int, unsigned int>, std::allocator<std::pair<unsigned int, unsigned int>>>*, char)
inline void read_setting_value(std::string &setting_val, setting_op_t operation,
        file_pos_ref input_pos, string_iterator &i, string_iterator end,
        std::list<std::pair<unsigned,unsigned>> *part_positions = nullptr,
        char delimiter = ' ')
{
    using std::locale;
    using std::isspace;

    unsigned &line_num = input_pos.get_line_num_ref();

    i = skipwsln(i, end, line_num);

    if (operation == setting_op_t::PLUSASSIGN) {
        // Ensure that values are correctly delimited. This is usually only for debugging
        // niceness as for commands where this is mostly used the offsets actually delimit
        // the components, but e.g. for capabilities (comma-separated) it matters more.
        if (!setting_val.empty()) {
            setting_val += delimiter;
        }
    }
    else {
        setting_val.clear();
        if (part_positions != nullptr) {
            part_positions->clear();
        }
    }

    bool new_part = true;
    int part_start;

    while (i != end) {
        char c = *i;
        if (c == '\"') {
            if (new_part) {
                part_start = setting_val.length();
                new_part = false;
            }
            // quoted string
            ++i;
            while (i != end) {
                c = *i;
                if (c == '\"') break;
                else if (c == '\\') {
                    // A backslash escapes the following character.
                    c = *(++i);
                    setting_val += c;
                }
                else {
                    setting_val += c;
                }
                ++i;
            }
            if (i == end) {
                // String wasn't terminated
                throw service_description_exc(input_pos, "unterminated quoted string");
            }
        }
        else if (c == '\\') {
            if (new_part) {
                part_start = setting_val.length();
                new_part = false;
            }
            // A backslash escapes the next character
            setting_val += *(++i);
        }
        else if (isspace(c, locale::classic())) {
            if (!new_part && part_positions != nullptr) {
                part_positions->emplace_back(part_start, setting_val.length());
                new_part = true;
            }
            i = skipcomment(i, end, line_num);
            if (i == end) break;
            setting_val += ' ';  // collapse ws to a single space
            continue;
        }
        else if (c == '#') {
            // Possibly intended a comment; we require leading whitespace to reduce occurrence of accidental
            // comments in setting values.
            throw service_description_exc(input_pos, "hashmark (`#') comment must be separated from setting value by whitespace");
        }
        else {
            if (new_part) {
                part_start = setting_val.length();
                new_part = false;
            }
            setting_val += c;
        }
        ++i;
    }

    // Got to end:
    if (!new_part && part_positions != nullptr) {
        part_positions->emplace_back(part_start, setting_val.length());
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r13
movq %r8, %r15
movl %esi, %ebp
movq %rdi, %rbx
movl %edx, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movq (%r8), %r14
cmpq %r9, %r14
je 0x11bad
cmpb $0xa, (%r14)
jne 0x11b85
incl 0x8(%rsp)
movzbl (%r14), %r12d
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r12,2)
je 0x11bad
incq %r14
cmpq %r13, %r14
jne 0x11b7b
movq %r13, %r14
movq 0x70(%rsp), %r12
movq %r14, (%r15)
cmpl $0x2, %ebp
jne 0x11bd0
cmpq $0x0, 0x8(%rbx)
je 0x11beb
movsbl 0x78(%rsp), %esi
movq %rbx, %rdi
callq 0x42a0
jmp 0x11beb
movq $0x0, 0x8(%rbx)
movq (%rbx), %rax
movb $0x0, (%rax)
testq %r12, %r12
je 0x11beb
movq %r12, %rdi
callq 0x11f62
movb $0x1, %al
movl %eax, (%rsp)
movq (%r15), %rax
cmpq %r13, %rax
je 0x11da0
movzbl (%rax), %r14d
cmpl $0x5c, %r14d
je 0x11c64
cmpl $0x22, %r14d
jne 0x11c89
movl (%rsp), %edx
testb $0x1, %dl
cmovnel 0x8(%rbx), %ebp
movzbl %dl, %edx
movl $0x0, %ecx
cmovnel %ecx, %edx
movl %edx, (%rsp)
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
cmpq %r13, %rcx
je 0x11c5a
movzbl 0x1(%rax), %edx
cmpl $0x5c, %edx
je 0x11c40
cmpl $0x22, %edx
jne 0x11c4a
jmp 0x11c5a
leaq 0x2(%rax), %rcx
movq %rcx, (%r15)
movb 0x2(%rax), %dl
movsbl %dl, %esi
movq %rbx, %rdi
callq 0x42a0
movq (%r15), %rax
jmp 0x11c24
cmpq %r13, %rcx
jne 0x11cd0
jmp 0x11ddd
movl (%rsp), %edx
testb $0x1, %dl
cmovnel 0x8(%rbx), %ebp
movzbl %dl, %edx
movl $0x0, %ecx
cmovnel %ecx, %edx
movl %edx, (%rsp)
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
movb 0x1(%rax), %r14b
jmp 0x11cc4
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
jne 0x11ce2
cmpb $0x23, %r14b
je 0x11e3a
movl (%rsp), %ecx
testb $0x1, %cl
cmovnel 0x8(%rbx), %ebp
movzbl %cl, %ecx
movl $0x0, %eax
cmovnel %eax, %ecx
movl %ecx, (%rsp)
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x42a0
incq (%r15)
xorl %eax, %eax
testb %al, %al
je 0x11bf0
jmp 0x11da0
testq %r12, %r12
je 0x11d21
testb $0x1, (%rsp)
jne 0x11d21
movl %ebp, %r14d
movl 0x8(%rbx), %ebp
movl $0x18, %edi
callq 0x42e0
movl %r14d, 0x10(%rax)
movl %ebp, 0x14(%rax)
movl %r14d, %ebp
movq 0x70(%rsp), %r12
movq %rax, %rdi
movq %r12, %rsi
callq 0x4060
incq 0x10(%r12)
movb $0x1, %al
movl %eax, (%rsp)
movq (%r15), %r14
cmpq %r13, %r14
je 0x11d7f
movl %ebp, 0x4(%rsp)
xorl %ebp, %ebp
movzbl (%r14), %eax
cmpl $0x23, %eax
je 0x11d45
cmpl $0xa, %eax
jne 0x11d48
incl 0x8(%rsp)
xorl %ebp, %ebp
jmp 0x11d48
movb $0x1, %bpl
testb $0x1, %bpl
jne 0x11d6b
movzbl (%r14), %r12d
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r12,2)
je 0x11d76
incq %r14
cmpq %r13, %r14
jne 0x11d2f
movq %r13, %r14
movq 0x70(%rsp), %r12
movl 0x4(%rsp), %ebp
movq %r14, (%r15)
cmpq %r13, %r14
je 0x11d99
movq %rbx, %rdi
movl $0x20, %esi
callq 0x42a0
jmp 0x11cd3
movb $0x1, %al
jmp 0x11cd5
testq %r12, %r12
je 0x11dce
testb $0x1, (%rsp)
jne 0x11dce
movl 0x8(%rbx), %ebx
movl $0x18, %edi
callq 0x42e0
movl %ebp, 0x10(%rax)
movl %ebx, 0x14(%rax)
movq %rax, %rdi
movq %r12, %rsi
callq 0x4060
incq 0x10(%r12)
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x70, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x514d(%rip), %rsi      # 0x16f47
leaq 0x5160(%rip), %rdx      # 0x16f61
leaq 0x18(%rsp), %rdi
callq 0xec92
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x116d2
xorl %ebp, %ebp
leaq 0xaee7(%rip), %rsi      # 0x1cd10
leaq -0x6be(%rip), %rdx      # 0x11772
movq %rbx, %rdi
callq 0x44d0
jmp 0x11e95
movl $0x70, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x510b(%rip), %rsi      # 0x16f62
leaq 0x514d(%rip), %rdx      # 0x16fab
leaq 0x18(%rsp), %rdi
callq 0xec92
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x116d2
xorl %ebp, %ebp
leaq 0xae8a(%rip), %rsi      # 0x1cd10
leaq -0x71b(%rip), %rdx      # 0x11772
movq %rbx, %rdi
callq 0x44d0
jmp 0x11e99
jmp 0x11eb5
movq %rax, %r14
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x11ebb
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42f0
jmp 0x11ebb
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x11ec8
movq %rbx, %rdi
callq 0x4240
movq %r14, %rdi
callq 0x44f0
jmp 0x11ed2
movq %rax, %rdi
callq 0xe564