// File: /workspace/github_c_makefile_star2_O1/nimble-code[P]Modex/Src/xtract.c
// Function: do_globals
void
do_globals(int setup, scopetab_t *that, int lastcall)
{	Fcts *g;
	char *z;
	FILE *fd;
	NameL *nl;

	if (suppress)
	{	return;
	}

	if (Verbose_cmds)
	{	printf("-- do globals [%d %d %d %s]\n", setup, do_inc_globals, allprocs, globfilename);
	}

	if (setup)
	{	setglobfile();
		if (do_inc_globals && allprocs)
		{	sprintf(tbuf, "#include \"%s\"	/* global header file */\n\n",
				globfilename);
			vis_direct(tbuf);
		}	/*  else created but not #include'd */
		return;
	}
	if (!globfilename)	/* no functions matched, user forgot -x */
	{	setglobfile();
	}

	#ifdef PC
		#define AFLAGS	"ab"
	#else
		#define AFLAGS	"a"
	#endif

	if ((fd = fopen(globfilename, AFLAGS)) == NULL)
	{	fprintf(stderr, "%s: error, cannot create global header file %s\n",
			progname, globfilename);
		return;
	}
if (debug_io) fprintf(stderr, ":: open %s -> %p\n", globfilename, fd);
	add_fnm(globfilename);

	fprintf(fd, "/** globals **/\n\n");

	do_constants(fd);
	fprintf(fd, "/** done with constants... **/\n\n");

	for (g = modex_globals; g; g = g->nxt)
	{
		if (strlen(g->full?g->full:g->nm) == 0)
			continue;

		if (!imported(g->nm, "Global", 1))
			continue;

		if (g->purged)
		{	continue;
		}
		g->purged = 1;

		if (0)
		printf("nm %s, dt %s, full %s\n", g->nm, g->dt, g->full);

		if ((z = spintype(g->dt, g->full?g->full:g->nm)) != NULL)
		{	sprintf(tbuf, "%s %s;\t/* derived <%s> */\n",
				z, g->full?g->full:g->nm, g->nm);
		} else if (strstr(g->dt, "typedef"))
		{	continue;
		} else
		{	z = checkfull(g->dt, g->full, g->lno);
			cleanse(g->dt);

			if (du_mode)
			{	char *yy, *y = g->full?g->full:g->nm;
				while (*y == '*' || *y == ' ' || *y == '\t')
					y++;
				if ((yy = strstr(y, "[]")) != NULL)
				{	*yy = '\0';
				}
				sprintf(tbuf, "int %s;	/* global */\n", y);
			} else
			{	if (z)
				sprintf(tbuf, " c_state \"%s %s\" \"Global\" \"%s\"\n",
					g->dt, g->full?g->full:g->nm, z);
				else
				sprintf(tbuf, " c_state \"%s %s\" \"Global\"\n",
					g->dt, g->full?g->full:g->nm);
		}	}
		fprintf(fd, "%s", tbuf);
	}

	for (nl = globchans; nl; nl = nl->nxt)
	{
		if (nl->purged)
		{	continue;
		}
		nl->purged = 1;

		fprintf(fd, "%s\n", nl->nm);
	}

	add_nomap_locals(fd);
	do_externals(fd);

	do_hidden(fd);			/* hidden vars */
	if (that)
	{	x_scopetab(that, fd, want);	/* extra c_state decls */
	}

	if (i_assert)
	{	ax_doprops(fd, that);
	}

	if (that && !nostructs)	/* import global structure declarations */
	{
		if (lastcall)				/* new 2.8 */
		{	find_typedefs(that, fd);	/* new 2.6 */
			put_structs(that, fd);
	}	}
if (debug_io) fprintf(stderr, "close z %p\n", fd);
	Fclose(fd);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
leaq 0x2b518(%rip), %rax     # 0x39cb0
cmpl $0x0, (%rax)
je 0xe7ac
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %edx, %ebp
movq %rsi, %rbx
movl %edi, %r14d
leaq 0x2b251(%rip), %rax     # 0x39a0c
cmpl $0x0, (%rax)
je 0xe7ea
leaq 0x28a19(%rip), %rax     # 0x371e0
movl (%rax), %edx
leaq 0x2b288(%rip), %rax     # 0x39a58
movl (%rax), %ecx
movq 0x2fe07(%rip), %r8      # 0x3e5e0
leaq 0x16baa(%rip), %rdi     # 0x2538a
movl %r14d, %esi
xorl %eax, %eax
callq 0x4140
testl %r14d, %r14d
je 0xe84a
leaq 0x16b8a(%rip), %rax     # 0x25380
movq %rax, 0x2fde3(%rip)     # 0x3e5e0
leaq 0x289dc(%rip), %rax     # 0x371e0
cmpl $0x0, (%rax)
je 0xe79d
leaq 0x2b248(%rip), %rax     # 0x39a58
cmpl $0x0, (%rax)
je 0xe79d
leaq 0x2fdd4(%rip), %rbx     # 0x3e5f0
leaq 0x16b84(%rip), %rsi     # 0x253a7
leaq 0x16b56(%rip), %rdx     # 0x25380
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xebec
cmpq $0x0, 0x2fd8e(%rip)     # 0x3e5e0
jne 0xe862
leaq 0x16b25(%rip), %rax     # 0x25380
movq %rax, 0x2fd7e(%rip)     # 0x3e5e0
movq 0x2fd77(%rip), %rdi     # 0x3e5e0
leaq 0x15fed(%rip), %rsi     # 0x2485d
callq 0x4260
testq %rax, %rax
je 0xebb8
movq %rax, %r14
movl %ebp, 0x4(%rsp)
movq %rbx, 0x10(%rsp)
leaq 0x2b177(%rip), %rax     # 0x39a08
cmpl $0x0, (%rax)
jne 0xebc2
movq 0x2fd3f(%rip), %rdi     # 0x3e5e0
callq 0xe728
leaq 0x16b65(%rip), %rdi     # 0x25412
movl $0x11, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42b0
movq %r14, %rdi
callq 0x7741
leaq 0x16b56(%rip), %rdi     # 0x25424
movl $0x20, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42b0
movq 0x2dad1(%rip), %rbp     # 0x3c3b8
testq %rbp, %rbp
je 0xeaab
leaq 0x147bf(%rip), %r15     # 0x230b6
leaq 0x2fcf2(%rip), %r13     # 0x3e5f0
movabsq $0x40100000200, %rbx    # imm = 0x40100000200
movq %r14, 0x8(%rsp)
movq 0x18(%rbp), %rax
testq %rax, %rax
jne 0xe91a
movq (%rbp), %rax
cmpb $0x0, (%rax)
je 0xe9d8
movq (%rbp), %rdi
movq %r15, %rsi
movl $0x1, %edx
callq 0xe686
testl %eax, %eax
je 0xe9d8
cmpl $0x0, 0x20(%rbp)
jne 0xe9d8
movq %rbx, %r14
movq %r15, %rbx
movq %r13, %r15
movl $0x1, 0x20(%rbp)
movq 0x18(%rbp), %r12
movq %r12, %rsi
testq %r12, %r12
jne 0xe966
movq (%rbp), %rsi
movq 0x10(%rbp), %r13
movq %r13, %rdi
callq 0xe09e
testq %rax, %rax
je 0xe9b6
testq %r12, %r12
jne 0xe980
movq (%rbp), %r12
movq (%rbp), %r8
movq %r15, %r13
movq %r15, %rdi
leaq 0x16ab4(%rip), %rsi     # 0x25445
movq %rax, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x4290
movq %rbx, %r15
movq %r14, %rbx
movq 0x8(%rsp), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x4170
jmp 0xe9d8
movq %r13, %rdi
leaq 0x167b4(%rip), %rsi     # 0x25174
callq 0x42c0
testq %rax, %rax
movq %r15, %r13
movq %rbx, %r15
movq %r14, %rbx
movq 0x8(%rsp), %r14
je 0xe9ea
movq 0x38(%rbp), %rbp
testq %rbp, %rbp
jne 0xe90d
jmp 0xeaab
movq %r12, %rsi
callq 0xe2e9
movq %rax, %r12
movq 0x10(%rbp), %rdi
callq 0xe3a0
leaq 0x2b043(%rip), %rax     # 0x39a48
cmpl $0x0, (%rax)
je 0xea5d
movq 0x18(%rbp), %r12
testq %r12, %r12
jne 0xea17
movq (%rbp), %r12
movzbl (%r12), %eax
cmpq $0x2a, %rax
ja 0xea2d
btq %rax, %rbx
jae 0xea2d
incq %r12
jmp 0xea17
movq %r12, %rdi
leaq 0x146e8(%rip), %rsi     # 0x2311f
callq 0x42c0
testq %rax, %rax
je 0xea44
movb $0x0, (%rax)
movq %r13, %rdi
leaq 0x16a12(%rip), %rsi     # 0x25460
movq %r12, %rdx
xorl %eax, %eax
callq 0x4290
jmp 0xe9a9
movq 0x10(%rbp), %rdx
movq 0x18(%rbp), %rcx
testq %r12, %r12
je 0xea8c
testq %rcx, %rcx
jne 0xea73
movq (%rbp), %rcx
movq %r13, %rdi
leaq 0x169f9(%rip), %rsi     # 0x25476
movq %r12, %r8
xorl %eax, %eax
callq 0x4290
jmp 0xe9a9
testq %rcx, %rcx
jne 0xea95
movq (%rbp), %rcx
movq %r13, %rdi
leaq 0x169f7(%rip), %rsi     # 0x25496
xorl %eax, %eax
callq 0x4290
jmp 0xe9a9
movq 0x30bbe(%rip), %rbx     # 0x3f670
testq %rbx, %rbx
movl 0x4(%rsp), %ebp
je 0xeae8
leaq 0x168ba(%rip), %r15     # 0x2537c
cmpl $0x0, 0x8(%rbx)
jne 0xeadf
movl $0x1, 0x8(%rbx)
movq (%rbx), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x41c0
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0xeac2
movq %r14, %rdi
callq 0xe3f6
movq 0x30fa1(%rip), %rbx     # 0x3fa98
testq %rbx, %rbx
je 0xeb2d
leaq 0x17a3c(%rip), %r15     # 0x2653f
cmpl $0x0, 0x18(%rbx)
jne 0xeb24
movl $0x1, 0x18(%rbx)
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x41c0
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
jne 0xeb03
movq %r14, %rdi
callq 0xe1ca
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0xeb54
leaq 0x28652(%rip), %rax     # 0x37198
movq (%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xec63
leaq 0x2868d(%rip), %rax     # 0x371e8
cmpl $0x0, (%rax)
je 0xeb6b
movq %r14, %rdi
movq %rbx, %rsi
callq 0xed1b
testl %ebp, %ebp
je 0xeb96
testq %rbx, %rbx
je 0xeb96
leaq 0x2aebd(%rip), %rax     # 0x39a38
cmpl $0x0, (%rax)
jne 0xeb96
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6f0e
movq %rbx, %rdi
movq %r14, %rsi
callq 0x703d
leaq 0x2ae6b(%rip), %rax     # 0x39a08
cmpl $0x0, (%rax)
jne 0xebcf
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x793c
callq 0x49e6
jmp 0xe79d
movq %r14, %rdi
callq 0x49c4
jmp 0xe89a
movq 0x28422(%rip), %rax     # 0x36ff8
movq (%rax), %rdi
leaq 0x168d1(%rip), %rsi     # 0x254b1
movq %r14, %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0xeba2