// File: /workspace/github_c_makefile_star2_O2/blakemcbride[P]LISP9/ls9.c
// Function: expand
cell expand(cell x, int r) {
	cell	n, m;

	if (Mxlev < 0) error("interrupted", UNDEF);
	if (Mxlev > MXMAX)
		error("too many levels of macro expansion", UNDEF);
	if (atomp(x)) {
		return x;
	}
	if (car(x) == S_quote) {
		return x;
	}
	Mxlev++;
	if (car(x) == S_lambda) {
		protect(x);
		n = mapexp(cddr(x), r);
		n = cons(cadr(x), n);
		n = cons(car(x), n);
		unprot(1);
		Mxlev--;
		return n;
	}
	if (car(x) == S_defun || car(x) == S_defmac) {
		protect(x);
		x = expanddef(x);
		car(Protected) = x;
		x = expand(x, r);
		unprot(1);
		Mxlev--;
		return x;
	}
	if (	symbolp(car(x)) &&
		(m = assq(car(x), Macros)) != NIL)
	{
		protect(x);
		n = cons(cdr(x), NIL);
		n = cons(S_quote, n);
		n = cons(n, NIL);
		n = cons(cdr(m), n);
		n = cons(S_apply, n);
		x = eval(n, 1);
		car(Protected) = x;
		if (r) x = expand(x, r);
		unprot(1);
		Mxlev--;
		return x;
	}
	x = mapexp(x, r);
	Mxlev--;
	return x;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
cmpl $0x0, 0xf478(%rip)      # 0x17948
js 0x86cd
movl 0xf46c(%rip), %eax      # 0x17948
cmpl $0x7d1, %eax            # imm = 0x7D1
jge 0x86d6
movl %edi, %ebp
testl %edi, %edi
js 0x86c0
movq 0xee58(%rip), %rax      # 0x17350
movl %ebp, %r15d
testb $0x9, (%rax,%r15)
jne 0x86c0
movq 0xee33(%rip), %rcx      # 0x17340
movl (%rcx,%r15,4), %edx
cmpl 0xf121(%rip), %edx      # 0x17638
je 0x86c0
movl %esi, %ebx
incl 0xf423(%rip)            # 0x17948
movl (%rcx,%r15,4), %edi
cmpl 0xf1f9(%rip), %edi      # 0x17728
jne 0x8592
movl 0xec39(%rip), %esi      # 0x17170
movl %ebp, %edi
xorl %edx, %edx
callq 0x2f8c
movl %eax, 0xec2a(%rip)      # 0x17170
movq 0xedfb(%rip), %rax      # 0x17348
movslq (%rax,%r15,4), %rcx
movl (%rax,%rcx,4), %edi
movl %ebx, %esi
callq 0x83fa
movq 0xedde(%rip), %rcx      # 0x17340
movq 0xeddf(%rip), %rdx      # 0x17348
movslq (%rdx,%r15,4), %rdx
movl (%rcx,%rdx,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x2f8c
movq 0xedc0(%rip), %rcx      # 0x17340
movl (%rcx,%r15,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x2f8c
jmp 0x86a3
cmpl 0xf3a8(%rip), %edi      # 0x17940
je 0x866d
cmpl 0xf3a8(%rip), %edi      # 0x1794c
je 0x866d
testl %edi, %edi
js 0x86af
testb $0x8, (%rax,%rdi)
je 0x86af
cmpl $-0x12, (%rcx,%rdi,4)
jne 0x86af
movl 0xebec(%rip), %esi      # 0x171b8
callq 0x2640
cmpl $-0x1, %eax
je 0x86af
movl %eax, %r14d
movl 0xeb8d(%rip), %esi      # 0x17170
movl %ebp, %edi
xorl %edx, %edx
callq 0x2f8c
movl %eax, 0xeb7e(%rip)      # 0x17170
movq 0xed4f(%rip), %rax      # 0x17348
movl (%rax,%r15,4), %edi
pushq $-0x1
popq %rbp
movl %ebp, %esi
xorl %edx, %edx
callq 0x2f8c
movl 0xf029(%rip), %edi      # 0x17638
movl %eax, %esi
xorl %edx, %edx
callq 0x2f8c
movl %eax, %edi
movl %ebp, %esi
xorl %edx, %edx
callq 0x2f8c
movq 0xed1e(%rip), %rcx      # 0x17348
movslq %r14d, %rdx
movl (%rcx,%rdx,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x2f8c
movl 0xf0d9(%rip), %edi      # 0x17718
movl %eax, %esi
xorl %edx, %edx
callq 0x2f8c
pushq $0x1
popq %rsi
movl %eax, %edi
callq 0x8adb
movl %eax, %ebp
movq 0xece5(%rip), %rax      # 0x17340
movslq 0xeb0e(%rip), %rcx      # 0x17170
movl %ebp, (%rax,%rcx,4)
testl %ebx, %ebx
je 0x86a5
movl %ebp, %edi
jmp 0x869c
movl 0xeafd(%rip), %esi      # 0x17170
movl %ebp, %edi
xorl %edx, %edx
callq 0x2f8c
movl %eax, 0xeaee(%rip)      # 0x17170
movl %ebp, %edi
callq 0x89d5
movq 0xecb0(%rip), %rcx      # 0x17340
movslq 0xead9(%rip), %rdx      # 0x17170
movl %eax, (%rcx,%rdx,4)
movl %eax, %edi
movl %ebx, %esi
callq 0x84c2
movl %eax, %ebp
pushq $0x1
popq %rdi
callq 0x31a9
jmp 0x86ba
movl %ebp, %edi
movl %ebx, %esi
callq 0x83fa
movl %eax, %ebp
decl 0xf288(%rip)            # 0x17948
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x7f56(%rip), %rdi      # 0x1062a
jmp 0x86dd
leaq 0x8159(%rip), %rdi      # 0x10836
pushq $-0x4
popq %rsi
callq 0x258a