// File: /workspace/github_c_makefile_star2_O1/dalnefre[P]kernel_abe/schemer.c
// Function: apply_lambda_beh
BEH_DECL(apply_lambda_beh)
{
	CONS* args = WHAT;
	CONS* to;
	CONS* lambda;
	CONS* vars;
	CONS* body;
	CONS* env;
	CONS* p = MINE;
	CONS* state;
	CONS* msg;
	CONS* a;

	DBUG_ENTER("apply_lambda_beh");
	DBUG_PRINT("", ("args = %s", cons_to_str(args)));
	to = pr_head(p);
	p = pr_tail(p);
	lambda = pr_head(p);
	env = pr_tail(p);
	vars = lst_first(lambda);
	DBUG_PRINT("", ("vars = %s", cons_to_str(vars)));
	body = lst_rest(lambda);
	DBUG_PRINT("", ("body = %s", cons_to_str(body)));
	if (is_empty(vars)) {
		if (is_empty(args)) {
			/* evaluate body in extended environment */
			DBUG_PRINT("", ("evaluate body"));
			msg = mk_pair(body, env);
			msg = mk_pair(to, msg);
			SEND(eval_seq__actor, msg);
		} else {
			DBUG_PRINT("", ("too many args"));
			FAIL(env, mk_list(ATOM("too-many-args"), args));
		}
	} else if (is_symbol(vars)) {
		/* bind symbol to remaining args */
		DBUG_PRINT("", ("bind remaining args"));
		state = mk_pair(vars, args);
		state = mk_pair(env, state);
		a = ACTOR(binding_beh, state);
		state = mk_pair(NIL, body);
		state = mk_pair(state, a);
		state = mk_pair(to, state);
		BECOME(THIS, state);
		SEND(SELF, NIL);
	} else if (is_pair(vars)) {
		if (is_empty(args)) {
			DBUG_PRINT("", ("too few args"));
			FAIL(env, mk_list(ATOM("too-few-args"), vars));
		} else {
			/* extend environment with new binding */
			DBUG_PRINT("", ("extend environment"));
			state = mk_pair(lst_first(vars), lst_first(args));
			state = mk_pair(env, state);
			a = ACTOR(binding_beh, state);
			state = mk_pair(lst_rest(vars), body);
			state = mk_pair(state, a);
			state = mk_pair(to, state);
			BECOME(THIS, state);
			SEND(SELF, lst_rest(args));
		}
	} else {
		DBUG_PRINT("", ("bad form"));
		FAIL(env, mk_list(ATOM("bad-form"), vars));
	}
	DBUG_RETURN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %r13
movq 0x30(%rdi), %rdi
callq 0x15225
movq %rax, %r12
movq 0x30(%r13), %rdi
callq 0x15186
movq %rax, %rdi
callq 0xd2f1
movq %rax, %r14
leaq 0x14998(%rip), %rax     # 0x1810d
leaq 0x20(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x1bb9c(%rip), %r15     # 0x1f320
movq (%r15), %rax
movq 0x50(%rax), %rax
movl 0x8(%rax), %ecx
movl %ecx, 0x8(%rdi)
movl $0x193, 0xc(%rdi)       # imm = 0x193
leaq 0x17241(%rip), %rbp     # 0x1a9e0
movq %rbp, 0x10(%rdi)
leaq 0x1b996(%rip), %rcx     # 0x1f140
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x16ef2
leaq 0x1c132(%rip), %rbx     # 0x1f8f0
cmpl $0x0, (%rbx)
je 0x3801
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3801
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x194, 0xc(%rax)       # imm = 0x194
movq %r12, %rdi
callq 0xf17c
leaq 0x14927(%rip), %rdi     # 0x1811e
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f63
movq %r12, 0x8(%rsp)
movq %r14, %rdi
callq 0x15186
movq %rax, 0x10(%rsp)
movq %r14, %rdi
callq 0x15225
movq %rax, %r14
movq %rax, %rdi
callq 0x15186
movq %rax, %r12
movq %r14, %rdi
callq 0x15225
movq %rax, (%rsp)
movq %r12, %rdi
callq 0x15186
movq %rax, %r14
cmpl $0x0, (%rbx)
je 0x3883
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3883
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x19a, 0xc(%rax)       # imm = 0x19A
movq %r14, %rdi
callq 0xf17c
leaq 0x148af(%rip), %rdi     # 0x18128
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f63
movq %r12, %rdi
callq 0x15225
movq %rax, %r12
cmpl $0x0, (%rbx)
je 0x38d1
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x38d1
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x19c, 0xc(%rax)       # imm = 0x19C
movq %r12, %rdi
callq 0xf17c
leaq 0x1486b(%rip), %rdi     # 0x18132
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f63
cmpq 0x1b6e8(%rip), %r14     # 0x1efc0
je 0x3ac0
movq %r12, 0x18(%rsp)
movq %r13, %r12
movl %r14d, %r13d
andl $0x3, %r13d
cmpq $0x2, %r13
jne 0x39f5
movl $0x1, %edi
callq 0x3d66
cmpq %rax, %r14
je 0x39f5
xorl %edi, %edi
callq 0x3d66
cmpq %rax, %r14
je 0x39f5
cmpl $0x0, (%rbx)
je 0x3952
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3952
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1aa, 0xc(%rax)       # imm = 0x1AA
leaq 0x1481b(%rip), %rdi     # 0x18166
xorl %eax, %eax
callq 0x16f63
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x15164
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x15164
leaq -0xb34(%rip), %rsi      # 0x2e3e
movq %r12, %rbx
movq %r12, %rdi
movq %rax, %rdx
callq 0xde1a
movq %rax, %r15
leaq 0x1b906(%rip), %r14     # 0x1f290
movq %r14, %rdi
movq 0x18(%rsp), %rsi
callq 0x15164
movq %rax, %rdi
movq %r15, %rsi
callq 0x15164
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x15164
movq %rax, %r15
movq 0x30(%r12), %rdi
callq 0x15186
movq %rax, %r12
movq 0x30(%rbx), %rdi
callq 0x15186
movq %rax, %rdi
callq 0xd2b8
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0xd500
movq 0x30(%rbx), %rdi
callq 0x15186
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
jmp 0x3d41
testq %r14, %r14
sete %al
testq %r13, %r13
setne %cl
orb %al, %cl
je 0x3b22
cmpl $0x0, (%rbx)
movq %r12, %rbx
je 0x3a44
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3a44
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1c4, 0xc(%rax)       # imm = 0x1C4
leaq 0x1476a(%rip), %rdi     # 0x181a7
xorl %eax, %eax
callq 0x16f63
leaq 0x14765(%rip), %rdi     # 0x181b0
callq 0x1265c
movq %rax, %rdi
movq %r14, %rsi
callq 0x15164
leaq -0xf8a(%rip), %rsi      # 0x2ad8
movq %rbx, %rdi
movq %rax, %rdx
callq 0xde1a
movq %rax, %r15
leaq 0x14613(%rip), %rdi     # 0x1808a
callq 0x1265c
movq %rax, %r12
callq 0xd26a
leaq 0x1b805(%rip), %rsi     # 0x1f290
movq %rax, %rdi
callq 0x15164
movq %r12, %rdi
movq %rax, %rsi
callq 0x15164
movq %rax, %rdi
movq (%rsp), %r14
movq %r14, %rsi
callq 0x15164
movq %r15, %rdi
movq %rax, %rsi
callq 0x15164
movq %rbx, %rdi
jmp 0x3c26
movl (%rbx), %eax
movq 0x8(%rsp), %rbx
cmpq 0x1b4f2(%rip), %rbx     # 0x1efc0
je 0x3c2e
testl %eax, %eax
je 0x3b0b
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3b0b
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1a5, 0xc(%rax)       # imm = 0x1A5
leaq 0x14646(%rip), %rdi     # 0x1814a
xorl %eax, %eax
callq 0x16f63
leaq 0x14646(%rip), %rdi     # 0x18158
callq 0x1265c
movq %rax, %rdi
movq %rbx, %rsi
jmp 0x3cd6
movl (%rbx), %eax
movq 0x8(%rsp), %rcx
cmpq 0x1b490(%rip), %rcx     # 0x1efc0
movq %r12, %r13
je 0x3c8d
testl %eax, %eax
je 0x3b70
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3b70
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1b9, 0xc(%rax)       # imm = 0x1B9
leaq 0x1462b(%rip), %rdi     # 0x18194
xorl %eax, %eax
callq 0x16f63
movq %r14, %rdi
callq 0x15186
movq %rax, %rbp
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x15186
movq %rbp, %rdi
movq %rax, %rsi
callq 0x15164
movq (%rsp), %rdi
movq %rax, %rsi
callq 0x15164
leaq -0xd68(%rip), %rsi      # 0x2e3e
movq %r13, %rdi
movq %rax, %rdx
callq 0xde1a
movq %rax, %rbx
movq %r14, %rdi
callq 0x15225
movq %rax, %rdi
movq 0x18(%rsp), %rsi
callq 0x15164
movq %rax, %rdi
movq %rbx, %rsi
callq 0x15164
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x15164
movq %rax, %r14
movq 0x30(%r13), %rdi
callq 0x15186
movq %rax, %r12
movq 0x30(%r13), %rdi
callq 0x15186
movq %rax, %rdi
callq 0xd2b8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xd500
movq 0x30(%r13), %rdi
callq 0x15186
movq %rax, %r14
movq %r15, %rdi
callq 0x15225
movq %r13, %rdi
movq %r14, %rsi
jmp 0x3d3e
testl %eax, %eax
je 0x3c65
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3c65
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1a0, 0xc(%rax)       # imm = 0x1A0
leaq 0x144de(%rip), %rdi     # 0x1813c
xorl %eax, %eax
callq 0x16f63
movq %r12, %rdi
movq (%rsp), %rsi
callq 0x15164
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x15164
movq 0x1b6e3(%rip), %rsi     # 0x1f368
movq %r13, %rdi
jmp 0x3d3e
testl %eax, %eax
je 0x3cc4
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16664
testl %eax, %eax
je 0x3cc4
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1b5, 0xc(%rax)       # imm = 0x1B5
leaq 0x144bd(%rip), %rdi     # 0x1817a
xorl %eax, %eax
callq 0x16f63
leaq 0x144bc(%rip), %rdi     # 0x18187
callq 0x1265c
movq %rax, %rdi
movq %r14, %rsi
callq 0x15164
leaq -0x120a(%rip), %rsi     # 0x2ad8
movq %r13, %rdi
movq %rax, %rdx
callq 0xde1a
movq %rax, %r15
leaq 0x14393(%rip), %rdi     # 0x1808a
callq 0x1265c
movq %rax, %r12
callq 0xd26a
leaq 0x1b585(%rip), %rsi     # 0x1f290
movq %rax, %rdi
callq 0x15164
movq %r12, %rdi
movq %rax, %rsi
callq 0x15164
movq %rax, %rdi
movq (%rsp), %rbx
movq %rbx, %rsi
callq 0x15164
movq %r15, %rdi
movq %rax, %rsi
callq 0x15164
movq %r13, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xdef7
leaq 0x20(%rsp), %rdi
movl $0x1c7, 0xc(%rdi)       # imm = 0x1C7
callq 0x17077
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq