// File: /workspace/github_c_makefile_star2_O3/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 0x3c1b0(%rip), %r15     # 0x45a00
movq %r15, %rax
cmoveq %rdi, %rax
movq (%rax), %rax
cmovneq %r15, %rcx
cmpb $0x3, 0x10(%rax)
jne 0x9c25
movq (%rcx), %r12
movl 0x8(%rax), %ecx
leaq 0x1076db(%rip), %r14    # 0x110f50
movq (%r14,%rcx,8), %rbx
testq %rbx, %rbx
je 0x9bb5
cmpq 0x3c177(%rip), %rbx     # 0x45a00
je 0x9bb5
movq 0x3ea52(%rip), %rdi     # 0x482e8
callq 0xf3a6
movq 0x3ea4e(%rip), %rdi     # 0x482f0
callq 0xf3a6
movq 0x3ea4a(%rip), %rdi     # 0x482f8
callq 0xf3a6
movq 0x3ea46(%rip), %rdi     # 0x48300
callq 0xf3a6
movq 0x3ea42(%rip), %rdi     # 0x48308
callq 0xf3a6
movq 0x3ea3e(%rip), %rdi     # 0x48310
callq 0xf3a6
movq 0x3ea3a(%rip), %rdi     # 0x48318
callq 0xf3a6
movq 0x3ea36(%rip), %rdi     # 0x48320
callq 0xf3a6
movq 0x3ea32(%rip), %rdi     # 0x48328
callq 0xf3a6
movq %rbx, %rdi
callq 0x8ba5
movl $0x9, %ebx
cmpb $0x1, 0x10(%r12)
movq %r15, %rax
cmoveq %r12, %rax
movq (%rax), %rdi
callq 0x8ba5
callq 0x96a4
leaq 0x8(%r12), %rax
cmpb $0x1, 0x10(%r12)
cmovneq %r15, %rax
movq (%rax), %r12
decl %ebx
jne 0x9908
movl 0x3597a(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x9c31
movq 0x3e9d3(%rip), %rsi     # 0x48328
leal -0x1(%rax), %edx
movl %edx, 0x3595a(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movq 0x3c091(%rip), %rcx     # 0x45a00
movl %edx, %edx
leaq 0x3ec48(%rip), %rbx     # 0x485c0
movq (%rbx,%rdx,8), %rdi
movl 0x8(%rsi), %r8d
leaq 0x102169(%rip), %rdx    # 0x10baf0
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x1, %eax
jbe 0x9c31
movq 0x3e97e(%rip), %rsi     # 0x48320
leal -0x2(%rax), %edi
movl %edi, 0x3590d(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x2, %eax
je 0x9c31
movq 0x3e93e(%rip), %rsi     # 0x48318
leal -0x3(%rax), %edi
movl %edi, 0x358d5(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x3, %eax
jbe 0x9c31
movq 0x3e8fe(%rip), %rsi     # 0x48310
leal -0x4(%rax), %edi
movl %edi, 0x3589d(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x4, %eax
je 0x9c31
movq 0x3e8be(%rip), %rsi     # 0x48308
leal -0x5(%rax), %edi
movl %edi, 0x35865(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x5, %eax
jbe 0x9c31
movq 0x3e87e(%rip), %rsi     # 0x48300
leal -0x6(%rax), %edi
movl %edi, 0x3582d(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x6, %eax
je 0x9c31
movq 0x3e83e(%rip), %rsi     # 0x482f8
leal -0x7(%rax), %edi
movl %edi, 0x357f5(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x7, %eax
jbe 0x9c31
movq 0x3e7fe(%rip), %rsi     # 0x482f0
leal -0x8(%rax), %edi
movl %edi, 0x357bd(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %edi, %edi
movq (%rbx,%rdi,8), %rdi
movl 0x8(%rsi), %r8d
movq %rdi, (%rdx,%r8,8)
movl 0x8(%rsi), %esi
movq %rcx, (%r14,%rsi,8)
cmpl $0x8, %eax
je 0x9c31
movq 0x3e7be(%rip), %rsi     # 0x482e8
addl $-0x9, %eax
movl %eax, 0x35785(%rip)     # 0x3f2b8
cmpb $0x3, 0x10(%rsi)
jne 0x9c25
movl %eax, %eax
movq (%rbx,%rax,8), %rax
movl 0x8(%rsi), %edi
movq %rax, (%rdx,%rdi,8)
movl 0x8(%rsi), %eax
movq %rcx, (%r14,%rax,8)
callq 0x96a4
movl 0x3575c(%rip), %eax     # 0x3f2b8
movl $0xfffe795f, %ecx       # imm = 0xFFFE795F
leal (%rax,%rcx), %edx
cmpl %ecx, %edx
jbe 0x9c31
decl %eax
movl %eax, 0x35744(%rip)     # 0x3f2b8
movq (%rbx,%rax,8), %rbx
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
callq 0xf40c
movq %rbx, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8ba5
cmpq 0x39f0c(%rip), %rax     # 0x43ac8
je 0x9c0b
movl 0x356f4(%rip), %ebx     # 0x3f2b8
movq %rax, %rdi
callq 0x8ba5
cmpb $0x1, 0x10(%r12)
jne 0x9bf6
movq (%r12), %rdi
callq 0x8ba5
callq 0x96a4
leaq 0x8(%r12), %rax
cmpb $0x1, 0x10(%r12)
cmovneq %r15, %rax
movq (%rax), %r12
jmp 0x9bcc
movl 0x356bc(%rip), %edi     # 0x3f2b8
subl %ebx, %edi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x8b7d
incl 0x101ebf(%rip)          # 0x10bad0
callq 0x11734
decl 0x101eb4(%rip)          # 0x10bad0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x2536e(%rip), %rdi     # 0x2ef9a
callq 0x780b
leaq 0x25309(%rip), %rdi     # 0x2ef41
callq 0x780b