// File: /workspace/github_c_makefile_star2_O1/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 0x18656(%rip), %rsi     # 0x25088
movl $0x4, %edx
callq 0x40a0
testl %eax, %eax
jne 0xca68
movq %r15, %rdi
movl $0x2a, %esi
callq 0x4130
testq %rax, %rax
jne 0xca68
movq %r14, %rdi
movl $0x2a, %esi
callq 0x4130
testq %rax, %rax
je 0xcbb5
leaq 0x1861e(%rip), %rsi     # 0x2508d
movl $0x6, %edx
movq %r15, %rdi
callq 0x40a0
testl %eax, %eax
je 0xcb66
cmpb $0x0, (%r15)
je 0xcbb5
cmpb $0x0, (%r14)
je 0xcbb5
movzbl (%r14), %r12d
cmpl $0x20, %r12d
je 0xcaa8
cmpl $0x9, %r12d
jne 0xcaad
incq %r14
jmp 0xca98
leaq 0x185e0(%rip), %rsi     # 0x25094
movl $0x6, %edx
movq %r15, %rdi
callq 0x40a0
cmpb $0x3d, %r12b
je 0xcbb5
testl %eax, %eax
je 0xcbb5
leaq 0x16614(%rip), %rsi     # 0x230ee
movq %r15, %rdi
callq 0x42c0
testq %rax, %rax
je 0xcb1f
movq %r15, %rdi
movl $0x7b, %esi
callq 0x4130
testq %rax, %rax
je 0xcb1f
movq %rax, %r12
callq 0x42d0
movq (%rax), %rax
incq %r12
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0xcb07
cmpb $0x7d, %cl
je 0xcbb5
movq %r15, %rdi
callq 0xc799
movq %rax, %r15
movq (%rax), %rax
movq %rax, 0x10(%r15)
movl %ebp, 0x34(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xc949
movq %rax, %r14
movq 0x2f86e(%rip), %r12     # 0x3c3b8
testq %r12, %r12
je 0xcb81
movq (%r12), %rdi
movq %r14, %rsi
callq 0x41b0
testl %eax, %eax
je 0xcbb5
movq 0x38(%r12), %r12
jmp 0xcb4a
addq $0x6, %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0xcb7c
cmpl $0x9, %eax
jne 0xca84
incq %r15
jmp 0xcb6a
movq %r14, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6469
movq %rax, (%r15)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
movl %ebx, 0x24(%r15)
movq 0x2f80e(%rip), %rax     # 0x3c3b8
movq %rax, 0x38(%r15)
movq %r15, 0x2f803(%rip)     # 0x3c3b8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq