// File: /workspace/github_cpp_makefile_star2_O1/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 0x12f8e
movq %rdx, %r14
movq %rsi, %rbx
movq %rsi, %rdi
callq 0x11276
movl %eax, %ebp
movq %rdx, (%rsp)
movq %rbx, %rdi
callq 0x11276
movl %eax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
cmpl $0x6, %ebp
jne 0x12fac
cmpl $0x5, %eax
jne 0x12fac
movl $0x68, %edi
callq 0x5380
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0xf2dc
movq %rbx, %rdi
movl $0x6, %esi
movq %r15, %rdx
callq 0x11230
movq (%rsp), %r12
movq 0x50(%r12), %rax
cmpq %rax, 0x58(%r12)
je 0x12ed5
xorl %ecx, %ecx
xorl %r13d, %r13d
movl %r13d, %edx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
movq %xmm0, %rbp
shlq $0x4, %rcx
movl (%rax,%rcx), %esi
movq 0x8(%rax,%rcx), %rdx
movq %rbx, %rdi
callq 0x11230
movq %rbx, %rdi
movl $0x1, %esi
movq %rbp, %rdx
callq 0x11230
movq (%r14), %rax
movq %rax, 0x18(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x20(%rsp)
testq %rax, %rax
je 0x12e7a
movq 0xe14c(%rip), %rcx      # 0x20fb8
cmpb $0x0, (%rcx)
je 0x12e76
incl 0x8(%rax)
jmp 0x12e7a
lock
incl 0x8(%rax)
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
leaq 0x18(%rsp), %rcx
callq 0xf6cc
movq %rdx, %r8
movq %r15, %rdi
movl $0x1, %esi
movq %rbp, %rdx
movl %eax, %ecx
callq 0xf3ea
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x12eb5
callq 0x6614
incl %r13d
movq 0x50(%r12), %rax
movq 0x58(%r12), %rdx
subq %rax, %rdx
sarq $0x4, %rdx
movq %r13, %rcx
cmpq %r13, %rdx
ja 0x12e1b
movq (%rsp), %rax
movq 0x28(%rax), %r13
testq %r13, %r13
je 0x12f77
movl 0x8(%r13), %ebp
movq 0x10(%r13), %r12
movl 0x18(%r13), %esi
movq 0x20(%r13), %rdx
movq %rbx, %rdi
callq 0x11230
movq %rbx, %rdi
movl %ebp, %esi
movq %r12, %rdx
callq 0x11230
movq (%r14), %rax
movq %rax, 0x8(%rsp)
movq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x12f36
movq 0xe090(%rip), %rcx      # 0x20fb8
cmpb $0x0, (%rcx)
je 0x12f32
incl 0x8(%rax)
jmp 0x12f36
lock
incl 0x8(%rax)
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
movl $0x2, %edx
leaq 0x8(%rsp), %rcx
callq 0xf6cc
movq %rdx, %r8
movq %r15, %rdi
movl %ebp, %esi
movq %r12, %rdx
movl %eax, %ecx
callq 0xf3ea
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x12f6e
callq 0x6614
movq (%r13), %r13
jmp 0x12edd
movq %rbx, %rdi
callq 0x11276
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 0x538f(%rip), %rsi      # 0x18331
movq %rax, %rdi
callq 0x5150
jmp 0x12fc8
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x5371(%rip), %rsi      # 0x18331
movq %rax, %rdi
callq 0x5150
movq 0xe021(%rip), %rsi      # 0x20ff0
movq 0xdfda(%rip), %rdx      # 0x20fb0
movq %r14, %rdi
callq 0x55d0
jmp 0x12fe0
movq %rax, %rbx
movq %r14, %rdi
callq 0x5280
jmp 0x1301b
movq %rax, %rbx
movl $0x68, %esi
movq %r15, %rdi
callq 0x5390
jmp 0x1301b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
jmp 0x13011
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1301b
callq 0x6614
movq %rbx, %rdi
callq 0x55e0