// File: davmac314[P]dinit/src/includes/dinit-env.h
// Function: environment::build(environment const&) const
env_map build(const environment &parent_env) const
    {
        env_map mapping;

        // first build base: variables from the parent(s) excluding those specifically excluded
        if (keep_parent_env) {
            mapping = parent_env.build(undefine);
            // remove final null entry:
            mapping.env_list.resize(mapping.env_list.size() - 1);
        }
        else {
            // import only those specifically chosen
            for (const std::string &import_name : import_from_parent) {
                string_view name_and_val = parent_env.get(import_name);
                if (name_and_val.empty()) continue;
                mapping.var_map.insert({import_name, mapping.env_list.size()});
                mapping.env_list.push_back(name_and_val.data());
            }
        }

        // add our own (excluding exclude set)
        for (const std::string &set_var : set_vars) {
            size_t eq_pos = set_var.find('=');
            string_view set_var_name = string_view(set_var.data(), eq_pos);
            auto iter = mapping.var_map.find(set_var_name);
            if (iter != mapping.var_map.end()) {
                unsigned pos = iter->second;
                mapping.env_list[pos] = set_var.c_str();
            }
            else {
                mapping.var_map[set_var_name] = mapping.env_list.size();
                mapping.env_list.push_back(set_var.c_str());
            }
        }
        mapping.env_list.push_back(nullptr);

        return mapping;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x1a0(%rbp)
movq %rdi, %rax
movq %rax, -0x198(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x190(%rbp)
movb $0x0, -0x19(%rbp)
callq 0x1d210
movq -0x190(%rbp), %rax
testb $0x1, (%rax)
je 0x16757
movq -0x190(%rbp), %rdx
movq -0x18(%rbp), %rsi
addq $0x38, %rdx
leaq -0x70(%rbp), %rdi
callq 0x1ccb0
jmp 0x166f2
movq -0x1a0(%rbp), %rdi
leaq -0x70(%rbp), %rsi
movq %rsi, -0x1a8(%rbp)
callq 0x16b00
movq -0x1a8(%rbp), %rdi
callq 0x16b40
movq -0x1a0(%rbp), %rdi
callq 0x18560
movq -0x1a0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0x23e80
jmp 0x16735
jmp 0x168d5
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x16b40
jmp 0x16aeb
movq -0x190(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rsi
leaq -0xa0(%rbp), %rdi
callq 0x1d310
movq -0x88(%rbp), %rsi
leaq -0xb8(%rbp), %rdi
callq 0x1d350
leaq -0xa0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x1d390
testb $0x1, %al
jne 0x167ab
jmp 0x168d3
leaq -0xa0(%rbp), %rdi
callq 0x1d3c0
movq %rax, -0xc0(%rbp)
movq -0x18(%rbp), %rdi
movq -0xc0(%rbp), %rsi
callq 0x23f10
movq %rdx, -0x1b8(%rbp)
movq %rax, -0x1b0(%rbp)
jmp 0x167de
movq -0x1b8(%rbp), %rax
movq -0x1b0(%rbp), %rcx
movq %rcx, -0xd0(%rbp)
movq %rax, -0xc8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x1b680
testb $0x1, %al
jne 0x1680c
jmp 0x16811
jmp 0x168c2
movq -0x1a0(%rbp), %rdi
movq %rdi, %rax
addq $0x18, %rax
movq %rax, -0x1c8(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x1c0(%rbp)
callq 0x18560
movq -0x1c0(%rbp), %rsi
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rdx
callq 0x1d3e0
jmp 0x1685c
movq -0x1c8(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x1d290
movb %dl, -0x1d1(%rbp)
movq %rax, -0x1d0(%rbp)
jmp 0x1687e
movb -0x1d1(%rbp), %al
movq -0x1d0(%rbp), %rcx
movq %rcx, -0x100(%rbp)
movb %al, -0xf8(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x1ded0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x108(%rbp)
leaq -0x108(%rbp), %rsi
callq 0x1d720
jmp 0x168c0
jmp 0x168c2
leaq -0xa0(%rbp), %rdi
callq 0x1d420
jmp 0x1678f
jmp 0x168d5
movq -0x190(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rsi
leaq -0x128(%rbp), %rdi
callq 0x1d540
movq -0x110(%rbp), %rsi
leaq -0x140(%rbp), %rdi
callq 0x1d580
leaq -0x128(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0x1d5c0
testb $0x1, %al
jne 0x16929
jmp 0x16aa5
leaq -0x128(%rbp), %rdi
callq 0x1d5f0
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
movl $0x3d, %esi
callq 0x5670
movq %rax, -0x150(%rbp)
movq -0x148(%rbp), %rdi
callq 0x5660
movq %rax, %rsi
movq -0x150(%rbp), %rdx
leaq -0x160(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x15030
movq -0x1a0(%rbp), %rdi
movq -0x1e8(%rbp), %rsi
addq $0x18, %rdi
callq 0x1d610
movq %rax, -0x1e0(%rbp)
jmp 0x169a1
movq -0x1a0(%rbp), %rdi
movq -0x1e0(%rbp), %rax
movq %rax, -0x168(%rbp)
addq $0x18, %rdi
callq 0x1d670
movq %rax, -0x170(%rbp)
leaq -0x168(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x1d640
testb $0x1, %al
jne 0x169df
jmp 0x16a27
leaq -0x168(%rbp), %rdi
callq 0x1d6a0
movl 0x10(%rax), %eax
movl %eax, -0x174(%rbp)
movq -0x148(%rbp), %rdi
callq 0x51b0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x1f0(%rbp)
movl -0x174(%rbp), %eax
movl %eax, %esi
callq 0x1d6d0
movq -0x1f0(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x16a92
movq -0x1a0(%rbp), %rdi
callq 0x18560
movq -0x1a0(%rbp), %rdi
movl %eax, -0x1fc(%rbp)
addq $0x18, %rdi
leaq -0x160(%rbp), %rsi
callq 0x1d6f0
movq %rax, -0x1f8(%rbp)
jmp 0x16a59
movq -0x1f8(%rbp), %rax
movl -0x1fc(%rbp), %ecx
movl %ecx, (%rax)
movq -0x148(%rbp), %rdi
callq 0x51b0
movq -0x1a0(%rbp), %rdi
movq %rax, -0x180(%rbp)
leaq -0x180(%rbp), %rsi
callq 0x1d720
jmp 0x16a90
jmp 0x16a92
jmp 0x16a94
leaq -0x128(%rbp), %rdi
callq 0x1d750
jmp 0x1690d
movq -0x1a0(%rbp), %rdi
movq $0x0, -0x188(%rbp)
leaq -0x188(%rbp), %rsi
callq 0x1d720
jmp 0x16ac5
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x16adb
movq -0x1a0(%rbp), %rdi
callq 0x16b40
movq -0x198(%rbp), %rax
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x5870
nopw %cs:(%rax,%rax)
nop