// File: /workspace/github_cpp_makefile_star2_O1/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 0xf7cd
cmpl $0x5, %eax
jne 0xf877
movq 0x8(%r14), %r8
movq 0x38(%r8), %rax
subq 0x30(%r8), %rax
sarq $0x3, %rax
movl %ebp, %r13d
cmpq %r13, %rax
jne 0xf895
addq $0x18, %r8
leaq 0x10(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x8(%rsp), %rsi
leaq 0x7(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0xd344
testl %ebp, %ebp
je 0xf775
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 0x11276
movq %rdx, %rcx
movq %r15, %rdi
movq %r12, %rsi
movl %eax, %edx
callq 0x10c8e
incq %rbp
cmpq %rbp, %r13
jne 0xf742
movq 0x8(%rsp), %rdi
movq (%rbx), %rax
movq %rax, 0x10(%rdi)
addq $0x18, %rdi
addq $0x8, %rbx
movq %rbx, %rsi
callq 0xd2fe
movq 0x8(%r14), %rax
movq 0x28(%rax), %rsi
leaq 0x40(%rsp), %rdi
callq 0x101cc
movq 0x8(%rsp), %rcx
movq 0x10(%rsp), %rax
movq %rcx, 0x30(%rsp)
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0xf815
movq 0x117f5(%rip), %rcx     # 0x20fb8
cmpb $0x0, (%rcx)
je 0xf811
incl 0x8(%rax)
jmp 0xf815
movq 0x8(%r14), %rax
movq (%rbx), %rcx
movq %rcx, 0x20(%rsp)
movq 0x8(%rbx), %rcx
movq %rcx, 0x28(%rsp)
testq %rcx, %rcx
je 0xf7fc
movq 0x117ca(%rip), %rdx     # 0x20fb8
cmpb $0x0, (%rdx)
je 0xf7f8
incl 0x8(%rcx)
jmp 0xf7fc
lock
incl 0x8(%rcx)
leaq 0x20(%rsp), %rdx
movl %ebp, %edi
callq *%rax
movl %eax, %ebx
movq %rdx, %r14
movq 0x28(%rsp), %rdi
jmp 0xf859
lock
incl 0x8(%rax)
movq 0x18(%rsp), %rdx
leaq 0x40(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0xc2bc
movl %eax, %ebx
movq %rdx, %r14
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xf83d
callq 0x6614
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf854
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x5390
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf863
callq 0x6614
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 0x8657(%rip), %rsi      # 0x17ee2
movq %rax, %rdi
callq 0x5150
jmp 0xf8b1
movl $0x10, %edi
callq 0x51b0
movq %rax, %r14
leaq 0x8615(%rip), %rsi      # 0x17ebe
movq %rax, %rdi
callq 0x5150
movq 0x11738(%rip), %rsi     # 0x20ff0
movq 0x116f1(%rip), %rdx     # 0x20fb0
movq %r14, %rdi
callq 0x55d0
jmp 0xf8c9
movq %rax, %rbx
movq %r14, %rdi
callq 0x5280
jmp 0xf91f
movq %rax, %rbx
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0xf8e8
callq 0x6614
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0xf910
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x5390
jmp 0xf910
jmp 0xf90d
movq %rax, %rbx
movq 0x28(%rsp), %rdi
jmp 0xf915
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xf91f
callq 0x6614
movq %rbx, %rdi
callq 0x55e0
nop