// File: /workspace/github_c_makefile_star2_O1/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, 0x10369(%rip)     # 0x19948
js 0x9809
movl 0x1035d(%rip), %eax     # 0x19948
cmpl $0x7d1, %eax            # imm = 0x7D1
jge 0x9812
movl %edi, %ebp
testl %edi, %edi
js 0x97fc
movq 0xfd49(%rip), %rdx      # 0x19350
movl %ebp, %r14d
testb $0x9, (%rdx,%r14)
jne 0x97fc
movq 0xfd24(%rip), %rax      # 0x19340
movl (%rax,%r14,4), %ecx
cmpl 0x10012(%rip), %ecx     # 0x19638
je 0x97fc
movl %esi, %ebx
incl 0x10314(%rip)           # 0x19948
movl (%rax,%r14,4), %ecx
cmpl 0x100ea(%rip), %ecx     # 0x19728
jne 0x96a1
movl 0xfb2a(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x3162
movl %eax, 0xfb1b(%rip)      # 0x19170
movq 0xfcec(%rip), %rax      # 0x19348
movslq (%rax,%r14,4), %rcx
movl (%rax,%rcx,4), %edi
movl %ebx, %esi
callq 0x94fc
movq 0xfccf(%rip), %rcx      # 0x19340
movq 0xfcd0(%rip), %rdx      # 0x19348
movslq (%rdx,%r14,4), %rdx
movl (%rcx,%rdx,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x3162
movq 0xfcb1(%rip), %rcx      # 0x19340
movl (%rcx,%r14,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x3162
jmp 0x9731
cmpl 0x10299(%rip), %ecx     # 0x19940
je 0x96fb
cmpl 0x1029d(%rip), %ecx     # 0x1994c
je 0x96fb
testl %ecx, %ecx
js 0x97eb
testb $0x8, (%rdx,%rcx)
je 0x97eb
cmpl $-0x12, (%rax,%rcx,4)
jne 0x97eb
movl 0xfae5(%rip), %esi      # 0x191b8
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
cmpl $-0x1, %esi
je 0x9745
movq 0xfc63(%rip), %rdx      # 0x19348
movslq %esi, %rsi
movslq (%rax,%rsi,4), %rdi
cmpl %ecx, (%rax,%rdi,4)
je 0x9742
movl (%rdx,%rsi,4), %esi
cmpl $-0x1, %esi
jne 0x96e5
jmp 0x9745
movl 0xfa6f(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x3162
movl %eax, 0xfa60(%rip)      # 0x19170
movl %ebp, %edi
callq 0x9b40
movq 0xfc22(%rip), %rcx      # 0x19340
movslq 0xfa4b(%rip), %rdx      # 0x19170
movl %eax, (%rcx,%rdx,4)
movl %eax, %edi
movl %ebx, %esi
callq 0x95d1
movl %eax, %ebp
movl $0x1, %edi
callq 0x33d7
jmp 0x97f6
movl %edi, %r15d
cmpl $-0x1, %r15d
je 0x97eb
movl 0xfa1b(%rip), %esi      # 0x19170
movl %ebp, %edi
xorl %edx, %edx
callq 0x3162
movl %eax, 0xfa0c(%rip)      # 0x19170
movq 0xfbdd(%rip), %rax      # 0x19348
movl (%rax,%r14,4), %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x3162
movl 0xfeb7(%rip), %edi      # 0x19638
movl %eax, %esi
xorl %edx, %edx
callq 0x3162
movl %eax, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
xorl %edx, %edx
callq 0x3162
movq 0xfba9(%rip), %rcx      # 0x19348
movslq %r15d, %rdx
movl (%rcx,%rdx,4), %edi
movl %eax, %esi
xorl %edx, %edx
callq 0x3162
movl 0xff64(%rip), %edi      # 0x19718
movl %eax, %esi
xorl %edx, %edx
callq 0x3162
movl %eax, %edi
movl $0x1, %esi
callq 0x9c5e
movl %eax, %ebp
movq 0xfb6e(%rip), %rax      # 0x19340
movslq 0xf997(%rip), %rcx      # 0x19170
movl %ebp, (%rax,%rcx,4)
testl %ebx, %ebx
je 0x9733
movl %ebp, %edi
jmp 0x972a
movl %ebp, %edi
movl %ebx, %esi
callq 0x94fc
movl %eax, %ebp
decl 0x1014c(%rip)           # 0x19948
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq 0x9e2a(%rip), %rdi      # 0x1363a
jmp 0x9819
leaq 0xa02d(%rip), %rdi      # 0x13846
movl $0xfffffffc, %esi       # imm = 0xFFFFFFFC
callq 0x264c