// File: iamlouk[P]asbi/src/procenv.cc
// Function: asbi::load_procenv(asbi::Context*, int, char const**, int)
void asbi::load_procenv(Context* ctx, int argc, const char* argv[], int scriptArgs) {
	auto env = new MapContainer(ctx);
	auto args = new MapContainer(ctx);
	for (int i = scriptArgs, j = 0; i < argc; ++i, ++j)
		args->set(Value::number(j), Value::string(ctx->new_string(argv[i])));

	env->set(Value::symbol("all",  ctx), Value::macro(all_env_vars));
	env->set(Value::symbol("set",  ctx), Value::macro(set_env_var));
	env->set(Value::symbol("get",  ctx), Value::macro(get_env_var));
	env->set(Value::symbol("argv", ctx), Value::map(args));
	env->set(Value::symbol("$",    ctx), Value::macro(macro_system));
	env->set(Value::symbol("exit", ctx), Value::macro(macro_exit));
	ctx->global_env->decl(ctx, "env", Value::map(env));
}

// Assembly:
subq $0x198, %rsp            # imm = 0x198
movq %rdi, 0x190(%rsp)
movl %esi, 0x18c(%rsp)
movq %rdx, 0x180(%rsp)
movl %ecx, 0x17c(%rsp)
movl $0x68, %edi
callq 0x6460
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x58(%rsp)
movq 0x190(%rsp), %rsi
callq 0x212d0
jmp 0x2cfb9
movq 0x58(%rsp), %rax
movq %rax, 0x170(%rsp)
movl $0x68, %edi
callq 0x6460
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x50(%rsp)
movq 0x190(%rsp), %rsi
callq 0x212d0
jmp 0x2cfea
movq 0x50(%rsp), %rax
movq %rax, 0x158(%rsp)
movl 0x17c(%rsp), %eax
movl %eax, 0x154(%rsp)
movl $0x0, 0x150(%rsp)
movl 0x154(%rsp), %eax
cmpl 0x18c(%rsp), %eax
jge 0x2d125
movq 0x158(%rsp), %rax
movq %rax, 0x48(%rsp)
cvtsi2sdl 0x150(%rsp), %xmm0
callq 0x1d090
movl %eax, 0x140(%rsp)
movq %rdx, 0x148(%rsp)
movq 0x190(%rsp), %rdi
movq 0x180(%rsp), %rax
movslq 0x154(%rsp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x26f70
movq %rax, %rdi
callq 0x1d180
movq 0x48(%rsp), %rdi
movl %eax, 0x130(%rsp)
movq %rdx, 0x138(%rsp)
movl 0x140(%rsp), %esi
movq 0x148(%rsp), %rdx
movl 0x130(%rsp), %ecx
movq 0x138(%rsp), %r8
callq 0x21550
movl 0x154(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x154(%rsp)
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x2d010
movq 0x58(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
movl $0x68, %esi
callq 0x6470
jmp 0x2d42f
movq 0x50(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x168(%rsp)
movl %eax, 0x164(%rsp)
movl $0x68, %esi
callq 0x6470
jmp 0x2d42f
movq 0x170(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xbea5(%rip), %rdi      # 0x38fe6
callq 0x217d0
movl %eax, 0x120(%rsp)
movq %rdx, 0x128(%rsp)
leaq 0x2e4(%rip), %rdi       # 0x2d440
callq 0x2cd00
movq 0x8(%rsp), %rdi
movl %eax, 0x110(%rsp)
movq %rdx, 0x118(%rsp)
movl 0x120(%rsp), %esi
movq 0x128(%rsp), %rdx
movl 0x110(%rsp), %ecx
movq 0x118(%rsp), %r8
callq 0x21550
movq 0x170(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xc36f(%rip), %rdi      # 0x39523
callq 0x217d0
movl %eax, 0x100(%rsp)
movq %rdx, 0x108(%rsp)
leaq 0x671(%rip), %rdi       # 0x2d840
callq 0x2cd00
movq 0x10(%rsp), %rdi
movl %eax, 0xf0(%rsp)
movq %rdx, 0xf8(%rsp)
movl 0x100(%rsp), %esi
movq 0x108(%rsp), %rdx
movl 0xf0(%rsp), %ecx
movq 0xf8(%rsp), %r8
callq 0x21550
movq 0x170(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xc300(%rip), %rdi      # 0x39527
callq 0x217d0
movl %eax, 0xe0(%rsp)
movq %rdx, 0xe8(%rsp)
leaq 0x7ce(%rip), %rdi       # 0x2da10
callq 0x2cd00
movq 0x18(%rsp), %rdi
movl %eax, 0xd0(%rsp)
movq %rdx, 0xd8(%rsp)
movl 0xe0(%rsp), %esi
movq 0xe8(%rsp), %rdx
movl 0xd0(%rsp), %ecx
movq 0xd8(%rsp), %r8
callq 0x21550
movq 0x170(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xc291(%rip), %rdi      # 0x3952b
callq 0x217d0
movl %eax, 0xc0(%rsp)
movq %rdx, 0xc8(%rsp)
movq 0x158(%rsp), %rdi
callq 0x7be0
movq 0x20(%rsp), %rdi
movl %eax, 0xb0(%rsp)
movq %rdx, 0xb8(%rsp)
movl 0xc0(%rsp), %esi
movq 0xc8(%rsp), %rdx
movl 0xb0(%rsp), %ecx
movq 0xb8(%rsp), %r8
callq 0x21550
movq 0x170(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xc222(%rip), %rdi      # 0x39530
callq 0x217d0
movl %eax, 0xa0(%rsp)
movq %rdx, 0xa8(%rsp)
leaq 0x837(%rip), %rdi       # 0x2db60
callq 0x2cd00
movq 0x28(%rsp), %rdi
movl %eax, 0x90(%rsp)
movq %rdx, 0x98(%rsp)
movl 0xa0(%rsp), %esi
movq 0xa8(%rsp), %rdx
movl 0x90(%rsp), %ecx
movq 0x98(%rsp), %r8
callq 0x21550
movq 0x170(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x190(%rsp), %rsi
leaq 0xc1b1(%rip), %rdi      # 0x39532
callq 0x217d0
movl %eax, 0x80(%rsp)
movq %rdx, 0x88(%rsp)
leaq 0xa44(%rip), %rdi       # 0x2dde0
callq 0x2cd00
movq 0x30(%rsp), %rdi
movl %eax, 0x70(%rsp)
movq %rdx, 0x78(%rsp)
movl 0x80(%rsp), %esi
movq 0x88(%rsp), %rdx
movl 0x70(%rsp), %ecx
movq 0x78(%rsp), %r8
callq 0x21550
movq 0x190(%rsp), %rdi
addq $0x4f8, %rdi            # imm = 0x4F8
callq 0x7bd0
movq %rax, 0x38(%rsp)
movq 0x190(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x170(%rsp), %rdi
callq 0x7be0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl %eax, 0x60(%rsp)
movq %rdx, 0x68(%rsp)
movl 0x60(%rsp), %ecx
movq 0x68(%rsp), %r8
leaq 0xbcc7(%rip), %rdx      # 0x390e9
callq 0x26260
addq $0x198, %rsp            # imm = 0x198
retq
movq 0x168(%rsp), %rdi
callq 0x67a0
nopl (%rax)