// File: /workspace/github_cpp_makefile_star2_O3/davmac314[P]dinit/src/includes/dinit-env.h
// Function: void read_env_file_inline<void (int), void (int)>(char const*, bool, environment&, bool, void (&)(int), void (&)(int))
inline void read_env_file_inline(const char *env_file_path, bool log_warnings, environment &env,
        bool throw_on_open_failure, LOG_INV_SETTING &log_inv_setting, LOG_BAD_COMMAND &log_bad_cmd)
{
    std::ifstream env_file(env_file_path);
    if (!env_file) {
        if (throw_on_open_failure) {
            throw std::system_error(errno, std::generic_category());
        }
        return;
    }

    env_file.exceptions(std::ios::badbit);

    auto &clocale = std::locale::classic();
    std::string line;
    int linenum = 0;

    while (std::getline(env_file, line)) {
        linenum++;
        auto lpos = line.begin();
        auto lend = line.end();
        while (lpos != lend && std::isspace(*lpos, clocale)) {
            ++lpos;
        }

        if (lpos == lend) continue; // empty line

        if (*lpos == '#') {
            continue;
        }
        if (*lpos == '=') {
            if (log_warnings) {
                log_inv_setting(linenum);
            }
            continue;
        }

        // "!COMMAND" form.
        if (*lpos == '!') {
            ++lpos; // lpos = first char of command
            auto epos = lpos;
            do {
                ++epos;
            } while(epos != lend && !std::isspace(*epos, clocale));

            const char *lpos_p = line.data() + (lpos - line.begin());
            string_view cmd {lpos_p, (size_t)(epos - lpos)};

            std::vector<string_view> cmd_args;
            while (epos != lend) {
                // skip whitespace
                while (std::isspace(*epos, clocale)) {
                    ++epos;
                    if (epos == lend) goto process_cmd; // no more args
                }
                // all non-ws is argument until next ws
                const char *arg_begin = line.c_str() + (epos - line.begin());
                auto arg_begin_i = epos;
                while (epos != lend && !std::isspace(*epos)) {
                    ++epos;
                }
                cmd_args.push_back(string_view {arg_begin, (size_t)(epos - arg_begin_i)});
            }

            process_cmd:

            if (cmd == "clear") {
                env.clear_no_inherit();
            }
            else if (cmd == "unset") {
                for (string_view arg : cmd_args) {
                    env.undefine_var(std::string(arg.data(), arg.length()));
                }
            }
            else if (cmd == "import") {
                for (string_view arg : cmd_args) {
                    env.import_parent_var(std::string(arg.data(), arg.length()));
                }
            }
            else if (log_warnings) {
                log_bad_cmd(linenum);
            }

            continue;
        }

        // ENV=VALUE form.
        auto name_begin = lpos++;
        // skip until '=' or whitespace:
        while (lpos != lend && *lpos != '=' && !std::isspace(*lpos, clocale)) ++lpos;
        auto name_end = lpos;
        //  skip whitespace:
        while (lpos != lend && std::isspace(*lpos, clocale)) ++lpos;
        if (lpos == lend || *lpos != '=') {
            if (log_warnings) {
                log_inv_setting(linenum);
            }
            continue;
        }

        ++lpos;
        auto val_begin = lpos;
        auto val_end = lend;

        if (val_begin != (name_end + 1) || name_begin != line.begin()) {
            // there are spaces that we need to eliminate
            std::string name_and_val;
            name_and_val.reserve((name_end - name_begin) + 1 + (val_end - val_begin));
            name_and_val = line.substr(name_begin - line.begin(), name_end - name_begin);
            name_and_val.append(1, '=');
            name_and_val.append(val_begin, val_end);
            env.set_var(std::move(name_and_val));
        }
        else {
            line.shrink_to_fit();
            env.set_var(std::move(line));
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
movq %r9, %r14
movq %r8, %r12
movl %ecx, %ebx
movq %rdx, %r13
movl %esi, %ebp
movq %rdi, %rsi
leaq 0xb0(%rsp), %r15
movq %r15, %rdi
movl $0x8, %edx
callq 0x8b00
movq (%r15), %rax
movq -0x18(%rax), %rax
movl 0xd0(%rsp,%rax), %esi
testb $0x5, %sil
je 0x30997
testb %bl, %bl
je 0x30fc9
movl $0x20, %edi
callq 0x82c0
movq %rax, %r14
callq 0x8050
movl (%rax), %ebx
callq 0x82e0
movq %r14, %rdi
movl %ebx, %esi
movq %rax, %rdx
callq 0xcc6e
movq 0x155a8(%rip), %rsi     # 0x45f30
movq 0x155d9(%rip), %rdx     # 0x45f68
movq %r14, %rdi
callq 0x8aa0
movl %ebp, 0x24(%rsp)
movq %r12, 0x98(%rsp)
leaq (%rsp,%rax), %rdi
addq $0xb0, %rdi
movl $0x1, 0x1c(%rdi)
callq 0x8a90
movq %r14, 0xa0(%rsp)
callq 0x8840
movq %rax, 0x38(%rsp)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorl %ebx, %ebx
movq %r13, 0x28(%rsp)
movq 0xb0(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x85d0
leaq 0x40(%rsp), %rsi
movsbl %al, %edx
movq %r15, %rdi
callq 0x8b10
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x30fad
incl %ebx
movq 0x40(%rsp), %rax
movq 0x48(%rsp), %rcx
movq %rax, %r14
testq %rcx, %rcx
je 0x30a92
movq %rbx, %r12
movq %rcx, 0x90(%rsp)
movq %rcx, %rbx
movq %rax, %rbp
movq %rax, %r14
movzbl (%r14), %r15d
movq 0x38(%rsp), %rdi
callq 0x8220
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r15,2)
je 0x30a7c
incq %r14
decq %rbx
jne 0x30a4a
leaq 0xb0(%rsp), %r15
movq %r12, %rbx
jmp 0x309e7
leaq 0xb0(%rsp), %r15
movq %r12, %rbx
movq %rbp, %rax
movq 0x90(%rsp), %rcx
movq %rax, 0xa8(%rsp)
leaq (%rax,%rcx), %r12
cmpq %r12, %r14
je 0x309e7
movzbl (%r14), %eax
cmpl $0x21, %eax
je 0x30adb
cmpl $0x23, %eax
je 0x309e7
cmpl $0x3d, %eax
jne 0x30bc4
cmpb $0x0, 0x24(%rsp)
je 0x309e7
movl %ebx, %edi
callq *0x98(%rsp)
jmp 0x309e7
movq %rbx, 0x30(%rsp)
leaq 0x1(%r14), %r15
addq $0x2, %r14
cmpq %r12, %r14
je 0x30c62
movzbl (%r14), %ebx
movq 0x38(%rsp), %rdi
callq 0x8220
movq 0x30(%rax), %rax
incq %r14
testb $0x20, 0x1(%rax,%rbx,2)
je 0x30ae8
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
decq %r14
cmpq %r12, %r14
je 0x30d00
movq %r14, %rbx
movzbl (%rbx), %r13d
movq 0x38(%rsp), %rdi
callq 0x8220
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r13,2)
jne 0x30b6a
movq %rbx, %r13
cmpq %r12, %rbx
je 0x30b74
movsbl (%r13), %edi
callq 0x8070
testl %eax, %eax
jne 0x30b65
incq %r13
cmpq %r12, %r13
jne 0x30b4f
movq %r13, %rbp
jmp 0x30b77
incq %rbx
cmpq %r12, %rbx
jne 0x30b2d
jmp 0x30bb7
movq %rbx, %rbp
subq %rbx, %r13
movq %rbx, (%rsp)
movq %r13, 0x8(%rsp)
movq 0x68(%rsp), %rsi
cmpq 0x70(%rsp), %rsi
je 0x30b9e
movups (%rsp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x68(%rsp)
jmp 0x30bab
leaq 0x60(%rsp), %rdi
movq %rsp, %rdx
callq 0x31126
movq %rbp, %rbx
cmpq %r12, %rbp
jne 0x30b2d
movq %r14, %r12
movq 0x28(%rsp), %r13
jmp 0x30d03
movq %rcx, 0x90(%rsp)
movq %rbx, 0x30(%rsp)
movl $0x2, %eax
movq %r14, %rbp
movq %rbp, %rcx
incq %rbp
cmpq %r12, %rbp
je 0x30cd5
movq %rax, %rbx
movq %rcx, 0x88(%rsp)
movzbl (%rbp), %r13d
cmpq $0x3d, %r13
je 0x30c18
movq 0x38(%rsp), %rdi
callq 0x8220
movq 0x30(%rax), %rcx
leaq 0x1(%rbx), %rax
testb $0x20, 0x1(%rcx,%r13,2)
je 0x30bd9
xorl %r13d, %r13d
movq 0x88(%rsp), %rcx
movq %r12, %r15
movzbl 0x1(%rcx,%r13), %r12d
movq 0x38(%rsp), %rdi
callq 0x8220
movq 0x30(%rax), %rax
testb $0x20, 0x1(%rax,%r12,2)
je 0x30c78
movq 0x88(%rsp), %rcx
leaq (%rcx,%r13), %rax
addq $0x2, %rax
incq %r13
incq %rbx
movq %r15, %r12
cmpq %r15, %rax
jne 0x30c23
jmp 0x30cd5
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
jmp 0x30d03
movq 0x88(%rsp), %rax
addq %r13, %rax
incq %rax
cmpq %r15, %rax
je 0x30cd5
cmpb $0x3d, (%rax)
jne 0x30cd5
testq %r13, %r13
jne 0x30eb0
cmpq 0x40(%rsp), %r14
jne 0x30eb0
leaq 0x40(%rsp), %r14
movq %r14, %rdi
callq 0x8370
leaq 0xb0(%rsp), %r15
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %r13
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1af98
jmp 0x309e7
cmpb $0x0, 0x24(%rsp)
movq 0x28(%rsp), %r13
leaq 0xb0(%rsp), %r15
movq 0x30(%rsp), %rbx
je 0x309e7
movl %ebx, %edi
callq *0x98(%rsp)
jmp 0x309e7
movq %r14, %r12
subq %r15, %r12
movb $0x63, %cl
xorl %eax, %eax
leaq 0x5c02(%rip), %rdx      # 0x36913
leaq 0x5c01(%rip), %rsi      # 0x36919
cmpb (%r15,%rax), %cl
jne 0x30d46
movb 0x1(%rax,%rdx), %cl
incq %rax
cmpq $0x5, %rax
jne 0x30d18
cmpq $0x5, %r12
jne 0x30d46
movq %r13, %rdi
callq 0x310ac
leaq 0xb0(%rsp), %r15
jmp 0x30e82
movb $0x75, %cl
xorl %eax, %eax
leaq 0x5bce(%rip), %rdx      # 0x3691f
movl 0x24(%rsp), %r8d
cmpb (%r15,%rax), %cl
jne 0x30de2
movb 0x1(%rax,%rsi), %cl
incq %rax
cmpq $0x5, %rax
jne 0x30d56
cmpq $0x5, %r12
jne 0x30de2
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %rbx
cmpq %rbx, %r14
je 0x30ea6
leaq 0xb0(%rsp), %r15
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %r12
movq %r12, %rdi
callq 0x1df58
movq %r13, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0x2bbbe
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x30dd4
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8620
addq $0x10, %r14
cmpq %rbx, %r14
jne 0x30d8e
jmp 0x30e82
movb $0x69, %cl
xorl %eax, %eax
cmpb (%r15,%rax), %cl
jne 0x30e69
movb 0x1(%rax,%rdx), %cl
incq %rax
cmpq $0x6, %rax
jne 0x30de6
cmpq $0x6, %r12
jne 0x30e69
movq 0x60(%rsp), %r14
movq 0x68(%rsp), %rbx
cmpq %rbx, %r14
je 0x30ea6
leaq 0xb0(%rsp), %r15
movq (%r14), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq %rsp, %r12
movq %r12, %rdi
callq 0x1df58
movq %r13, %rdi
movq %r12, %rsi
callq 0x310d2
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x30e5e
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8620
addq $0x10, %r14
cmpq %rbx, %r14
jne 0x30e1a
jmp 0x30e82
testb %r8b, %r8b
leaq 0xb0(%rsp), %r15
je 0x30e82
movq 0x30(%rsp), %rdi
callq *0xa0(%rsp)
movq 0x60(%rsp), %r14
testq %r14, %r14
je 0x30e9c
movq 0x70(%rsp), %rsi
subq %r14, %rsi
movq %r14, %rdi
callq 0x8620
movq 0x30(%rsp), %rbx
jmp 0x309e7
leaq 0xb0(%rsp), %r15
jmp 0x30e87
leaq 0x10(%rsp), %rax
movq %rax, (%rsp)
movq $0x0, 0x8(%rsp)
movb $0x0, 0x10(%rsp)
movq 0xa8(%rsp), %rsi
addq 0x90(%rsp), %rsi
subq %r14, %rsi
movq %rsi, %r15
subq %r13, %rsi
movq %rsp, %rdi
callq 0x89b0
subq %r14, %rbp
subq 0x40(%rsp), %r14
leaq 0x60(%rsp), %r12
movq %r12, %rdi
leaq 0x40(%rsp), %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x8640
movq %rsp, %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x8740
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x30f32
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x8620
movq 0x8(%rsp), %rsi
movl $0x1, %ecx
movq %r14, %rdi
xorl %edx, %edx
movl $0x3d, %r8d
callq 0x8b20
movq 0x88(%rsp), %rax
leaq (%rax,%r13), %rcx
addq $0x2, %rcx
movq %r15, %r8
subq %rbx, %r8
movq 0x8(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
callq 0x86b0
movq 0x28(%rsp), %rdi
movq %r14, %rsi
xorl %edx, %edx
callq 0x1af98
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x30f9b
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8620
movq 0x28(%rsp), %r13
leaq 0xb0(%rsp), %r15
jmp 0x30e9c
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0x30fc9
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8620
leaq 0xb0(%rsp), %rdi
callq 0x8120
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x31078
jmp 0x30ff7
movq %rax, %rdi
callq 0xb74e
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x3107b
movq 0x10(%rsp), %rsi
incq %rsi
jmp 0x31069
jmp 0x31054
movq %rax, %rbx
movq %r14, %rdi
callq 0x8440
jmp 0x31097
jmp 0x31027
jmp 0x31078
jmp 0x31078
movq %rax, %rbx
jmp 0x31097
jmp 0x31054
jmp 0x31032
jmp 0x31054
movq %rax, %rbx
movq (%rsp), %rdi
leaq 0x10(%rsp), %rax
cmpq %rax, %rdi
je 0x31057
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x8620
jmp 0x31057
jmp 0x31054
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x3107b
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x8620
jmp 0x3107b
jmp 0x31078
jmp 0x31078
jmp 0x31078
jmp 0x31078
movq %rax, %rbx
leaq 0x50(%rsp), %rax
movq 0x40(%rsp), %rdi
cmpq %rax, %rdi
je 0x31097
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x8620
leaq 0xb0(%rsp), %rdi
callq 0x8120
movq %rbx, %rdi
callq 0x8ab0