// File: /workspace/github_c_makefile_star2_O1/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 0x1ce69
movq %rsi, %rbx
movq %rdi, %r14
movq 0x40(%rdi), %rax
movl 0x1c(%rax), %r15d
cmpl $0x2d, %r15d
jne 0x1ce55
movq 0x40(%rax), %rax
movq 0x8(%rax), %r12
leaq 0x14352(%rip), %rsi     # 0x310dd
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1ce63
leaq 0x14345(%rip), %rsi     # 0x310e7
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1ce7a
leaq 0x1252e(%rip), %rsi     # 0x2f2e7
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1cea3
leaq 0x14351(%rip), %rsi     # 0x31121
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1ceb3
leaq 0x14361(%rip), %rsi     # 0x31148
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1cf7a
leaq 0x14353(%rip), %rsi     # 0x31151
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1cffa
leaq 0x14365(%rip), %rsi     # 0x3117a
movq %r12, %rdi
callq 0x3180
testl %eax, %eax
je 0x1d007
xorl %eax, %eax
leaq 0x1af62(%rip), %rcx     # 0x37d90
movq (%rcx,%rax,4), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rbp
callq 0x3180
testl %eax, %eax
je 0x1cf98
addq $0x4, %rbp
cmpq $0x14, %rbp
movq %rbp, %rax
jne 0x1ce27
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x43b4
movl 0x63bfb(%rip), %ebp     # 0x80a64
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 0x1ce55
cmpl $0x2f, 0x1c(%rax)
jne 0x1ce55
movq 0x40(%rax), %rsi
movq %rbx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d071
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
jmp 0x1cf85
movq 0x48(%r14), %r12
testq %r12, %r12
je 0x1d05b
cmpl $0xa, 0x1c(%r12)
jne 0x1d05b
movq 0x40(%r12), %rdi
testq %rdi, %rdi
je 0x1d05b
cmpq $0x0, 0x48(%r12)
je 0x1d05b
leaq 0x63a9b(%rip), %r13     # 0x80988
movl $0x0, (%r13)
movq %rbx, %rsi
callq 0x1b08f
movl %eax, %r15d
movq 0x48(%r12), %rdi
movq %rbx, %rsi
callq 0x1b08f
cmpl $0x0, (%r13)
jne 0x1d05b
testq %rbx, %rbx
je 0x1cf27
cmpl $0x1b, 0x1c(%rbx)
jne 0x1cf27
movq 0x40(%rbx), %rbx
testq %rbx, %rbx
je 0x1ce69
movq 0x28(%rbx), %rcx
testq %rcx, %rcx
je 0x1ce69
movq 0x18(%rcx), %rcx
testq %rcx, %rcx
je 0x1ce69
xorl %edx, %edx
cmpl $0x0, (%rcx)
je 0x1cf68
movl 0x4(%rcx), %esi
testl %r15d, %esi
je 0x1cf62
movl $0x1, %ebp
andl %eax, %esi
je 0x1cf6a
movl $0x0, (%rcx)
movl %edx, %ebp
movq 0x10(%rcx), %rcx
movl %ebp, %edx
testq %rcx, %rcx
jne 0x1cf4c
jmp 0x1ce69
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d0d4
movq %rbp, %r12
leaq 0x639e6(%rip), %r15     # 0x80988
movl $0x0, (%r15)
leaq 0x14016(%rip), %rsi     # 0x30fc6
movl $0x6, %edx
movq %r13, %rdi
callq 0x3080
testl %eax, %eax
je 0x1d025
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x1d066
cmpl $0xa, 0x1c(%rax)
jne 0x1d066
movq 0x40(%rax), %rdi
movq %rbx, %rsi
callq 0x1b08f
movl %eax, %ebp
movq 0x48(%r14), %rax
movq 0x48(%rax), %rdi
movq %rbx, %rsi
callq 0x1b08f
movl %eax, %edx
jmp 0x1d029
movq %r14, %rdi
movq %rbx, %rsi
movl $0x1, %edx
jmp 0x1d012
movq %r14, %rdi
movq %rbx, %rsi
movl $0x2, %edx
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1d289
xorl %ebp, %ebp
xorl %edx, %edx
cmpl $0x0, (%r15)
jne 0x1d066
leaq 0x639fa(%rip), %rax     # 0x80a30
movq %r12, %rcx
incl (%r12,%rax)
movq %rbx, %rdi
movl %ebp, %esi
leaq 0x1ad47(%rip), %rax     # 0x37d90
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *0x8(%rax,%rcx,4)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x435b
movq %r14, %rdi
movq %r13, %rsi
callq 0x4322