// File: davmac314[P]dinit/src/includes/load-service.h
// Function: dinit_load::read_config_name(__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>>>, bool, bool*)
inline string read_config_name(string_iterator & i, string_iterator end, bool env = false, bool *num = nullptr) noexcept
{
    using std::locale;
    using std::ctype;
    using std::use_facet;

    // To avoid the horror of locales, we'll use the classic facet only, to identify digits, control
    // characters and punctuation. (Unless something is totally crazy, we are talking about ASCII or
    // a superset of it, but using the facet allows us to avoid that assumption). However, we're only
    // working with "narrow" char type so accuracy is limited. In general, that's not going to matter
    // much, but may allow certain unicode punctuation characters to be used as part of a name for example.
    const ctype<char> & facet = use_facet<ctype<char>>(locale::classic());

    string rval;

    // For environment lookups, integers are valid names (particularly for argument)
    if (env && facet.is(ctype<char>::digit, *i)) {
        while (facet.is(ctype<char>::digit, *i)) {
            rval += *i;
            ++i;
        }
        if (num) {
            *num = true;
        }
        return rval;
    }

    // Don't allow empty name, numeric digit, or dash/dot at start of setting name
    if (i == end || (*i == '-' || *i == '.' || facet.is(ctype<char>::digit, *i))) {
        return {};
    }

    // Within the setting name, allow dash and dot unless parsing envvar name
    // also allow any non-control, non-punctuation non-space character.
    while (i != end && (((*i == '-' || *i == '.') && !env) || *i == '_'
            || (!facet.is(ctype<char>::cntrl, *i) && !facet.is(ctype<char>::punct, *i)
                    && !facet.is(ctype<char>::space, *i)))) {
        rval += *i;
        ++i;
    }
    return rval;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x70(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x68(%rbp)
movq %rdi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq %r8, -0x28(%rbp)
callq 0x5570
movq %rax, -0x60(%rbp)
jmp 0x19798
movq -0x60(%rbp), %rdi
callq 0x5170
movq %rax, -0x78(%rbp)
jmp 0x197a7
movq -0x78(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x55c0
testb $0x1, -0x19(%rbp)
je 0x19863
movq -0x30(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0x80(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
movsbl (%rax), %edx
callq 0x1a3e0
testb $0x1, %al
jne 0x197ea
jmp 0x19863
jmp 0x197ec
movq -0x30(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0x88(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
movsbl (%rax), %edx
callq 0x1a3e0
testb $0x1, %al
jne 0x1981a
jmp 0x1983c
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0x5290
jmp 0x19831
movq -0x18(%rbp), %rdi
callq 0x19740
jmp 0x197ec
cmpq $0x0, -0x28(%rbp)
je 0x1984a
movq -0x28(%rbp), %rax
movb $0x1, (%rax)
movq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5250
movl $0x1, -0x54(%rbp)
jmp 0x19a48
movq -0x18(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x19620
testb $0x1, %al
jne 0x198c4
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x198c4
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %eax
cmpl $0x2e, %eax
je 0x198c4
movq -0x30(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0x90(%rbp), %rdi
movl $0x800, %esi            # imm = 0x800
movsbl (%rax), %edx
callq 0x1a3e0
testb $0x1, %al
jne 0x198c4
jmp 0x198d9
movq -0x70(%rbp), %rdi
callq 0x55c0
movl $0x1, -0x54(%rbp)
jmp 0x19a48
jmp 0x198db
movq -0x18(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x19700
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x91(%rbp)
jne 0x198fc
jmp 0x19a03
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x1991e
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %eax
cmpl $0x2e, %eax
jne 0x19930
movb $0x1, %al
testb $0x1, -0x19(%rbp)
movb %al, -0x92(%rbp)
je 0x199f7
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %ecx
movb $0x1, %al
cmpl $0x5f, %ecx
movb %al, -0x92(%rbp)
je 0x199f7
movq -0x30(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0xa0(%rbp), %rdi
movl $0x2, %esi
movsbl (%rax), %edx
callq 0x1a3e0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x93(%rbp)
jne 0x199eb
movq -0x30(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0xa8(%rbp), %rdi
movl $0x4, %esi
movsbl (%rax), %edx
callq 0x1a3e0
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x93(%rbp)
jne 0x199eb
movq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x172b0
movq -0xb0(%rbp), %rdi
movl $0x2000, %esi           # imm = 0x2000
movsbl (%rax), %edx
callq 0x1a3e0
xorb $-0x1, %al
movb %al, -0x93(%rbp)
movb -0x93(%rbp), %al
movb %al, -0x92(%rbp)
movb -0x92(%rbp), %al
movb %al, -0x91(%rbp)
movb -0x91(%rbp), %al
testb $0x1, %al
jne 0x19a0f
jmp 0x19a34
movq -0x18(%rbp), %rdi
callq 0x172b0
movsbl (%rax), %esi
leaq -0x50(%rbp), %rdi
callq 0x5290
jmp 0x19a26
movq -0x18(%rbp), %rdi
callq 0x19740
jmp 0x198db
movq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x5250
movl $0x1, -0x54(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x5280
movq -0x68(%rbp), %rax
addq $0xb0, %rsp
popq %rbp
retq
movq %rax, %rdi
callq 0x103e0
nopw %cs:(%rax,%rax)