// File: /workspace/github_c_makefile_star2_O3/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 0x2a66d(%rip), %rax     # 0x38cc0
cmpl $0x0, (%rax)
je 0xe667
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 0x2a3a6(%rip), %rax     # 0x38a1c
cmpl $0x0, (%rax)
je 0xe6a5
leaq 0x27b6e(%rip), %rax     # 0x361f0
movl (%rax), %edx
leaq 0x2a3dd(%rip), %rax     # 0x38a68
movl (%rax), %ecx
movq 0x2ef5c(%rip), %r8      # 0x3d5f0
leaq 0x15cef(%rip), %rdi     # 0x2438a
movl %r14d, %esi
xorl %eax, %eax
callq 0x4140
testl %r14d, %r14d
je 0xe705
leaq 0x15ccf(%rip), %rax     # 0x24380
movq %rax, 0x2ef38(%rip)     # 0x3d5f0
leaq 0x27b31(%rip), %rax     # 0x361f0
cmpl $0x0, (%rax)
je 0xe658
leaq 0x2a39d(%rip), %rax     # 0x38a68
cmpl $0x0, (%rax)
je 0xe658
leaq 0x2ef29(%rip), %rbx     # 0x3d600
leaq 0x15cc9(%rip), %rsi     # 0x243a7
leaq 0x15c9b(%rip), %rdx     # 0x24380
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42a0
movq %rbx, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xeab6
movq 0x2eee4(%rip), %rdi     # 0x3d5f0
testq %rdi, %rdi
jne 0xe71f
leaq 0x15c68(%rip), %rdi     # 0x24380
movq %rdi, 0x2eed1(%rip)     # 0x3d5f0
leaq 0x15137(%rip), %rsi     # 0x2385d
callq 0x4270
testq %rax, %rax
je 0xea82
movq %rax, %r14
movq %rbx, 0x10(%rsp)
leaq 0x2a2d5(%rip), %rax     # 0x38a18
cmpl $0x0, (%rax)
jne 0xea8c
movl %ebp, 0x4(%rsp)
movq 0x2ee99(%rip), %rdi     # 0x3d5f0
callq 0xe5e3
leaq 0x15caf(%rip), %rdi     # 0x24412
movl $0x11, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq %r14, %rdi
callq 0x75d6
leaq 0x15ca0(%rip), %rdi     # 0x24424
movl $0x20, %esi
movl $0x1, %edx
movq %r14, %rcx
callq 0x42c0
movq 0x2cc2b(%rip), %rbx     # 0x3b3c8
testq %rbx, %rbx
je 0xe975
leaq 0x13909(%rip), %r13     # 0x220b6
movabsq $0x40100000200, %r15    # imm = 0x40100000200
movq %r14, 0x8(%rsp)
movq 0x18(%rbx), %rax
testq %rax, %rax
jne 0xe7c8
movq (%rbx), %rax
cmpb $0x0, (%rax)
je 0xe890
movq (%rbx), %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xe541
testl %eax, %eax
je 0xe890
cmpl $0x0, 0x20(%rbx)
jne 0xe890
movq %r15, %r14
movq %r13, %r15
movl $0x1, 0x20(%rbx)
movq 0x10(%rbx), %r13
movq 0x18(%rbx), %r12
testq %r12, %r12
je 0xe825
movq %r13, %rdi
movq %r12, %rsi
callq 0xdf6b
testq %rax, %rax
je 0xe871
movq (%rbx), %rbp
movq %r12, %rcx
jmp 0xe83b
movq (%rbx), %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0xdf6b
movq %rbp, %rcx
testq %rax, %rax
je 0xe871
leaq 0x2edbe(%rip), %r12     # 0x3d600
movq %r12, %rdi
leaq 0x15bf9(%rip), %rsi     # 0x24445
movq %rax, %rdx
movq %rbp, %r8
xorl %eax, %eax
callq 0x42a0
movq %r15, %r13
movq %r14, %r15
movq 0x8(%rsp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x4170
jmp 0xe890
movq %r13, %rdi
leaq 0x158f9(%rip), %rsi     # 0x24174
callq 0x42d0
testq %rax, %rax
movq %r15, %r13
movq %r14, %r15
movq 0x8(%rsp), %r14
je 0xe8a2
movq 0x38(%rbx), %rbx
testq %rbx, %rbx
jne 0xe7bc
jmp 0xe975
movq %r12, %rsi
callq 0xe1ae
movq %rax, %r12
movq 0x10(%rbx), %rdi
callq 0xe25b
leaq 0x2a19b(%rip), %rax     # 0x38a58
cmpl $0x0, (%rax)
je 0xe91b
movq 0x18(%rbx), %r12
testq %r12, %r12
jne 0xe8ce
movq (%rbx), %r12
movzbl (%r12), %eax
cmpq $0x2a, %rax
ja 0xe8e4
btq %rax, %r15
jae 0xe8e4
incq %r12
jmp 0xe8ce
movq %r12, %rdi
leaq 0x13831(%rip), %rsi     # 0x2211f
callq 0x42d0
testq %rax, %rax
je 0xe8fb
movb $0x0, (%rax)
leaq 0x2ecfe(%rip), %rdi     # 0x3d600
leaq 0x15b57(%rip), %rsi     # 0x24460
movq %r12, %rdx
movq %rdi, %r12
xorl %eax, %eax
callq 0x42a0
jmp 0xe864
movq 0x10(%rbx), %rdx
movq 0x18(%rbx), %rcx
testq %r12, %r12
je 0xe950
testq %rcx, %rcx
jne 0xe930
movq (%rbx), %rcx
leaq 0x2ecc9(%rip), %rdi     # 0x3d600
leaq 0x15b38(%rip), %rsi     # 0x24476
movq %r12, %r8
movq %rdi, %r12
xorl %eax, %eax
callq 0x42a0
jmp 0xe864
testq %rcx, %rcx
jne 0xe958
movq (%rbx), %rcx
leaq 0x2eca1(%rip), %r12     # 0x3d600
movq %r12, %rdi
leaq 0x15b2d(%rip), %rsi     # 0x24496
xorl %eax, %eax
callq 0x42a0
jmp 0xe864
movq 0x2fd04(%rip), %rbx     # 0x3e680
testq %rbx, %rbx
je 0xe9ae
leaq 0x159f4(%rip), %r15     # 0x2437c
cmpl $0x0, 0x8(%rbx)
jne 0xe9a5
movl $0x1, 0x8(%rbx)
movq (%rbx), %rdx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x41d0
movq 0x10(%rbx), %rbx
testq %rbx, %rbx
jne 0xe988
movq %r14, %rdi
callq 0xe2b1
movq 0x300eb(%rip), %rbx     # 0x3eaa8
testq %rbx, %rbx
je 0xe9f3
leaq 0x16b76(%rip), %r15     # 0x2553f
cmpl $0x0, 0x18(%rbx)
jne 0xe9ea
movl $0x1, 0x18(%rbx)
movq (%rbx), %rdx
movq 0x8(%rbx), %rcx
movq %r14, %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x41d0
movq 0x20(%rbx), %rbx
testq %rbx, %rbx
jne 0xe9c9
movq %r14, %rdi
callq 0xe08f
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0xea1a
leaq 0x2779c(%rip), %rax     # 0x361a8
movq (%rax), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xeb2d
leaq 0x277d7(%rip), %rax     # 0x361f8
cmpl $0x0, (%rax)
movl 0x4(%rsp), %ebp
je 0xea35
movq %r14, %rdi
movq %rbx, %rsi
callq 0xebc3
testl %ebp, %ebp
je 0xea60
testq %rbx, %rbx
je 0xea60
leaq 0x2a003(%rip), %rax     # 0x38a48
cmpl $0x0, (%rax)
jne 0xea60
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6d84
movq %rbx, %rdi
movq %r14, %rsi
callq 0x6ecd
leaq 0x29fb1(%rip), %rax     # 0x38a18
cmpl $0x0, (%rax)
jne 0xea99
movq %r14, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x77d0
callq 0x49a9
jmp 0xe658
movq %r14, %rdi
callq 0x4987
jmp 0xe74c
movq 0x27558(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0x15a07(%rip), %rsi     # 0x244b1
movq %r14, %rdx
xorl %eax, %eax
callq 0x41d0
jmp 0xea6c