// File: /workspace/github_c_makefile_star2_O1/nimble-code[P]Modex/Src/xtract.c
// Function: which_var
char *
which_var(char *s)
{	Fcts *g;
	char *x, *y, *z;
	int i;

	if (strlen(s) == 0)
		return (char *) 0;

	for (g = modex_locals; g; g = g->nxt)
		if (strcmp(g->nm, s) == 0
		&&  strcmp(g->tg, fct_name) == 0)
		{	if (Verbose&2)
			printf("		%s -L-> %s %s %s\n",
				s, g->dt, g->tg, g->full?g->full:g->nm);
			goto found;
		}

	for (g = modex_globals; g; g = g->nxt)
		if (strcmp(g->nm, s) == 0)
		{	if (Verbose&2)
			printf("		%s -G-> %s %s %s\n",
				s, g->dt, g->tg, g->full?g->full:g->nm);
			goto found;
		}

	for (g = modex_hidden; g; g = g->nxt)
		if (strcmp(g->nm, s) == 0)
		{	if (Verbose&2)
			printf("		%s -H-> %s %s %s\n",
				s, g->dt, g->tg, g->full?g->full:g->nm);
			goto found;
		}
notfound:
	if (0)	/* could be field in struct - beyond our scope */
	fprintf(stderr, "		%s -?-> not found\n", s);
	return (char *) 0;
found:
	i = 0; z = g->full?g->full:g->nm;
	while (*z) { if (*z++ == '[') i++; }

	if (i != 1	/* can't tell apart multiple indices - yet */
	||  !(z = strrchr(g->full?g->full:g->nm, '['))
	||  !(y = strrchr(g->full?g->full:g->nm, ']'))
	||  !(z < y))
		goto notfound;
	*y = '\0';
	x = (char *) e_malloc(strlen(z+1)+1);
	strcpy(x, z+1);
	*y = ']';
	return x;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
cmpb $0x0, (%rdi)
je 0xced4
movq %rdi, %rbx
movq 0x2f6ae(%rip), %r13     # 0x3c3c0
testq %r13, %r13
je 0xcd51
leaq 0x2a662(%rip), %r15     # 0x37380
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
jne 0xcd48
movq 0x8(%r13), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x41b0
testl %eax, %eax
je 0xce03
movq 0x38(%r13), %r13
testq %r13, %r13
jne 0xcd1e
movq 0x2f660(%rip), %r13     # 0x3c3b8
testq %r13, %r13
je 0xcd76
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0xcdaa
movq 0x38(%r13), %r13
jmp 0xcd58
movq 0x2f623(%rip), %r13     # 0x3c3a0
testq %r13, %r13
je 0xced4
xorl %r14d, %r14d
movq (%r13), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0xcdd5
movq 0x38(%r13), %r13
testq %r13, %r13
jne 0xcd89
jmp 0xced7
leaq 0x2ccbb(%rip), %rax     # 0x39a6c
testb $0x2, (%rax)
je 0xce35
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x1830e(%rip), %rdi     # 0x250de
movq %rbx, %rsi
jmp 0xce2b
leaq 0x2cc90(%rip), %rax     # 0x39a6c
testb $0x2, (%rax)
je 0xce35
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r15
leaq 0x182f7(%rip), %rdi     # 0x250f2
movq %rbx, %rsi
movq %r15, %r8
jmp 0xce2e
leaq 0x2cc62(%rip), %rax     # 0x39a6c
testb $0x2, (%rax)
je 0xce35
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x182a5(%rip), %rdi     # 0x250ca
movq %rbx, %rsi
movq %r12, %rcx
movq %r14, %r8
xorl %eax, %eax
callq 0x4140
movq 0x18(%r13), %rbx
movq %rbx, %rax
testq %rbx, %rbx
jne 0xce45
movq (%r13), %rax
movb (%rax), %cl
xorl %r14d, %r14d
testb %cl, %cl
je 0xced7
incq %rax
xorl %edx, %edx
cmpb $0x5b, %cl
sete %dl
addl %edx, %r14d
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0xce55
cmpl $0x1, %r14d
jne 0xced4
movq %rbx, %rdi
testq %rbx, %rbx
jne 0xce7b
movq (%r13), %rdi
movl $0x5b, %esi
callq 0x4150
testq %rax, %rax
je 0xced4
movq %rax, %r15
testq %rbx, %rbx
jne 0xce96
movq (%r13), %rbx
movq %rbx, %rdi
movl $0x5d, %esi
callq 0x4150
cmpq %rax, %r15
jae 0xced4
movq %rax, %rbx
movb $0x0, (%rax)
incq %r15
movq %r15, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6469
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x40b0
movb $0x5d, (%rbx)
jmp 0xced7
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq