// File: /workspace/github_c_makefile_star2_O3/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, %rbx
movq 0x30(%rdi), %rdi
callq 0x1518d
movq %rax, %r12
movq %rbx, 0x8(%rsp)
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %rdi
callq 0xd1e1
movq %rax, %r14
leaq 0x149df(%rip), %rax     # 0x1810d
leaq 0x20(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x1bbe3(%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 0x17288(%rip), %rbp     # 0x1a9e0
movq %rbp, 0x10(%rdi)
leaq 0x1b9dd(%rip), %rcx     # 0x1f140
movq %rcx, 0x18(%rdi)
movq %rax, 0x20(%rdi)
callq 0x16ea2
leaq 0x1c179(%rip), %rbx     # 0x1f8f0
cmpl $0x0, (%rbx)
je 0x37ba
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x37ba
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x194, 0xc(%rax)       # imm = 0x194
movq %r12, %rdi
callq 0xf0bc
leaq 0x1496e(%rip), %rdi     # 0x1811e
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f13
movq %r12, 0x10(%rsp)
movq %r14, %rdi
callq 0x150ee
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x1518d
movq %rax, %r14
movq %rax, %rdi
callq 0x150ee
movq %rax, %r12
movq %r14, %rdi
callq 0x1518d
movq %rax, %r14
movq %r12, %rdi
callq 0x150ee
movq %rax, %r13
cmpl $0x0, (%rbx)
je 0x383b
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x383b
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x19a, 0xc(%rax)       # imm = 0x19A
movq %r13, %rdi
callq 0xf0bc
leaq 0x148f7(%rip), %rdi     # 0x18128
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f13
movq %r12, %rdi
callq 0x1518d
movq %rax, %r12
cmpl $0x0, (%rbx)
je 0x3889
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3889
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x19c, 0xc(%rax)       # imm = 0x19C
movq %r12, %rdi
callq 0xf0bc
leaq 0x148b3(%rip), %rdi     # 0x18132
movq %rax, %rsi
xorl %eax, %eax
callq 0x16f13
cmpq 0x1b730(%rip), %r13     # 0x1efc0
je 0x39a2
movl %r13d, %eax
andl $0x3, %eax
cmpq $0x2, %rax
jne 0x3a01
movl $0x1, %edi
callq 0x3c98
cmpq %rax, %r13
je 0x3a15
xorl %edi, %edi
callq 0x3c98
cmpq %rax, %r13
je 0x3a15
cmpl $0x0, (%rbx)
je 0x3901
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3901
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1aa, 0xc(%rax)       # imm = 0x1AA
leaq 0x1486c(%rip), %rdi     # 0x18166
xorl %eax, %eax
callq 0x16f13
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x150cc
movq %r14, %rdi
movq %rax, %rsi
callq 0x150cc
leaq -0xb42(%rip), %rsi      # 0x2dde
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdd3a
movq %rax, %r15
leaq 0x1b956(%rip), %r14     # 0x1f290
movq %r14, %rdi
movq %r12, %rsi
callq 0x150cc
movq %rax, %rdi
movq %r15, %rsi
callq 0x150cc
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x150cc
movq %rax, %r15
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %r12
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %rdi
callq 0xd1a8
movq %r12, %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0xd43a
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rbx, %rdi
movq %rax, %rsi
movq %r14, %rdx
jmp 0x3acb
movl (%rbx), %eax
movq 0x10(%rsp), %rbx
cmpq 0x1b610(%rip), %rbx     # 0x1efc0
je 0x3bf5
testl %eax, %eax
je 0x39ed
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x39ed
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1a5, 0xc(%rax)       # imm = 0x1A5
leaq 0x14764(%rip), %rdi     # 0x1814a
xorl %eax, %eax
callq 0x16f13
leaq 0x14764(%rip), %rdi     # 0x18158
callq 0x1257b
movq %rax, %rdi
movq %rbx, %rsi
jmp 0x3a5f
testq %r13, %r13
sete %cl
testq %rax, %rax
setne %al
orb %cl, %al
je 0x3af0
cmpl $0x0, (%rbx)
je 0x3a4d
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3a4d
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1c4, 0xc(%rax)       # imm = 0x1C4
leaq 0x14761(%rip), %rdi     # 0x181a7
xorl %eax, %eax
callq 0x16f13
leaq 0x1475c(%rip), %rdi     # 0x181b0
callq 0x1257b
movq %rax, %rdi
movq %r13, %rsi
callq 0x150cc
leaq -0xff3(%rip), %rsi      # 0x2a78
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdd3a
movq %rax, %r15
leaq 0x14605(%rip), %rdi     # 0x1808a
callq 0x1257b
movq %rax, %r12
callq 0xd160
leaq 0x1b7f7(%rip), %rsi     # 0x1f290
movq %rax, %rdi
callq 0x150cc
movq %r12, %rdi
movq %rax, %rsi
callq 0x150cc
movq %rax, %rdi
movq %r14, %rsi
callq 0x150cc
movq %r15, %rdi
movq %rax, %rsi
callq 0x150cc
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0xde17
leaq 0x20(%rsp), %rdi
movl $0x1c7, 0xc(%rdi)       # imm = 0x1C7
callq 0x17027
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl (%rbx), %eax
movq 0x10(%rsp), %rcx
cmpq 0x1b4c2(%rip), %rcx     # 0x1efc0
je 0x3c55
testl %eax, %eax
je 0x3b3b
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3b3b
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1b9, 0xc(%rax)       # imm = 0x1B9
leaq 0x14660(%rip), %rdi     # 0x18194
xorl %eax, %eax
callq 0x16f13
movq %r13, %rdi
callq 0x150ee
movq %rax, %rbp
movq 0x10(%rsp), %r15
movq %r15, %rdi
callq 0x150ee
movq %rbp, %rdi
movq %rax, %rsi
callq 0x150cc
movq %r14, %rdi
movq %rax, %rsi
callq 0x150cc
leaq -0xd92(%rip), %rsi      # 0x2dde
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
movq %rax, %rdx
callq 0xdd3a
movq %rax, %r14
movq %r13, %rdi
callq 0x1518d
movq %rax, %rdi
movq %r12, %rsi
callq 0x150cc
movq %rax, %rdi
movq %r14, %rsi
callq 0x150cc
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x150cc
movq %rax, %r14
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %r12
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %rdi
callq 0xd1a8
movq %r12, %rdi
movq %rax, %rsi
movq %r14, %rdx
callq 0xd43a
movq 0x30(%rbx), %rdi
callq 0x150ee
movq %rax, %r14
movq %r15, %rdi
callq 0x1518d
jmp 0x3ac2
testl %eax, %eax
je 0x3c2c
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3c2c
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1a0, 0xc(%rax)       # imm = 0x1A0
leaq 0x14517(%rip), %rdi     # 0x1813c
xorl %eax, %eax
callq 0x16f13
movq %r12, %rdi
movq %r14, %rsi
callq 0x150cc
movq 0x18(%rsp), %rdi
movq %rax, %rsi
callq 0x150cc
movq 0x1b71d(%rip), %rsi     # 0x1f368
movq 0x8(%rsp), %rdi
jmp 0x3ac8
testl %eax, %eax
je 0x3c8c
movq (%r15), %rax
movq 0x50(%rax), %rax
movq %rbp, 0x10(%rax)
movq %rbp, %rdi
callq 0x16604
testl %eax, %eax
je 0x3c8c
movq (%r15), %rax
movq 0x50(%rax), %rax
movl $0x1b5, 0xc(%rax)       # imm = 0x1B5
leaq 0x144f5(%rip), %rdi     # 0x1817a
xorl %eax, %eax
callq 0x16f13
leaq 0x144f4(%rip), %rdi     # 0x18187
jmp 0x3a54