// File: /workspace/github_c_makefile_star2_O1/georgeweigt[P]eigenmath/eigenmath.c
// Function: eval_user_function
void
eval_user_function(struct atom *p1)
{
	int h, i;
	struct atom *FUNC_NAME, *FUNC_ARGS, *FUNC_DEFN;

	FUNC_NAME = car(p1);
	FUNC_ARGS = cdr(p1);

	FUNC_DEFN = get_usrfunc(FUNC_NAME);

	// undefined function?

	if (FUNC_DEFN == symbol(NIL)) {
		if (FUNC_NAME == symbol(D_LOWER)) {
			expanding++;
			eval_derivative(p1);
			expanding--;
			return;
		}
		h = tos;
		push(FUNC_NAME);
		while (iscons(FUNC_ARGS)) {
			push(car(FUNC_ARGS));
			evalg();
			FUNC_ARGS = cdr(FUNC_ARGS);
		}
		list(tos - h);
		return;
	}

	save_symbol(symbol(ARG1));
	save_symbol(symbol(ARG2));
	save_symbol(symbol(ARG3));
	save_symbol(symbol(ARG4));
	save_symbol(symbol(ARG5));
	save_symbol(symbol(ARG6));
	save_symbol(symbol(ARG7));
	save_symbol(symbol(ARG8));
	save_symbol(symbol(ARG9));

	push(FUNC_DEFN); // make visible to garbage collector

	// eval all args before changing bindings

	for (i = 0; i < 9; i++) {
		push(car(FUNC_ARGS));
		evalg();
		FUNC_ARGS = cdr(FUNC_ARGS);
	}

	set_symbol(symbol(ARG9), pop(), symbol(NIL));
	set_symbol(symbol(ARG8), pop(), symbol(NIL));
	set_symbol(symbol(ARG7), pop(), symbol(NIL));
	set_symbol(symbol(ARG6), pop(), symbol(NIL));
	set_symbol(symbol(ARG5), pop(), symbol(NIL));
	set_symbol(symbol(ARG4), pop(), symbol(NIL));
	set_symbol(symbol(ARG3), pop(), symbol(NIL));
	set_symbol(symbol(ARG2), pop(), symbol(NIL));
	set_symbol(symbol(ARG1), pop(), symbol(NIL));

	evalg(); // eval FUNC_DEFN

	p1 = pop();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	restore_symbol();
	push(p1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
leaq 0x8(%rdi), %rcx
cmpb $0x1, 0x10(%rdi)
leaq 0x372f8(%rip), %r15     # 0x40a00
movq %r15, %rax
cmoveq %rdi, %rax
movq (%rax), %rax
cmovneq %r15, %rcx
cmpb $0x3, 0x10(%rax)
jne 0x9a4f
movq (%rcx), %r12
movl 0x8(%rax), %ecx
leaq 0x102823(%rip), %r14    # 0x10bf50
movq (%r14,%rcx,8), %rbx
testq %rbx, %rbx
je 0x99df
cmpq 0x372bf(%rip), %rbx     # 0x40a00
je 0x99df
movq 0x39b9a(%rip), %rdi     # 0x432e8
callq 0xe73e
movq 0x39b96(%rip), %rdi     # 0x432f0
callq 0xe73e
movq 0x39b92(%rip), %rdi     # 0x432f8
callq 0xe73e
movq 0x39b8e(%rip), %rdi     # 0x43300
callq 0xe73e
movq 0x39b8a(%rip), %rdi     # 0x43308
callq 0xe73e
movq 0x39b86(%rip), %rdi     # 0x43310
callq 0xe73e
movq 0x39b82(%rip), %rdi     # 0x43318
callq 0xe73e
movq 0x39b7e(%rip), %rdi     # 0x43320
callq 0xe73e
movq 0x39b7a(%rip), %rdi     # 0x43328
callq 0xe73e
movq %rbx, %rdi
callq 0x8b01
movl $0x9, %ebx
cmpb $0x1, 0x10(%r12)
movq %r15, %rax
cmoveq %r12, %rax
movq (%rax), %rdi
callq 0x8b01
callq 0x95ac
leaq 0x8(%r12), %rax
cmpb $0x1, 0x10(%r12)
cmovneq %r15, %rax
movq (%rax), %r12
decl %ebx
jne 0x97c0
movq 0x39b31(%rip), %r15     # 0x43328
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x371f2(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
leaq 0xfd2d7(%rip), %rbx     # 0x106af0
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x39af4(%rip), %r15     # 0x43320
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x371bd(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x39abe(%rip), %r15     # 0x43318
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x3718f(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x39a88(%rip), %r15     # 0x43310
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x37161(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x39a52(%rip), %r15     # 0x43308
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x37133(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x39a1c(%rip), %r15     # 0x43300
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x37105(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x399e6(%rip), %r15     # 0x432f8
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x370d7(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x399b0(%rip), %r15     # 0x432f0
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x370a9(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
movq 0x3997a(%rip), %r15     # 0x432e8
callq 0x8b78
cmpb $0x3, 0x10(%r15)
jne 0x9a4f
movq 0x3707b(%rip), %rcx     # 0x40a00
movl 0x8(%r15), %edx
movq %rax, (%rbx,%rdx,8)
movl 0x8(%r15), %eax
movq %rcx, (%r14,%rax,8)
callq 0x95ac
callq 0x8b78
movq %rax, %rbx
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
callq 0xe7a4
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8b01
cmpq 0x350e2(%rip), %rax     # 0x3eac8
je 0x9a35
movl 0x308ca(%rip), %ebx     # 0x3a2b8
movq %rax, %rdi
callq 0x8b01
cmpb $0x1, 0x10(%r12)
jne 0x9a20
movq (%r12), %rdi
callq 0x8b01
callq 0x95ac
leaq 0x8(%r12), %rax
cmpb $0x1, 0x10(%r12)
cmovneq %r15, %rax
movq (%rax), %r12
jmp 0x99f6
movl 0x30892(%rip), %edi     # 0x3a2b8
subl %ebx, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8ad9
incl 0xfd095(%rip)           # 0x106ad0
callq 0x1059e
decl 0xfd08a(%rip)           # 0x106ad0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21524(%rip), %rdi     # 0x2af7a
callq 0x77c8