// File: /workspace/github_c_makefile_star2_O2/nimble-code[P]Uno/Src/uno_generic.c
// Function: eval_fct
int
eval_fct(treenode *e, treenode *n)
{	leafnode *leaf;
	int i, val1, val2;

	if (!e) return 0;

	if (e->lnode->hdr.type != TN_IDENT)
	{
bad1:		err_path++;
		fprintf(stderr, "eval_fct:\n\t%s:%d: expect ident for fctname, got %s in %s\n",
			n?n->hdr.fnm:"--",
			n?n->hdr.line:0,
			name_of_node(e->lnode->hdr.type), x_stmnt(e));
		exit(1);
	}

	leaf = (leafnode *) e->lnode;
	if (strcmp(leaf->data.sval->str, endname) == 0)
		return path_ends;

	if (strcmp(leaf->data.sval->str, callname) == 0)
	{	if (e->rnode
		&&  e->rnode->hdr.type == TN_STRING)
		{	leaf = (leafnode *) e->rnode;

			if (debug) printf("saw %s(%s)\n", callname, leaf->data.str);

			return has_ident(n, leaf->data.str);
		}
		goto bad1;
	}

	if (strcmp(leaf->data.sval->str, selname) == 0)
		return sel_args(e, n, 1);

	if (strcmp(leaf->data.sval->str, refname) == 0)
		return ref_args(e, n);

	if (strcmp(leaf->data.sval->str, excname) == 0)
		return sel_args(e, n, 2);

	if (strcmp(leaf->data.sval->str, matchname) == 0)
		return match_args(e, n, 1);

	if (strcmp(leaf->data.sval->str, markedname) == 0)
		return match_args(e, n, 2);

	for (i = 0; i < (int) (sizeof(evals)/sizeof(struct Cmd)); i++)
		if (strcmp(leaf->data.sval->str, evals[i].cmd) == 0)
		{
			val1 = val2 = 0;	/* set defaults */
			nogood = 0;

			if (strncmp(evals[i].cmd, "known_", strlen("known_")) == 0)
				goto doit;	/* no args */

			/* everything else has two args */

			if (!e->rnode
			||   e->rnode->hdr.type != TN_EXPR_LIST)
			{
bad2:				fprintf(stderr, "uno: bad fct args %s(%s)\n",
					evals[i].cmd, x_stmnt(e->rnode));
				exit(1);
			}

			val1 = eval_const_expr(e->rnode->lnode, n);
			val2 = eval_const_expr(e->rnode->rnode, n);
doit:			if (nogood) goto bad2;

			hit_fcts[i]++;
			if (debug) printf("saw %s(%d,%d)\n", evals[i].cmd, val1, val2);
			return evals[i].fn(n, val1, val2);
		}
	goto bad1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebp, %ebp
testq %rdi, %rdi
je 0x1a2bc
movq %rsi, %rbx
movq %rdi, %r14
movq 0x40(%rdi), %rax
movl 0x1c(%rax), %r15d
cmpl $0x2d, %r15d
jne 0x1a432
movq 0x40(%rax), %rax
movq 0x8(%rax), %r12
leaq 0x14f6b(%rip), %rsi     # 0x2f0e9
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a2b6
leaq 0x14f5e(%rip), %rsi     # 0x2f0f3
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a2cd
leaq 0x13118(%rip), %rsi     # 0x2d2c4
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a2fe
leaq 0x14f6a(%rip), %rsi     # 0x2f12d
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a305
leaq 0x14f7a(%rip), %rsi     # 0x2f154
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a3c5
leaq 0x14f6c(%rip), %rsi     # 0x2f15d
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a3e1
leaq 0x14f7e(%rip), %rsi     # 0x2f186
movq %r12, %rdi
callq 0x3190
testl %eax, %eax
je 0x1a3e5
xorl %ecx, %ecx
cmpq $0x14, %rcx
je 0x1a432
leaq 0x1cb65(%rip), %rax     # 0x36d90
movq (%rax,%rcx,4), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %rcx, %rbp
callq 0x3190
movq %rbp, %rcx
addq $0x4, %rcx
testl %eax, %eax
jne 0x1a21a
movq %rcx, %r12
leaq 0x65746(%rip), %r15     # 0x7f998
andl $0x0, (%r15)
leaq 0x14d75(%rip), %rsi     # 0x2efd2
pushq $0x6
popq %rdx
movq %r13, %rdi
callq 0x3080
testl %eax, %eax
je 0x1a401
movq 0x48(%r14), %rdi
testq %rdi, %rdi
je 0x1a4da
cmpl $0xa, 0x1c(%rdi)
jne 0x1a4e2
movq 0x40(%rdi), %rdi
movq %rbx, %rsi
callq 0x18519
movl %eax, %ebp
movq 0x48(%r14), %rax
movq 0x48(%rax), %rdi
movq %rbx, %rsi
callq 0x18519
cmpl $0x0, (%r15)
jne 0x1a4de
movl %eax, %edx
jmp 0x1a405
movl 0x657b8(%rip), %ebp     # 0x7fa74
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x1a432
cmpl $0x2f, 0x1c(%rax)
jne 0x1a432
movq 0x40(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a50d
pushq $0x1
jmp 0x1a3c7
movq 0x48(%r14), %r12
testq %r12, %r12
je 0x1a490
cmpl $0xa, 0x1c(%r12)
jne 0x1a490
movq 0x40(%r12), %rdi
testq %rdi, %rdi
je 0x1a490
cmpq $0x0, 0x48(%r12)
je 0x1a490
leaq 0x65659(%rip), %r13     # 0x7f998
andl $0x0, (%r13)
movq %rbx, %rsi
callq 0x18519
movl %eax, %r15d
movq 0x48(%r12), %rdi
movq %rbx, %rsi
callq 0x18519
cmpl $0x0, (%r13)
jne 0x1a490
testq %rbx, %rbx
je 0x1a2bc
cmpl $0x1b, 0x1c(%rbx)
jne 0x1a383
movq 0x40(%rbx), %rbx
testq %rbx, %rbx
je 0x1a2bc
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
je 0x1a2bc
addq $0x18, %rcx
xorl %ebp, %ebp
pushq $0x1
popq %rdx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x1a2bc
cmpl $0x0, (%rcx)
je 0x1a3bb
movl 0x4(%rcx), %edi
testl %r15d, %edi
je 0x1a3b8
movl %edx, %esi
andl %eax, %edi
je 0x1a3bd
andl $0x0, (%rcx)
movl %ebp, %esi
addq $0x10, %rcx
movl %esi, %ebp
jmp 0x1a399
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a579
pushq $0x1
jmp 0x1a3e7
pushq $0x2
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1a79d
xorl %edx, %edx
xorl %ebp, %ebp
movq %r12, %rcx
leaq 0x65631(%rip), %rax     # 0x7fa40
incl -0x4(%r12,%rax)
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x1c970(%rip), %rax     # 0x36d90
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *-0x8(%rax,%rcx,4)
incl 0x65638(%rip)           # 0x7fa70
movq 0x1cbb9(%rip), %rax     # 0x36ff8
movq (%rax), %r12
testq %rbx, %rbx
jne 0x1a452
xorl %ebx, %ebx
leaq 0x3db5(%rip), %r13      # 0x1e205
jmp 0x1a459
movq 0x8(%rbx), %r13
movl 0x10(%rbx), %ebx
movl %r15d, %edi
callq 0x66b2
movq %rax, %r15
movq %r14, %rdi
callq 0x4ac7
leaq 0x14b25(%rip), %rsi     # 0x2ef98
movq %r12, %rdi
movq %r13, %rdx
movl %ebx, %ecx
movq %r15, %r8
movq %rax, %r9
xorl %eax, %eax
callq 0x31a0
pushq $0x1
popq %rdi
callq 0x3270
incl 0x655da(%rip)           # 0x7fa70
movq 0x1cb5b(%rip), %rax     # 0x36ff8
movq (%rax), %r15
testq %rbx, %rbx
jne 0x1a4b0
xorl %ebx, %ebx
leaq 0x3d57(%rip), %r12      # 0x1e205
jmp 0x1a4b7
movq 0x8(%rbx), %r12
movl 0x10(%rbx), %ebx
movq %r14, %rdi
callq 0x4ac7
leaq 0x14c6e(%rip), %rsi     # 0x2f134
movq %r15, %rdi
movq %r12, %rdx
movl %ebx, %ecx
movq %rax, %r8
xorl %eax, %eax
callq 0x31a0
jmp 0x1a488
xorl %edi, %edi
jmp 0x1a4e2
movq 0x48(%r14), %rdi
movq 0x1cb0f(%rip), %rax     # 0x36ff8
movq (%rax), %rbx
callq 0x4ac7
leaq 0x14ae1(%rip), %rsi     # 0x2efd9
movq %rbx, %rdi
movq %r13, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x31a0
jmp 0x1a488