// File: /workspace/github_cpp_makefile_star2_O3/iamlouk[P]asbi/src/types.cc
// Function: asbi::Value::call(asbi::Context*, unsigned int, std::shared_ptr<asbi::Env>) const
Value Value::call(Context *ctx, unsigned int n, std::shared_ptr<Env> callerenv) const {
	switch (type) {
	case type_t::Lambda:{
		if (_lambda->argnames.size() != n)
			throw std::runtime_error("callable argnum does not match call");

		auto lbdenv = std::make_shared<Env>(ctx, _lambda->env);
		for (unsigned int i = 0; i < n; ++i)
			lbdenv->decl(_lambda->argnames[i], ctx->pop());

		lbdenv->caller = callerenv;
		return execute(*_lambda->ops, lbdenv, ctx);
	}
	case type_t::Macro:
		return _macro(n, ctx, callerenv);
	default:
		throw std::runtime_error("not callable");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movl %edx, %ebp
movq %rdi, %r14
movq %rsi, 0x18(%rsp)
movl (%rdi), %eax
cmpl $0x7, %eax
je 0xf74e
cmpl $0x5, %eax
jne 0xf7f8
movq 0x8(%r14), %r8
movq 0x38(%r8), %r13
subq 0x30(%r8), %r13
sarq $0x3, %r13
movl %ebp, %eax
cmpq %rax, %r13
jne 0xf816
addq $0x18, %r8
leaq 0x10(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x8(%rsp), %rsi
leaq 0x7(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0xd21a
testl %ebp, %ebp
je 0xf6f6
xorl %ebp, %ebp
movq 0x8(%rsp), %r15
movq 0x8(%r14), %rax
movq 0x30(%rax), %rax
movq (%rax,%rbp,8), %r12
movq 0x18(%rsp), %rdi
callq 0x11122
movq %rdx, %rcx
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x10b4e
incq %rbp
cmpq %rbp, %r13
jne 0xf6c3
movq 0x8(%rsp), %rdi
movq (%rbx), %rax
movq %rax, 0x10(%rdi)
addq $0x18, %rdi
addq $0x8, %rbx
movq %rbx, %rsi
callq 0xd1d0
movq 0x8(%r14), %rax
movq 0x28(%rax), %rsi
leaq 0x40(%rsp), %rdi
callq 0x10110
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xf796
movq 0x11874(%rip), %rcx     # 0x20fb8
cmpb $0x0, (%rcx)
je 0xf792
incl 0x8(%rax)
jmp 0xf796
movq 0x8(%r14), %rax
movq (%rbx), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rbx), %rcx
movq %rcx, 0x28(%rsp)
testq %rcx, %rcx
je 0xf77d
movq 0x11849(%rip), %rdx     # 0x20fb8
cmpb $0x0, (%rdx)
je 0xf779
incl 0x8(%rcx)
jmp 0xf77d
lock
incl 0x8(%rcx)
leaq 0x20(%rsp), %rdx
movl %ebp, %edi
callq *%rax
movl %eax, %ebx
movq %rdx, %r14
movq 0x28(%rsp), %rdi
jmp 0xf7da
lock
incl 0x8(%rax)
movq 0x18(%rsp), %rdx
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xc19c
movl %eax, %ebx
movq %rdx, %r14
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xf7be
callq 0x65d6
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf7d5
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x5390
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf7e4
callq 0x65d6
movl %ebx, %eax
movq %r14, %rdx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x86d6(%rip), %rsi      # 0x17ee2
movq %rax, %rdi
callq 0x5150
jmp 0xf832
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x8694(%rip), %rsi      # 0x17ebe
movq %rax, %rdi
callq 0x5150
movq 0x117b7(%rip), %rsi     # 0x20ff0
movq 0x11770(%rip), %rdx     # 0x20fb0
movq %r14, %rdi
callq 0x55d0
jmp 0xf84a
movq %rax, %rbx
movq %r14, %rdi
callq 0x5280
jmp 0xf8a0
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xf869
callq 0x65d6
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf891
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x5390
jmp 0xf891
jmp 0xf88e
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0xf896
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf8a0
callq 0x65d6
movq %rbx, %rdi
callq 0x55e0