// File: /workspace/github_c_makefile_star2_O2/nimble-code[P]Modex/Src/tree.c
// Function: find_typedef_name
void
find_typedef_name(treenode *n, treenode *def, FindFunction find)
{
    if (!n)
        return;

	if (0)
	printf("%s: find_typedef_name %s - %s\n",
		progname, name_of_nodetype(n->hdr.which), name_of_node(n->hdr.type));

    switch(n->hdr.which)
    {
        case LEAF_T:
            (find)((leafnode*) n, def, NULL);
            break;

        case NODE_T:
        {
            switch(n->hdr.type)
            {
            case TN_DECL:
                find_typedef_name(n->rnode,def,find);
                break;

            case TN_ARRAY_DECL:
                find_typedef_name(n->lnode,def,find);
                break;

            case TN_PNTR:
#if 0
                fprintf(stderr,
                    "%s: parse error: TN_PNTR reached in find_typedef_name!\n", progname);
		/* can happen, e.g.: typedef long name(int *); */
#endif
                break;

            case TN_DECL_LIST:
            case TN_DECLS:
                find_typedef_name(n->lnode,def,find);
                find_typedef_name(n->rnode,def,find);
                break;

            case TN_FUNC_DECL:

		if (0) printf("lnode=%s %s rnode=%s %s\n",
		name_of_nodetype(n->lnode->hdr.which), name_of_node(n->lnode->hdr.type),
		name_of_nodetype(n->rnode->hdr.which), name_of_node(n->rnode->hdr.type));

		if (n->lnode->hdr.which == LEAF_T)		/* gjh added */
			find_typedef_name(n->lnode,def,find);
		else if (n->lnode->hdr.type == TN_DECL)
                    find_typedef_name(n->lnode,def,find);
                else
                    find_typedef_name(n->rnode,def,find);
                break;

	    case TN_PARAM_LIST:
		return;

            default:
                fprintf(stderr,
                        "%s: parse error: "
                        "unknown node type (%s) in find_typedef_name\n",
                        progname, name_of_node(n->hdr.type));
                break;
            }
        }
        break;

        case IF_T:
        case FOR_T:
        case NONE_T:
        default:
            fprintf(stderr,
                "%s: parse error: unknown node %s in find_typedef_name;"
                "  type: %s\n", progname, print_ptr(n), name_of_nodetype(n->hdr.which));
            break;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbp
movq %rsi, %rbx
pushq $0x30
popq %r15
pushq $0x38
popq %r12
leaq 0x100c3(%rip), %r13     # 0x24628
testq %rdi, %rdi
je 0x145c2
movq %rdi, %r14
movl (%rdi), %eax
cmpl $0x4, %eax
jne 0x145d1
movl 0x1c(%r14), %edi
leal -0x5(%rdi), %eax
cmpl $0xe, %eax
ja 0x145a5
movslq (%r13,%rax,4), %rcx
addq %r13, %rcx
movq %r15, %rax
jmpq *%rcx
movq 0x30(%r14), %rdi
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x14545
movq %r12, %rax
movq (%r14,%rax), %rdi
jmp 0x14565
cmpl $0x2, %edi
jne 0x14641
movq 0x30(%r14), %rdi
cmpl $0x1, (%rdi)
je 0x14565
cmpl $0x5, 0x1c(%rdi)
movq %r12, %rax
je 0x14565
jmp 0x1459f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %eax
jne 0x145f1
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rbp, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0x1fa00(%rip), %rax     # 0x33ff8
movq (%rax), %rbx
leaq 0x1fb9e(%rip), %rax     # 0x341a0
movq (%rax), %r15
movq %r14, %rdi
callq 0x141e8
movl (%r14), %edi
callq 0x14527
leaq 0x10395(%rip), %rsi     # 0x249b1
leaq 0x317fd(%rip), %rcx     # 0x45e20
movq %rbx, %rdi
movq %r15, %rdx
movq %rax, %r8
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41c0
movq 0x1f9b0(%rip), %rax     # 0x33ff8
movq (%rax), %rbx
leaq 0x1fb4e(%rip), %rax     # 0x341a0
movq (%rax), %r14
callq 0x1467f
leaq 0x10312(%rip), %rsi     # 0x24973
movq %rbx, %rdi
movq %r14, %rdx
movq %rax, %rcx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x41c0