// File: /workspace/github_c_makefile_star2_O3/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 0xcd72
movq %rdi, %rbx
movq 0x2e813(%rip), %r13     # 0x3b3d0
testq %r13, %r13
je 0xcbfc
leaq 0x297c7(%rip), %r15     # 0x36390
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
jne 0xcbf3
movq 0x8(%r13), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x41c0
testl %eax, %eax
je 0xccae
movq 0x38(%r13), %r13
testq %r13, %r13
jne 0xcbc9
movq 0x2e7c5(%rip), %r13     # 0x3b3c8
testq %r13, %r13
je 0xcc21
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0xcc55
movq 0x38(%r13), %r13
jmp 0xcc03
movq 0x2e788(%rip), %r13     # 0x3b3b0
testq %r13, %r13
je 0xcd72
xorl %r14d, %r14d
movq (%r13), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x41c0
testl %eax, %eax
je 0xcc80
movq 0x38(%r13), %r13
testq %r13, %r13
jne 0xcc34
jmp 0xcd75
leaq 0x2be20(%rip), %rax     # 0x38a7c
testb $0x2, (%rax)
je 0xcce0
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x17463(%rip), %rdi     # 0x240de
movq %rbx, %rsi
jmp 0xccd6
leaq 0x2bdf5(%rip), %rax     # 0x38a7c
testb $0x2, (%rax)
je 0xcce0
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r15
leaq 0x1744c(%rip), %rdi     # 0x240f2
movq %rbx, %rsi
movq %r15, %r8
jmp 0xccd9
leaq 0x2bdc7(%rip), %rax     # 0x38a7c
testb $0x2, (%rax)
je 0xcce0
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x173fa(%rip), %rdi     # 0x240ca
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 0xccf0
movq (%r13), %rax
movb (%rax), %cl
xorl %r14d, %r14d
testb %cl, %cl
je 0xcd75
incq %rax
xorl %edx, %edx
cmpb $0x5b, %cl
sete %dl
addl %edx, %r14d
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0xccfc
cmpl $0x1, %r14d
jne 0xcd72
testq %rbx, %rbx
jne 0xcd1f
movq (%r13), %rbx
movq %rbx, %rdi
movl $0x5b, %esi
callq 0x4150
testq %rax, %rax
je 0xcd72
movq %rax, %r15
movq %rbx, %rdi
movl $0x5d, %esi
callq 0x4150
cmpq %rax, %r15
jae 0xcd72
movq %rax, %rbx
movb $0x0, (%rax)
incq %r15
movq %r15, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6321
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x40b0
movb $0x5d, (%rbx)
jmp 0xcd75
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq