// File: /workspace/github_c_makefile_star2_O2/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 0xb0c9
movq %rdi, %rbx
leaq 0x2e4b9(%rip), %r13     # 0x393d0
leaq 0x29472(%rip), %r15     # 0x34390
movq (%r13), %r13
testq %r13, %r13
je 0xaf57
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
jne 0xaf51
movq 0x8(%r13), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x41b0
testl %eax, %eax
je 0xafdb
addq $0x38, %r13
jmp 0xaf1e
leaq 0x2e46a(%rip), %r13     # 0x393c8
movq (%r13), %r13
testq %r13, %r13
je 0xaf80
movq (%r13), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0xafb0
addq $0x38, %r13
jmp 0xaf5e
leaq 0x2e429(%rip), %r13     # 0x393b0
xorl %r14d, %r14d
movq (%r13), %r13
testq %r13, %r13
je 0xb0cc
movq (%r13), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x41b0
testl %eax, %eax
je 0xb008
addq $0x38, %r13
jmp 0xaf8a
leaq 0x2bac5(%rip), %rax     # 0x36a7c
testb $0x2, (%rax)
je 0xb03b
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x17008(%rip), %rdi     # 0x21fde
movq %rbx, %rsi
jmp 0xb003
leaq 0x2ba9a(%rip), %rax     # 0x36a7c
testb $0x2, (%rax)
je 0xb03b
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r14
leaq 0x16fcd(%rip), %rdi     # 0x21fca
movq %rbx, %rsi
movq %r12, %rcx
movq %r14, %r8
jmp 0xb034
leaq 0x2ba6d(%rip), %rax     # 0x36a7c
testb $0x2, (%rax)
je 0xb03b
movq 0x8(%r13), %rcx
movq 0x10(%r13), %rdx
movq 0x18(%r13), %rax
testq %rax, %rax
cmovneq %rax, %r15
leaq 0x16fc4(%rip), %rdi     # 0x21ff2
movq %rbx, %rsi
movq %r15, %r8
xorl %eax, %eax
callq 0x4140
movq 0x18(%r13), %rbx
movq %rbx, %rax
testq %rbx, %rbx
jne 0xb04b
movq (%r13), %rax
xorl %ecx, %ecx
movb (%rax), %dl
testb %dl, %dl
je 0xb063
incq %rax
xorl %esi, %esi
cmpb $0x5b, %dl
sete %sil
addl %esi, %ecx
jmp 0xb04d
cmpl $0x1, %ecx
jne 0xb0c9
movq %rbx, %rdi
testq %rbx, %rbx
jne 0xb074
movq (%r13), %rdi
pushq $0x5b
popq %rsi
callq 0x4150
testq %rax, %rax
je 0xb0c9
movq %rax, %r15
testq %rbx, %rbx
jne 0xb08d
movq (%r13), %rbx
pushq $0x5d
popq %rsi
movq %rbx, %rdi
callq 0x4150
cmpq %rax, %r15
jae 0xb0c9
movq %rax, %rbx
movb $0x0, (%rax)
incq %r15
movq %r15, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x4739
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x40b0
movb $0x5d, (%rbx)
jmp 0xb0cc
xorl %r14d, %r14d
movq %r14, %rax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq