// File: /workspace/github_c_makefile_star2_O2/nimble-code[P]Modex/Src/xtract.c
// Function: add_global
void
add_global(char *s, char *t, int d, int ln)	/* s=type, t=varname, d=derived */
{	Fcts *g, *h; char *z;

if (0)	printf("::%3d: addglobal <%s> <%s> %d -- %d -- line %d\n",
			ln, s, t, d, with_decorations, ln);

	if (strncmp(s, "void", strlen("void")) == 0
	&& !strchr(s, '*')
	&& !strchr(t, '*'))	/* void star */
	{	return;
	}

	if (strncmp(s, "static", strlen("static")) == 0)
	{	s += strlen("static");	/* can't have this in State */
		while (*s == ' ' || *s == '\t')
			s++;
	}
if (0) { if (strcmp(t, "uint") == 0) abort(); }
	if (strlen(s) == 0
	||  strlen(t) == 0)
	{	return;
	}

if (0)
	printf("%3d: addglobal <%s> <%s> %d -- %d -- line %d\n",
			ln, s, t, d, with_decorations, ln);

	while (*t == ' ' || *t == '\t')
		t++;

	if (strncmp(s, "extern", strlen("extern")) == 0
	||  strncmp(t, "=", 1) == 0
/*	||  (strncmp(t, "*", 1) == 0 && d != 0) */ )	// llist example
	{	return;
	}

	if (strstr(s, "struct")
	&&  (z = strchr(s, '{')))	/* assign z */
	{
		do	z++;
		while (isspace((int) *z));
		if (*z == '}')	/* empty struct declaration */
			return;
	}

	g = modex_fct_el(s);
	g->dt = g->nm;
	g->lno = ln;
	t = sep_decor(t, g);

	if (strcmp(s, "unsigned unsigned ") == 0)
	{	s += strlen("unsigned ");
	}

	if (0)
		fprintf(stderr, "%3d:	 addglobal <%s> <%s> %d -- %d\n",
			ln, s, t, d, with_decorations);

	for (h = modex_globals; h; h = h->nxt)
	{	if (	/* strcmp(h->dt, s) == 0 &&	*/
		    strcmp(h->nm, t) == 0)
			return;
	}
	if (0) fprintf(stderr, "	ok\n");

	g->nm = (char *) e_malloc(strlen(t)+1);
	strcpy(g->nm, t);
	g->derived = d;

	g->nxt = modex_globals;
	modex_globals = g;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
movl %ecx, %ebp
movl %edx, %ebx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x17358(%rip), %rsi     # 0x21f88
pushq $0x4
popq %rdx
callq 0x40a0
testl %eax, %eax
jne 0xac60
pushq $0x2a
popq %rsi
movq %r15, %rdi
callq 0x4130
testq %rax, %rax
jne 0xac60
pushq $0x2a
popq %rsi
movq %r14, %rdi
callq 0x4130
testq %rax, %rax
je 0xadb0
leaq 0x17326(%rip), %rsi     # 0x21f8d
pushq $0x6
popq %rdx
movq %r15, %rdi
callq 0x40a0
testl %eax, %eax
je 0xad61
movb (%r15), %al
testb %al, %al
je 0xadb0
movb (%r14), %r12b
testb %r12b, %r12b
je 0xadb0
cmpb $0x20, %r12b
je 0xaca0
movzbl %r12b, %eax
cmpl $0x9, %eax
jne 0xaca9
movb 0x1(%r14), %r12b
incq %r14
jmp 0xac91
leaq 0x172e4(%rip), %rsi     # 0x21f94
pushq $0x6
popq %rdx
movq %r15, %rdi
callq 0x40a0
cmpb $0x3d, %r12b
je 0xadb0
testl %eax, %eax
je 0xadb0
leaq 0x1541a(%rip), %rsi     # 0x200ee
movq %r15, %rdi
callq 0x42d0
testq %rax, %rax
je 0xad17
pushq $0x7b
popq %rsi
movq %r15, %rdi
callq 0x4130
testq %rax, %rax
je 0xad17
movq %rax, %r12
callq 0x42e0
movq (%rax), %rax
incq %r12
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0xacff
cmpb $0x7d, %cl
je 0xadb0
movq %r15, %rdi
callq 0xa9ba
movq %rax, %r15
movq (%rax), %rax
movq %rax, 0x10(%r15)
movl %ebp, 0x34(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xab68
movq %rax, %r14
leaq 0x2e686(%rip), %r12     # 0x393c8
movq (%r12), %r12
testq %r12, %r12
je 0xad7c
movq (%r12), %rdi
movq %r14, %rsi
callq 0x41b0
addq $0x38, %r12
testl %eax, %eax
jne 0xad42
jmp 0xadb0
addq $0x6, %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0xad77
cmpl $0x9, %eax
jne 0xac7d
incq %r15
jmp 0xad65
movq %r14, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x4739
movq %rax, (%r15)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
movl %ebx, 0x24(%r15)
movq 0x2e623(%rip), %rax     # 0x393c8
movq %rax, 0x38(%r15)
movq %r15, 0x2e618(%rip)     # 0x393c8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq