// File: /workspace/github_c_makefile_star2_O3/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, 0x104a8(%rip)     # 0x19948
js 0x96c7
movl 0x1049c(%rip), %eax     # 0x19948
cmpl $0x7d1, %eax            # imm = 0x7D1
jge 0x96d0
movl %edi, %ebp
testl %edi, %edi
js 0x96ba
movq 0xfe88(%rip), %rdx      # 0x19350
movl %ebp, %r14d
testb $0x9, (%rdx,%r14)
jne 0x96ba
movq 0xfe63(%rip), %rax      # 0x19340
movl (%rax,%r14,4), %ecx
cmpl 0x10151(%rip), %ecx     # 0x19638
je 0x96ba
movl %esi, %ebx
incl 0x10453(%rip)           # 0x19948
movl (%rax,%r14,4), %ecx
cmpl 0x10229(%rip), %ecx     # 0x19728
jne 0x9562
movl 0xfc69(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x30e7
movl %eax, 0xfc5a(%rip)      # 0x19170
movq 0xfe2b(%rip), %rax      # 0x19348
movslq (%rax,%r14,4), %rcx
movl (%rax,%rcx,4), %edi
movl %ebx, %esi
callq 0x93bd
movq 0xfe0e(%rip), %rcx      # 0x19340
movq 0xfe0f(%rip), %rdx      # 0x19348
movslq (%rdx,%r14,4), %rdx
movl (%rcx,%rdx,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x30e7
movq 0xfdf0(%rip), %rcx      # 0x19340
movl (%rcx,%r14,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x30e7
jmp 0x95f4
cmpl 0x103d8(%rip), %ecx     # 0x19940
je 0x95be
cmpl 0x103dc(%rip), %ecx     # 0x1994c
je 0x95be
testl %ecx, %ecx
js 0x96a9
testb $0x8, (%rdx,%rcx)
je 0x96a9
cmpl $-0x12, (%rax,%rcx,4)
jne 0x96a9
movl 0xfc24(%rip), %esi      # 0x191b8
cmpl $-0x1, %esi
je 0x96a9
movq 0xfda4(%rip), %rdx      # 0x19348
movslq %esi, %rsi
movslq (%rax,%rsi,4), %r15
cmpl %ecx, (%rax,%r15,4)
je 0x9605
movl (%rdx,%rsi,4), %esi
cmpl $-0x1, %esi
jne 0x95a4
jmp 0x96a9
movl 0xfbac(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x30e7
movl %eax, 0xfb9d(%rip)      # 0x19170
movl %ebp, %edi
callq 0x99f7
movq 0xfd5f(%rip), %rcx      # 0x19340
movslq 0xfb88(%rip), %rdx      # 0x19170
movl %eax, (%rcx,%rdx,4)
movl %eax, %edi
movl %ebx, %esi
callq 0x9492
movl %eax, %ebp
movl $0x1, %edi
callq 0x335c
jmp 0x96b4
cmpl $-0x1, %r15d
je 0x96a9
movl 0xfb5b(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x30e7
movl %eax, 0xfb4c(%rip)      # 0x19170
movq 0xfd1d(%rip), %rax      # 0x19348
movl (%rax,%r14,4), %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x30e7
movl 0xfff7(%rip), %edi      # 0x19638
movl %eax, %esi
xorl %edx, %edx
callq 0x30e7
movl %eax, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x30e7
movq 0xfce9(%rip), %rcx      # 0x19348
movl (%rcx,%r15,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x30e7
movl 0x100a6(%rip), %edi     # 0x19718
movl %eax, %esi
xorl %edx, %edx
callq 0x30e7
movl %eax, %edi
movl $0x1, %esi
callq 0x9aff
movl %eax, %ebp
movq 0xfcb0(%rip), %rax      # 0x19340
movslq 0xfad9(%rip), %rcx      # 0x19170
movl %ebp, (%rax,%rcx,4)
testl %ebx, %ebx
je 0x95f6
movl %ebp, %edi
jmp 0x95ed
movl %ebp, %edi
movl %ebx, %esi
callq 0x93bd
movl %eax, %ebp
decl 0x1028e(%rip)           # 0x19948
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9f9c(%rip), %rdi      # 0x1366a
jmp 0x96d7
leaq 0xa19f(%rip), %rdi      # 0x13876
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x2643