// File: establishment[P]sandman/src/rules.hpp
// Function: Rules::Environment::getEnvironment()
char** getEnvironment() {
            int numRules = 0;
            for (auto rule : allRules) {
                // don't count empty rules for the final number of rules
                numRules += !rule.second.empty();
            }

            char** env = (char**) malloc((numRules + 1) * sizeof(char*));
            int currentRule = 0;

            env[numRules] = NULL;
            for (auto rule : allRules) {
                if (rule.second.empty()) {
                    // no empty rules
                    continue;
                }

                env[currentRule++] = strdup(Base::StrCat(rule.first, "=", rule.second).c_str());
            }

            return env;
        }

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x8(%rsp)
movl $0x0, 0x14c(%rsp)
addq $0x8, %rax
movq %rax, 0x140(%rsp)
movq 0x140(%rsp), %rdi
callq 0xb5930
movq %rax, 0x138(%rsp)
movq 0x140(%rsp), %rdi
callq 0xb5250
movq %rax, 0x130(%rsp)
leaq 0x138(%rsp), %rdi
leaq 0x130(%rsp), %rsi
callq 0xb5960
testb $0x1, %al
jne 0xa35c8
jmp 0xa3627
leaq 0x138(%rsp), %rdi
callq 0xb52a0
movq %rax, %rsi
leaq 0xf0(%rsp), %rdi
callq 0xb4ef0
leaq 0xf0(%rsp), %rdi
addq $0x20, %rdi
callq 0x8c9a0
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
addl 0x14c(%rsp), %eax
movl %eax, 0x14c(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0xb5130
leaq 0x138(%rsp), %rdi
callq 0xb4ab0
jmp 0xa35ad
movl 0x14c(%rsp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x8c7f0
movq %rax, %rcx
movq 0x8(%rsp), %rax
movq %rcx, 0xe8(%rsp)
movl $0x0, 0xe4(%rsp)
movq 0xe8(%rsp), %rcx
movslq 0x14c(%rsp), %rdx
movq $0x0, (%rcx,%rdx,8)
addq $0x8, %rax
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rdi
callq 0xb5930
movq %rax, 0xd0(%rsp)
movq 0xd8(%rsp), %rdi
callq 0xb5250
movq %rax, 0xc8(%rsp)
leaq 0xd0(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xb5960
testb $0x1, %al
jne 0xa36c4
jmp 0xa382e
leaq 0xd0(%rsp), %rdi
callq 0xb52a0
movq %rax, %rsi
leaq 0x88(%rsp), %rdi
callq 0xb4ef0
leaq 0x88(%rsp), %rdi
addq $0x20, %rdi
callq 0x8c9a0
testb $0x1, %al
jne 0xa36f8
jmp 0xa3708
movl $0x5, 0x84(%rsp)
jmp 0xa37ad
leaq 0x40(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0x8c220
jmp 0xa371c
leaq 0xa8(%rsp), %rsi
leaq 0x10(%rsp), %rdi
callq 0x8c220
jmp 0xa3730
leaq 0x52f01(%rip), %rdx     # 0xf6638
leaq 0x60(%rsp), %rdi
leaq 0x40(%rsp), %rsi
leaq 0x10(%rsp), %rcx
callq 0xb5980
jmp 0xa374d
leaq 0x60(%rsp), %rdi
callq 0x8c1f0
movq %rax, %rdi
callq 0x8cab0
movq %rax, %rdx
movq 0xe8(%rsp), %rax
movl 0xe4(%rsp), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, 0xe4(%rsp)
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
leaq 0x60(%rsp), %rdi
callq 0x8cbd8
leaq 0x10(%rsp), %rdi
callq 0x8cbd8
leaq 0x40(%rsp), %rdi
callq 0x8cbd8
movl $0x0, 0x84(%rsp)
leaq 0x88(%rsp), %rdi
callq 0xb5130
movl 0x84(%rsp), %eax
testl %eax, %eax
je 0xa37c9
jmp 0xa37c7
jmp 0xa37cb
jmp 0xa37cb
leaq 0xd0(%rsp), %rdi
callq 0xb4ab0
jmp 0xa36a6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
jmp 0xa381f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
jmp 0xa3815
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x38(%rsp)
movl %eax, 0x34(%rsp)
leaq 0x10(%rsp), %rdi
callq 0x8cbd8
leaq 0x40(%rsp), %rdi
callq 0x8cbd8
leaq 0x88(%rsp), %rdi
callq 0xb5130
jmp 0xa383e
movq 0xe8(%rsp), %rax
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x38(%rsp), %rdi
callq 0x8ca40
nopl (%rax,%rax)