// File: /workspace/github_cpp_makefile_star2_O3/iamlouk[P]asbi/src/macros.cc
// Function: macro_map(int, asbi::Context*, std::shared_ptr<asbi::Env>)
static Value macro_map(int n, Context* ctx, std::shared_ptr<Env> env) {
	if (n != 2)
		throw std::runtime_error("map macro usage error");

	auto map = ctx->pop();
	auto fn  = ctx->pop();
	if (map.type != type_t::Map || fn.type != type_t::Lambda)
		throw std::runtime_error("map macro usage error");

	auto res = new MapContainer(ctx);
	ctx->push(Value::map(res));

	auto &vecdata = map._map->vecdata;
	for (unsigned int i = 0; i < vecdata.size(); ++i) {
		auto key = Value::number(i);
		ctx->push(vecdata[i]);
		ctx->push(key);
		res->set(key, fn.call(ctx, 2, env));
	}

	for (auto [key, value]: map._map->data) {
		ctx->push(value);
		ctx->push(key);
		res->set(key, fn.call(ctx, 2, env));
	}

	return ctx->pop(); // res muss auf stack liegen weil GC
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
cmpl $0x2, %edi
jne 0x12e0c
movq %rdx, %r14
movq %rsi, %rbx
movq %rsi, %rdi
callq 0x11122
movl %eax, %ebp
movq %rdx, %r12
movq %rdx, 0x30(%rsp)
movq %rbx, %rdi
callq 0x11122
movl %eax, 0x20(%rsp)
movq %rdx, 0x28(%rsp)
cmpl $0x6, %ebp
jne 0x12e2a
cmpl $0x5, %eax
jne 0x12e2a
movl $0x68, %edi
callq 0x5380
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0xf274
movq %rbx, %rdi
movl $0x6, %esi
movq %r15, %rdx
callq 0x110dc
movq 0x50(%r12), %rax
cmpq %rax, 0x58(%r12)
je 0x12d59
xorl %ecx, %ecx
xorl %ebp, %ebp
movl %ebp, %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
movq %xmm0, %r13
shlq $0x4, %rcx
movl (%rax,%rcx), %esi
movq 0x8(%rax,%rcx), %rdx
movq %rbx, %rdi
callq 0x110dc
movq %rbx, %rdi
movl $0x1, %esi
movq %r13, %rdx
callq 0x110dc
movq (%r14), %rax
movq %rax, 0x10(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x12cfa
movq 0xe2cc(%rip), %rcx      # 0x20fb8
cmpb $0x0, (%rcx)
je 0x12cf6
incl 0x8(%rax)
jmp 0x12cfa
lock
incl 0x8(%rax)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
leaq 0x10(%rsp), %rcx
callq 0xf64e
movq %rdx, %r8
movq %r15, %rdi
movl $0x1, %esi
movq %r13, %rdx
movl %eax, %ecx
callq 0xf382
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x12d35
callq 0x65d6
incl %ebp
movq 0x50(%r12), %rax
movq 0x58(%r12), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movq %rbp, %rcx
cmpq %rbp, %rdx
ja 0x12c9c
movq 0x30(%rsp), %r12
movq 0x28(%r12), %r13
testq %r13, %r13
je 0x12df5
movl 0x8(%r13), %ebp
movq 0x10(%r13), %r12
movl 0x18(%r13), %esi
movq 0x20(%r13), %rdx
movq %rbx, %rdi
callq 0x110dc
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x110dc
movq (%r14), %rax
movq %rax, (%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x12db6
movq 0xe210(%rip), %rcx      # 0x20fb8
cmpb $0x0, (%rcx)
je 0x12db2
incl 0x8(%rax)
jmp 0x12db6
lock
incl 0x8(%rax)
leaq 0x20(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
movq %rsp, %rcx
callq 0xf64e
movq %rdx, %r8
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
movl %eax, %ecx
callq 0xf382
movq 0x8(%rsp), %rdi
testq %rdi, %rdi
je 0x12dec
callq 0x65d6
movq (%r13), %r13
jmp 0x12d5e
movq %rbx, %rdi
callq 0x11122
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x5511(%rip), %rsi      # 0x18331
movq %rax, %rdi
callq 0x5150
jmp 0x12e46
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x54f3(%rip), %rsi      # 0x18331
movq %rax, %rdi
callq 0x5150
movq 0xe1a3(%rip), %rsi      # 0x20ff0
movq 0xe15c(%rip), %rdx      # 0x20fb0
movq %r14, %rdi
callq 0x55d0
jmp 0x12e5e
movq %rax, %rbx
movq %r14, %rdi
callq 0x5280
jmp 0x12e99
movq %rax, %rbx
movl $0x68, %esi
movq %r15, %rdi
callq 0x5390
jmp 0x12e99
movq %rax, %rbx
movq 0x8(%rsp), %rdi
jmp 0x12e8f
movq %rax, %rbx
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x12e99
callq 0x65d6
movq %rbx, %rdi
callq 0x55e0