// File: /workspace/github_c_makefile_star2_O0/nimble-code[P]Modex/Src/symtab.c
// Function: scopetab_find
symentry_t*
scopetab_find(scopetab_t *that, str_t *nme)
{	symentry_t *ret = NULL, *oret = NULL;
	int j;
	extern int structfieldflag;

if (DBG) {	printf("scopetab_find %s -- hashtab: <%p> -- ", nme->str, that?that->htab:0);
		printf("scopetab: %p, level: %d  nsyms: %d  nchild: %d -- structfield: %s -- owner_t: %d\n",
			that, that?that->level:-1, that?that->nsyms:-1, that?that->nchild:-1,
			structfieldflag?"YES":"no",
			that?that->owner_t:-1);
	}

	if (that)
	{	if (that->visited)
			return NULL;
		that->visited = 1;	/* prevent circularity */

		if (that->htab)
		{	if (!structfieldflag
			||   (that->level >= 3
			&&    that->owner_t == TN_OBJ_DEF))	/* Struct/Union, must have owner_t before ref */
			{	ret = hashtab_lookup(that->htab, nme);
			}
		}

		if (!ret && structfieldflag)	/* gjh */
		for (j = 0; j < that->nchild; j++)
		{	ret = scopetab_find(that->children[j], nme);
			if (ret)
			{	ret->used = 1;	/* set for all matches, return last */
				oret = ret;
if (DBG)			printf("Candidate Match %s: %p - %s:%d nes: %s\n",
					nme->str, ret, ret->fn, ret->ln,
					ret->nes && ret->nes->owner ? ret->nes->owner : "no owner");
		}	}
		if (!ret && oret) ret = oret;

		if (!ret) ret = scopetab_find(that->parent,nme);	/* goes up one level */

		that->visited = 0;
	}
	if (ret && structfieldflag) ret->used = 1;

	return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x54a5
movq -0x10(%rbp), %rax
cmpl $0x0, 0x24(%rax)
je 0x53b2
movq $0x0, -0x8(%rbp)
jmp 0x54c8
movq -0x10(%rbp), %rax
movl $0x1, 0x24(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x53ff
leaq 0x564f9(%rip), %rax     # 0x5b8c8
cmpl $0x0, (%rax)
je 0x53e8
movq -0x10(%rbp), %rax
cmpl $0x3, 0x4(%rax)
jl 0x53fd
movq -0x10(%rbp), %rax
cmpl $0x18, 0x20(%rax)
jne 0x53fd
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x4f70
movq %rax, -0x20(%rbp)
jmp 0x53ff
cmpq $0x0, -0x20(%rbp)
jne 0x5468
leaq 0x564bb(%rip), %rax     # 0x5b8c8
cmpl $0x0, (%rax)
je 0x5468
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x28(%rcx), %eax
jge 0x5466
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movslq -0x2c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
callq 0x5370
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x5459
movq -0x20(%rbp), %rax
movb $0x1, 0x22(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x545b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x5419
jmp 0x5468
cmpq $0x0, -0x20(%rbp)
jne 0x547e
cmpq $0x0, -0x28(%rbp)
je 0x547e
movq -0x28(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x549a
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x5370
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movl $0x0, 0x24(%rax)
cmpq $0x0, -0x20(%rbp)
je 0x54c0
leaq 0x56415(%rip), %rax     # 0x5b8c8
cmpl $0x0, (%rax)
je 0x54c0
movq -0x20(%rbp), %rax
movb $0x1, 0x22(%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)