// File: /workspace/github_c_makefile_star2_O3/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 0x177b1(%rip), %rsi     # 0x24088
movl $0x4, %edx
callq 0x40a0
testl %eax, %eax
jne 0xc90d
movq %r15, %rdi
movl $0x2a, %esi
callq 0x4130
testq %rax, %rax
jne 0xc90d
movq %r14, %rdi
movl $0x2a, %esi
callq 0x4130
testq %rax, %rax
je 0xca60
leaq 0x17779(%rip), %rsi     # 0x2408d
movl $0x6, %edx
movq %r15, %rdi
callq 0x40a0
testl %eax, %eax
je 0xca11
movb (%r15), %al
testb %al, %al
je 0xca60
movb (%r14), %r12b
testb %r12b, %r12b
je 0xca60
cmpb $0x20, %r12b
je 0xc94f
movzbl %r12b, %eax
cmpl $0x9, %eax
jne 0xc958
movb 0x1(%r14), %r12b
incq %r14
jmp 0xc940
leaq 0x17735(%rip), %rsi     # 0x24094
movl $0x6, %edx
movq %r15, %rdi
callq 0x40a0
cmpb $0x3d, %r12b
je 0xca60
testl %eax, %eax
je 0xca60
leaq 0x15769(%rip), %rsi     # 0x220ee
movq %r15, %rdi
callq 0x42d0
testq %rax, %rax
je 0xc9ca
movq %r15, %rdi
movl $0x7b, %esi
callq 0x4130
testq %rax, %rax
je 0xc9ca
movq %rax, %r12
callq 0x42e0
movq (%rax), %rax
incq %r12
movsbq (%r12), %rcx
incq %r12
testb $0x20, 0x1(%rax,%rcx,2)
jne 0xc9b2
cmpb $0x7d, %cl
je 0xca60
movq %r15, %rdi
callq 0xc63e
movq %rax, %r15
movq (%rax), %rax
movq %rax, 0x10(%r15)
movl %ebp, 0x34(%r15)
movq %r14, %rdi
movq %r15, %rsi
callq 0xc7ee
movq %rax, %r14
movq 0x2e9d3(%rip), %r12     # 0x3b3c8
testq %r12, %r12
je 0xca2c
movq (%r12), %rdi
movq %r14, %rsi
callq 0x41c0
testl %eax, %eax
je 0xca60
movq 0x38(%r12), %r12
jmp 0xc9f5
addq $0x6, %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0xca27
cmpl $0x9, %eax
jne 0xc92c
incq %r15
jmp 0xca15
movq %r14, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6321
movq %rax, (%r15)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
movl %ebx, 0x24(%r15)
movq 0x2e973(%rip), %rax     # 0x3b3c8
movq %rax, 0x38(%r15)
movq %r15, 0x2e968(%rip)     # 0x3b3c8
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq