// File: /workspace/github_cpp_makefile_star2_O2/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 $0x48, %rsp
movq %rdx, 0x10(%rsp)
cmpl $0x2, %edi
jne 0x10c28
movq %rsi, %rbx
movq %rsi, %rdi
callq 0xf1b4
movl %eax, %ebp
movq %rdx, %r15
movq %rbx, %rdi
callq 0xf1b4
movl %eax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
cmpl $0x6, %ebp
jne 0x10c44
cmpl $0x5, %eax
jne 0x10c44
pushq $0x68
popq %rdi
callq 0x5390
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %rbx, %rsi
callq 0xd80c
pushq $0x6
popq %rsi
movq %rbx, %rdi
movq 0x8(%rsp), %rdx
callq 0xf190
xorl %ebp, %ebp
pushq $0x1
popq %r13
movl %ebp, %ebp
movq 0x50(%r15), %rax
movq 0x58(%r15), %rcx
subq %rax, %rcx
sarq $0x4, %rcx
cmpq %rbp, %rcx
jbe 0x10b96
cvtsi2sd %rbp, %xmm0
movq %xmm0, %r14
movq %rbp, %rcx
shlq $0x4, %rcx
movl (%rax,%rcx), %esi
movq 0x8(%rax,%rcx), %rdx
movq %rbx, %rdi
callq 0xf190
movq %rbx, %rdi
movl %r13d, %esi
movq %r14, %rdx
callq 0xf190
leaq 0x18(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x6356
leaq 0x28(%rsp), %rdi
movq %rbx, %r12
movq %rbx, %rsi
pushq $0x2
popq %rdx
leaq 0x18(%rsp), %rcx
callq 0xdb52
movq %rdx, %r8
movq 0x8(%rsp), %rdi
movl %r13d, %esi
movq %r14, %rdx
movl %eax, %ecx
callq 0xd90c
leaq 0x20(%rsp), %rdi
callq 0x638a
incl %ebp
movq %r12, %rbx
jmp 0x10b01
addq $0x28, %r15
leaq 0x40(%rsp), %r12
leaq 0x38(%rsp), %rbp
movq (%r15), %r15
testq %r15, %r15
je 0x10c11
movl 0x8(%r15), %r14d
movq 0x10(%r15), %r13
movl 0x18(%r15), %esi
movq 0x20(%r15), %rdx
movq %rbx, %rdi
callq 0xf190
movq %rbx, %rdi
movl %r14d, %esi
movq %r13, %rdx
callq 0xf190
movq %rbp, %rdi
movq 0x10(%rsp), %rsi
callq 0x6356
leaq 0x28(%rsp), %rdi
movq %rbx, %rsi
pushq $0x2
popq %rdx
movq %rbp, %rcx
callq 0xdb52
movq %rdx, %r8
movq 0x8(%rsp), %rdi
movl %r14d, %esi
movq %r13, %rdx
movl %eax, %ecx
callq 0xd90c
movq %r12, %rdi
callq 0x638a
jmp 0x10ba4
movq %rbx, %rdi
callq 0xf1b4
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x51b0
movq %rax, %r14
leaq 0x4707(%rip), %rsi      # 0x15341
movq %rax, %rdi
callq 0x5120
jmp 0x10c5e
pushq $0x10
popq %rdi
callq 0x51b0
movq %rax, %r14
leaq 0x46eb(%rip), %rsi      # 0x15341
movq %rax, %rdi
callq 0x5120
movq 0xf38b(%rip), %rsi      # 0x1fff0
movq 0xf33c(%rip), %rdx      # 0x1ffa8
movq %r14, %rdi
callq 0x55f0
jmp 0x10c76
movq %rax, %rbx
movq %r14, %rdi
callq 0x5290
jmp 0x10caa
movq %rax, %rbx
pushq $0x68
popq %rsi
movq 0x8(%rsp), %rdi
callq 0x53a0
jmp 0x10caa
movq %rax, %rbx
movq %r12, %rdi
jmp 0x10ca5
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x638a
movq %rbx, %rdi
callq 0x5600