// File: /workspace/github_cpp_makefile_star2_O3/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 0x11975
movzbl (%r14), %r12d
cmpq $0xa, %r12
jne 0x11951
incl 0x8(%rsp)
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r12,2)
je 0x11975
incq %r14
cmpq %r13, %r14
jne 0x11943
movq %r13, %r14
movq 0x70(%rsp), %rdi
movq %r14, (%r15)
cmpl $0x2, %ebp
jne 0x11998
cmpq $0x0, 0x8(%rbx)
je 0x119b0
movsbl 0x78(%rsp), %esi
movq %rbx, %rdi
callq 0x42a0
jmp 0x119b0
movq $0x0, 0x8(%rbx)
movq (%rbx), %rax
movb $0x0, (%rax)
testq %rdi, %rdi
je 0x119b0
callq 0x11d3c
movq (%r15), %rax
cmpq %r13, %rax
je 0x11baa
movb $0x1, %r12b
movzbl (%rax), %r14d
cmpl $0x5c, %r14d
je 0x11a2d
cmpl $0x22, %r14d
jne 0x11a57
testb $0x1, %r12b
movl 0x4(%rsp), %ecx
cmovnel 0x8(%rbx), %ecx
movl %ecx, 0x4(%rsp)
movzbl %r12b, %r12d
movl $0x0, %ecx
cmovnel %ecx, %r12d
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
cmpq %r13, %rcx
je 0x11bb9
movzbl 0x1(%rax), %edx
cmpl $0x5c, %edx
je 0x11a13
cmpl $0x22, %edx
jne 0x11a1d
jmp 0x11aa5
leaq 0x2(%rax), %rcx
movq %rcx, (%r15)
movb 0x2(%rax), %dl
movsbl %dl, %esi
movq %rbx, %rdi
callq 0x42a0
movq (%r15), %rax
jmp 0x119f0
testb $0x1, %r12b
movl 0x4(%rsp), %ecx
cmovnel 0x8(%rbx), %ecx
movl %ecx, 0x4(%rsp)
movzbl %r12b, %r12d
movl $0x0, %ecx
cmovnel %ecx, %r12d
leaq 0x1(%rax), %rcx
movq %rcx, (%r15)
movb 0x1(%rax), %r14b
jmp 0x11a97
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r14,2)
jne 0x11ac5
cmpb $0x23, %r14b
je 0x11c16
testb $0x1, %r12b
movl 0x4(%rsp), %eax
cmovnel 0x8(%rbx), %eax
movl %eax, 0x4(%rsp)
movzbl %r12b, %r12d
movl $0x0, %eax
cmovnel %eax, %r12d
movsbl %r14b, %esi
movq %rbx, %rdi
callq 0x42a0
jmp 0x11aae
cmpq %r13, %rcx
je 0x11bb9
movq (%r15), %rax
incq %rax
movq %rax, (%r15)
cmpq %r13, %rax
jne 0x119bf
jmp 0x11b71
cmpq $0x0, 0x70(%rsp)
je 0x11b01
testb $0x1, %r12b
jne 0x11b01
movl 0x8(%rbx), %ebp
movl $0x18, %edi
callq 0x42e0
movl 0x4(%rsp), %ecx
movl %ecx, 0x10(%rax)
movl %ebp, 0x14(%rax)
movq %rax, %rdi
movq 0x70(%rsp), %r14
movq %r14, %rsi
callq 0x4060
incq 0x10(%r14)
movb $0x1, %r12b
movq (%r15), %r14
cmpq %r13, %r14
je 0x11b54
xorl %ecx, %ecx
movzbl (%r14), %ebp
movb $0x1, %al
cmpl $0x23, %ebp
je 0x11b47
cmpl $0xa, %ebp
jne 0x11b24
incl 0x8(%rsp)
movb (%r14), %bpl
jmp 0x11b29
testb $0x1, %cl
jne 0x11b47
callq 0x43d0
movq %rax, %rdi
callq 0x4140
movq 0x30(%rax), %rax
movzbl %bpl, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x11b54
xorl %eax, %eax
incq %r14
movl %eax, %ecx
cmpq %r13, %r14
jne 0x11b0b
movq %r13, %r14
movq %r14, (%r15)
cmpq %r13, %r14
je 0x11b71
movq %rbx, %rdi
movl $0x20, %esi
callq 0x42a0
movq (%r15), %rax
jmp 0x11ab7
cmpq $0x0, 0x70(%rsp)
je 0x11baa
testb $0x1, %r12b
jne 0x11baa
movl 0x8(%rbx), %ebx
movl $0x18, %edi
callq 0x42e0
movl 0x4(%rsp), %ecx
movl %ecx, 0x10(%rax)
movl %ebx, 0x14(%rax)
movq %rax, %rdi
movq 0x70(%rsp), %rbx
movq %rbx, %rsi
callq 0x4060
incq 0x10(%rbx)
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 0x535c(%rip), %rsi      # 0x16f32
leaq 0x536f(%rip), %rdx      # 0x16f4c
leaq 0x18(%rsp), %rdi
callq 0xec34
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x114c0
xorl %ebp, %ebp
leaq 0xb10b(%rip), %rsi      # 0x1cd10
leaq -0x6ac(%rip), %rdx      # 0x11560
movq %rbx, %rdi
callq 0x44d0
jmp 0x11c71
movl $0x70, %edi
callq 0x4190
movq %rax, %rbx
leaq 0x28(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x531a(%rip), %rsi      # 0x16f4d
leaq 0x535c(%rip), %rdx      # 0x16f96
leaq 0x18(%rsp), %rdi
callq 0xec34
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0x114c0
xorl %ebp, %ebp
leaq 0xb0ae(%rip), %rsi      # 0x1cd10
leaq -0x709(%rip), %rdx      # 0x11560
movq %rbx, %rdi
callq 0x44d0
jmp 0x11c7f
jmp 0x11ca0
jmp 0x11c77
movq %rax, %rdi
callq 0xe590
movq %rax, %r14
movq 0x18(%rsp), %rdi
cmpq %r15, %rdi
je 0x11c99
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x42f0
testb %bpl, %bpl
jne 0x11ca3
jmp 0x11cab
movq %rax, %r14
movq %rbx, %rdi
callq 0x4240
movq %r14, %rdi
callq 0x44f0