// File: /workspace/github_cpp_makefile_star2_O2/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, %r15
movq %r8, %r12
movl %esi, %ebp
movq %rdi, %r14
movq 0x70(%rsp), %rbx
leaq 0x28(%rsp), %rax
movl %edx, (%rax)
movq %rcx, 0x8(%rax)
movq (%r8), %rdi
movq %r9, %rsi
movq %rax, %rdx
callq 0xd37c
movq %rax, (%r12)
cmpl $0x2, %ebp
jne 0xd79c
cmpq $0x0, 0x8(%r14)
je 0xd7b4
movsbl 0x78(%rsp), %esi
movq %r14, %rdi
callq 0x42b0
jmp 0xd7b4
andq $0x0, 0x8(%r14)
movq (%r14), %rax
movb $0x0, (%rax)
testq %rbx, %rbx
je 0xd7b4
movq %rbx, %rdi
callq 0xda78
movb $0x1, %bpl
movq (%r12), %rax
cmpq %r15, %rax
je 0xd8ea
movzbl (%rax), %r13d
cmpl $0x5c, %r13d
je 0xd82c
cmpl $0x22, %r13d
jne 0xd85d
testb $0x1, %bpl
je 0xd804
movl 0x8(%r14), %ecx
movl %ecx, 0x4(%rsp)
xorl %ebp, %ebp
jmp 0xd804
leaq 0x2(%rax), %rcx
movq %rcx, (%r12)
movb 0x2(%rax), %dl
movsbl %dl, %esi
movq %r14, %rdi
callq 0x42b0
movq (%r12), %rax
leaq 0x1(%rax), %rcx
movq %rcx, (%r12)
cmpq %r15, %rcx
je 0xd91d
movzbl (%rcx), %edx
cmpl $0x5c, %edx
je 0xd7ea
cmpl $0x22, %edx
jne 0xd7f5
cmpq %r15, %rcx
jne 0xd854
jmp 0xd91d
testb $0x1, %bpl
je 0xd83c
movl 0x8(%r14), %ecx
movl %ecx, 0x4(%rsp)
xorl %ebp, %ebp
leaq 0x1(%rax), %rcx
movq %rcx, (%r12)
movb 0x1(%rax), %r13b
movsbl %r13b, %esi
movq %r14, %rdi
callq 0x42b0
incq (%r12)
jmp 0xd7b7
callq 0x4400
movsbl %r13b, %edi
movq %rax, %rsi
callq 0xd729
testb %al, %al
je 0xd8c7
testq %rbx, %rbx
sete %al
orb %bpl, %al
testb $0x1, %al
jne 0xd89d
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
movq %rbx, %rdi
leaq 0x4(%rsp), %rsi
leaq 0x8(%rsp), %rdx
callq 0xda90
movb $0x1, %bpl
movq (%r12), %rdi
movq %r15, %rsi
leaq 0x28(%rsp), %rdx
callq 0xdaac
movq %rax, (%r12)
cmpq %r15, %rax
je 0xd8ea
movq %r14, %rdi
pushq $0x20
popq %rsi
callq 0x42b0
jmp 0xd7b7
cmpb $0x23, %r13b
je 0xd96d
testb $0x1, %bpl
je 0xd848
movl 0x8(%r14), %eax
movl %eax, 0x4(%rsp)
xorl %ebp, %ebp
jmp 0xd848
testq %rbx, %rbx
je 0xd90e
testb $0x1, %bpl
jne 0xd90e
movq 0x8(%r14), %rax
leaq 0x8(%rsp), %rdx
movq %rax, (%rdx)
leaq 0x4(%rsp), %rsi
movq %rbx, %rdi
callq 0xda90
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x70
popq %rdi
callq 0x4190
movq %rax, %rbx
leaq 0x55f3(%rip), %rsi      # 0x12f22
leaq 0x8(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xb124
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0xd2ec
xorl %ebp, %ebp
leaq 0xd3b4(%rip), %rsi      # 0x1ad10
leaq -0x639(%rip), %rdx      # 0xd32a
movq %rbx, %rdi
callq 0x44f0
jmp 0xd9bb
pushq $0x70
popq %rdi
callq 0x4190
movq %rax, %rbx
leaq 0x55be(%rip), %rsi      # 0x12f3d
leaq 0x8(%rsp), %rdi
leaq 0x3(%rsp), %rdx
callq 0xb124
movb $0x1, %bpl
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0xd2ec
xorl %ebp, %ebp
leaq 0xd364(%rip), %rsi      # 0x1ad10
leaq -0x689(%rip), %rdx      # 0xd32a
movq %rbx, %rdi
callq 0x44f0
jmp 0xd9bf
jmp 0xd9d3
movq %rax, %r14
leaq 0x8(%rsp), %rdi
callq 0x4150
testb %bpl, %bpl
jne 0xd9d6
jmp 0xd9de
movq %rax, %r14
movq %rbx, %rdi
callq 0x4250
movq %r14, %rdi
callq 0x4510