// File: /workspace/github_c_makefile_star2_O2/hughbarney[P]zepl/lisp.c
// Function: evalExpr
Object *evalExpr(Object ** object, Object ** env, GC_PARAM)
{
	GC_TRACE(gcObject, *object);
	GC_TRACE(gcEnv, *env);

	GC_TRACE(gcFunc, nil);
	GC_TRACE(gcArgs, nil);
	GC_TRACE(gcBody, nil);

	for (;;) {
		if ((*gcObject)->type == TYPE_SYMBOL)
			return envLookup(*gcObject, *gcEnv);
		if ((*gcObject)->type != TYPE_CONS)
			return *gcObject;

		*gcFunc = (*gcObject)->car;
		*gcArgs = (*gcObject)->cdr;

		*gcFunc = evalExpr(gcFunc, gcEnv, GC_ROOTS);
		*gcBody = nil;

		if ((*gcFunc)->type == TYPE_LAMBDA) {
			*gcBody = (*gcFunc)->body;
			*gcArgs = evalList(gcArgs, gcEnv, GC_ROOTS);
			*gcEnv = newEnv(gcFunc, gcArgs, GC_ROOTS);
			*gcObject = evalProgn(gcBody, gcEnv, GC_ROOTS);
		} else if ((*gcFunc)->type == TYPE_MACRO) {
			*gcObject = expandMacroTo(gcFunc, gcArgs, gcObject, GC_ROOTS);
		} else if ((*gcFunc)->type == TYPE_PRIMITIVE) {
			Primitive *primitive = &primitives[(*gcFunc)->primitive];
			int nArgs = 0;

			for (Object * args = *gcArgs; args != nil; args = args->cdr, nArgs++)
				if (args->type != TYPE_CONS)
					exceptionWithObject(args, "is not a list");

			if (nArgs < primitive->nMinArgs)
				exceptionWithObject(*gcFunc, "expects at least %d arguments", primitive->nMinArgs);
			if (nArgs > primitive->nMaxArgs && primitive->nMaxArgs >= 0)
				exceptionWithObject(*gcFunc, "expects at most %d arguments", primitive->nMaxArgs);
			if (primitive->nMaxArgs < 0 && nArgs % -primitive->nMaxArgs)
				exceptionWithObject(*gcFunc, "expects a multiple of %d arguments", -primitive->nMaxArgs);

			switch ((*gcFunc)->primitive) {
			case PRIMITIVE_QUOTE:
				return (*gcArgs)->car;
			case PRIMITIVE_SETQ:
				return evalSetq(gcArgs, gcEnv, GC_ROOTS);
			case PRIMITIVE_PROGN:
				*gcObject = evalProgn(gcArgs, gcEnv, GC_ROOTS);
				break;
			case PRIMITIVE_IF:
				*gcObject = evalIf(gcArgs, gcEnv, GC_ROOTS);
				break;
			case PRIMITIVE_COND:
				*gcObject = evalCond(gcArgs, gcEnv, GC_ROOTS);
				break;
			case PRIMITIVE_LAMBDA:
				return evalLambda(gcArgs, gcEnv, GC_ROOTS);
			case PRIMITIVE_MACRO:
				return evalMacro(gcArgs, gcEnv, GC_ROOTS);
			default:
				*gcArgs = evalList(gcArgs, gcEnv, GC_ROOTS);
				return primitive->eval(gcArgs, GC_ROOTS);
			}
		} else
			exceptionWithObject(*gcFunc, "is not a function");
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
pushq $0x3
popq %rcx
leaq 0xb0(%rsp), %r8
movl %ecx, -0x10(%r8)
andq $0x0, -0x8(%r8)
movq (%rdi), %rax
movq %rax, (%r8)
movq %rdx, 0x8(%r8)
leaq 0x88(%rsp), %rbx
movl %ecx, -0x10(%rbx)
andq $0x0, -0x8(%rbx)
movq (%rsi), %rdx
movq %rdx, (%rbx)
leaq 0xa0(%rsp), %rdx
leaq 0x60(%rsp), %r12
movl %ecx, -0x10(%r12)
andq $0x0, -0x8(%r12)
movq %rdx, 0x8(%rbx)
movq 0x5dbd(%rip), %rdx      # 0xc208
movq %rdx, (%r12)
leaq 0x38(%rsp), %r15
movl %ecx, -0x10(%r15)
andq $0x0, -0x8(%r15)
leaq 0x78(%rsp), %rsi
movq %rsi, 0x8(%r12)
movq %rdx, (%r15)
leaq 0x10(%rsp), %rsi
movl %ecx, -0x10(%rsi)
andq $0x0, -0x8(%rsi)
leaq 0x50(%rsp), %rcx
movq %rcx, 0x8(%r15)
movq %rdx, (%rsi)
leaq 0x28(%rsp), %rcx
movq %rcx, 0x8(%rsi)
movq %rsp, %rbp
leaq 0xfa6(%rip), %r14       # 0x743c
movl (%rax), %ecx
cmpl $0x3, %ecx
jne 0x65e7
movq 0x10(%rax), %rcx
movq %rcx, 0x60(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movq %r12, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x63e3
movq %rax, %r8
movq %rax, 0x60(%rsp)
movq 0x5d38(%rip), %rcx      # 0xc208
movq %rcx, 0x10(%rsp)
movl (%rax), %eax
cmpl $0x6, %eax
je 0x653e
cmpl $0x5, %eax
je 0x6526
cmpl $0x4, %eax
jne 0x6674
movq 0x18(%r8), %rax
movq %rax, 0x10(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x6a32
movq %rax, 0x38(%rsp)
movq %r12, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x4a2f
movq %rax, 0x88(%rsp)
leaq 0x10(%rsp), %rdi
jmp 0x65af
movq %r12, %rdi
movq %r15, %rsi
leaq 0xb0(%rsp), %rdx
movq %rbp, %rcx
callq 0x69a7
jmp 0x65ba
movslq 0x10(%r8), %r9
imulq $0x18, %r9, %r13
leaq 0x5cd3(%rip), %rax      # 0xc220
addq %rax, %r13
xorl %eax, %eax
movq 0x38(%rsp), %rsi
movq %rsi, %rdi
cmpq %rcx, %rdi
je 0x6570
cmpl $0x3, (%rdi)
jne 0x6666
movq 0x18(%rdi), %rdi
incl %eax
jmp 0x655a
movl 0x8(%r13), %edx
cmpl %edx, %eax
jl 0x6680
movl 0xc(%r13), %ecx
cmpl %eax, %ecx
jb 0x668c
testl %ecx, %ecx
jns 0x659a
negl %ecx
xorl %edx, %edx
divl %ecx
testl %edx, %edx
jne 0x6695
cmpl $0x6, %r9d
ja 0x661e
movl %r9d, %eax
movslq (%r14,%rax,4), %rax
addq %r14, %rax
jmpq *%rax
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x66a8
movq %rax, 0xb0(%rsp)
jmp 0x6496
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x672d
jmp 0x65ba
movq %r15, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x6787
jmp 0x65ba
cmpl $0x2, %ecx
jne 0x65fc
movq 0x88(%rsp), %rsi
movq %rax, %rdi
callq 0x526d
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsp, %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x686d
jmp 0x65fc
movq %rsp, %r14
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x6a32
movq %rax, 0x38(%rsp)
movq %r15, %rdi
movq %r14, %rsi
callq *0x10(%r13)
jmp 0x65fc
movq %rsp, %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x62c9
jmp 0x65fc
movq 0x10(%rsi), %rax
jmp 0x65fc
movq %rsp, %rdx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x68c5
jmp 0x65fc
leaq 0xe82(%rip), %rsi       # 0x74ef
xorl %eax, %eax
callq 0x4186
leaq 0x133f(%rip), %rsi      # 0x79ba
movq %r8, %rdi
jmp 0x666d
leaq 0xe93(%rip), %rsi       # 0x751a
movq %r8, %rdi
jmp 0x66a1
leaq 0xe6a(%rip), %rsi       # 0x74fd
jmp 0x669c
leaq 0x12fb(%rip), %rsi      # 0x7997
movq %r8, %rdi
movl %ecx, %edx
xorl %eax, %eax
callq 0x4186