// File: /workspace/github_c_makefile_star2_O3/nimble-code[P]Modex/Src/modex_pp.c
// Function: strip_sys_includes
void
strip_sys_includes(char *z, char *f, char *m)
{	FILE	*fd, *fo;
	char	buf[1024];
	char	*p;
	char	*match_what = NULL;
	char	*curfile    = NULL;
	int	first_directive = 1;

	*z = 'I';

	if ((fo = fopen(f, MFLAGS)) == NULL)	/* .I intermediate */
	{	fprintf(stderr, "modex: cannot create %s\n", f);
		goto clean;
	}
if (debug_io) fprintf(stderr, "fopen %s -> %p\n", f, fo);
	fprintf(fo, "#define pthread_t	int\n");
	fprintf(fo, "#define thread_t	int\n");
	fprintf(fo, "#define pthread_mutex_t	int\n");
	fprintf(fo, "#define pthread_cond_t	int\n");
	fprintf(fo, "#define mutex_t	int\n");
	fprintf(fo, "#define key_t	int\n");

	if ((fd = fopen(m, "r")) != NULL)	/* .dfn file -- if any */
	{	fprintf(fo, "#define UnoType	typedef int\n");
if (debug_io) fprintf(stderr, "fopen %s -> %p\n", m, fd);
		while (fgets(buf, 1024, fd))
			fprintf(fo, "%s", buf);
if (debug_io) fprintf(stderr, "close xx %p\n", fd);
		Fclose(fd);
	}
	fprintf(fo, "typedef int __builtin_va_list;\n"); /* gcc-ism */
	fprintf(fo, "typedef int __w64;\n");		 /* cl-ism */
	fprintf(fo, "typedef int _Bool;\n");		 /* c99 */
	fprintf(fo, "#define __restrict\n");		 /* gcc-ism */

	if (master_dfn)
	if ((fd = fopen(master_dfn, "r")) != NULL)	/* possible master .dfn file */
	{
if (debug_io) fprintf(stderr, "fopen %s -> %p\n", master_dfn, fd);
		while (fgets(buf, 1024, fd))
			fprintf(fo, "%s", buf);
if (debug_io) fprintf(stderr, "close yy %p\n", fd);
		Fclose(fd);
	}

	*z = 'c';
	if ((fd = fopen(f, "r")) == NULL)	/* .c file */
	{	fprintf(stderr, "%s: cannot open %s\n", progname, f);
		*z = 'I';	/* remove .I intermediate */
		unlink(f);
clean:		unlink("_modex_.run");
		exit(1);
	}
if (debug_io) fprintf(stderr, "--fopen %s -> %p\n", f, fd);

	fprintf(fo, "#line 1 \"%s\"\n", f);	/* restore linenumber and filename */

	while (fgets(buf, 1024, fd))
	{	if (buf[0] == '#')
		{	char *op;
			p = &buf[1];
			while (*p == ' ' || *p == '\t')
			{	p++;
			}
			op = p;

			/* eliminat output from external preprocessing
			   of system include files -- pan.c
			   will include the necessary files separately
			 */
			if (isdigit((int) *p)
			||  strncmp(p, "line", strlen("line")) == 0)	/* it is preprocessor output */
			{	char *q;
				q = p = strchr(p, '"');
				if (p)
				{	p++; q++;
					q = strchr(q, '"');
					if (q)
					{	*q = '\0';
						if (first_directive)
						{	match_what = (char *) e_malloc(strlen(p)+1);
							/* remember original filename: */
							strcpy(match_what, p);
							first_directive = 0;
						}
						curfile = (char *) e_malloc(strlen(p)+1);
						strcpy(curfile, p);
						continue;
				}	}
				p = op;
			}

			if (strncmp(p, "include", strlen("include")) == 0)
			{	p += strlen("include");
				while (*p == ' ' || *p == '\t')
					p++;
				if (sysoverride == 0
				&&  *p == '<')			/* system header file */
				{	fprintf(fo, "\n");	/* maintain linecount */
					continue;		/* skip it */
		}	}	}

		if (match_what
		&&  curfile
		&&  strcmp(match_what, curfile) != 0)
		{	continue;		/* preprocessed headers */
		}

		avoid_name_clash(buf, "empty");	/* empty -> Empty */
		avoid_name_clash(buf, "full");	/* full  -> Full */
		avoid_name_clash(buf, "init");	/* init  -> Init */
		avoid_name_clash(buf, "len");	/* len   -> Len */
		avoid_name_clash(buf, "skip");	/* skip  -> Skip */

		fprintf(fo, "%s", buf);
	}

if (debug_io) fprintf(stderr, "close 2x %p %p\n", fd, fo);

	Fclose(fd);
	Fclose(fo);
	fo = NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
movb $0x49, (%rdi)
leaq 0x8d07(%rip), %rsi      # 0x298df
movq %r14, %rdi
callq 0x4270
testq %rax, %rax
je 0x2108f
movq %rax, %rbx
leaq 0x17e25(%rip), %rbp     # 0x38a18
cmpl $0x0, (%rbp)
jne 0x210ac
leaq 0xcd3b(%rip), %rdi      # 0x2d93f
movl $0x16, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xcd39(%rip), %rdi      # 0x2d956
movl $0x15, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xcd36(%rip), %rdi      # 0x2d96c
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xcd3a(%rip), %rdi      # 0x2d989
movl $0x1b, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xcd3d(%rip), %rdi      # 0x2d9a5
movl $0x14, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xcd39(%rip), %rdi      # 0x2d9ba
movl $0x12, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0x4101(%rip), %rsi      # 0x24d9b
movq %r15, %rdi
callq 0x4270
testq %rax, %rax
je 0x20d1b
movq %rax, %r13
leaq 0xcd1c(%rip), %rdi      # 0x2d9cd
movl $0x1c, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
cmpl $0x0, (%rbp)
jne 0x21136
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x41a0
testq %rax, %rax
je 0x20d09
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x4170
movq %r15, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x41a0
testq %rax, %rax
jne 0x20ce9
cmpl $0x0, (%rbp)
jne 0x21159
movq %r13, %rdi
callq 0x77d0
leaq 0xccd5(%rip), %rdi      # 0x2d9f7
movl $0x1f, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xccdc(%rip), %rdi      # 0x2da17
movl $0x13, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xccd7(%rip), %rdi      # 0x2da2b
movl $0x13, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0xccd2(%rip), %rdi      # 0x2da3f
movl $0x13, %esi
movl $0x1, %edx
movq %rbx, %rcx
callq 0x42c0
leaq 0x17cca(%rip), %rax     # 0x38a50
movq (%rax), %rdi
testq %rdi, %rdi
je 0x20dfa
leaq 0x4006(%rip), %rsi      # 0x24d9b
callq 0x4270
testq %rax, %rax
je 0x20dfa
movq %rax, %r15
cmpl $0x0, (%rbp)
jne 0x21179
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdx
callq 0x41a0
testq %rax, %rax
je 0x20de8
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4170
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdx
callq 0x41a0
testq %rax, %rax
jne 0x20dc8
cmpl $0x0, (%rbp)
jne 0x21186
movq %r15, %rdi
callq 0x77d0
movb $0x63, (%r12)
leaq 0x3f95(%rip), %rsi      # 0x24d9b
movq %r14, %rdi
callq 0x4270
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x210cf
cmpl $0x0, (%rbp)
movq 0x18(%rsp), %r12
jne 0x210f0
leaq 0xcc54(%rip), %rsi      # 0x2da86
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x41d0
leaq 0x20(%rsp), %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x41a0
testq %rax, %rax
je 0x2105d
movl $0x1, 0x4(%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %r13
movq $0x0, 0x8(%rsp)
cmpq $0x0, 0x8(%rsp)
setne %al
cmpq $0x0, 0x10(%rsp)
setne %bpl
andb %al, %bpl
cmpb $0x23, 0x20(%rsp)
jne 0x20f55
leaq 0x28(%rsp), %r15
movzbl -0x7(%r15), %eax
cmpl $0x20, %eax
je 0x20eae
cmpl $0x9, %eax
jne 0x20eb3
incq %r15
jmp 0x20e9f
movsbq %al, %r14
callq 0x42e0
movq (%rax), %rax
leaq -0x7(%r15), %r12
testb $0x8, 0x1(%rax,%r14,2)
jne 0x20ee3
movl $0x4, %edx
movq %r12, %rdi
leaq 0x23e2(%rip), %rsi      # 0x232bc
callq 0x40a0
testl %eax, %eax
jne 0x20f11
movq %r12, %rdi
movl $0x22, %esi
callq 0x4130
testq %rax, %rax
je 0x20f11
movq %rax, %r14
incq %r14
movq %r14, %rdi
movl $0x22, %esi
callq 0x4130
testq %rax, %rax
jne 0x20fde
movl $0x7, %edx
movq %r12, %rdi
leaq 0xcb74(%rip), %rsi      # 0x2da94
callq 0x40a0
testl %eax, %eax
movq 0x18(%rsp), %r12
jne 0x20f55
jmp 0x20f33
incq %r15
movzbl (%r15), %eax
cmpl $0x20, %eax
je 0x20f30
cmpl $0x9, %eax
je 0x20f30
cmpb $0x3c, %al
jne 0x20f55
leaq 0x17af4(%rip), %rax     # 0x38a40
cmpl $0x0, (%rax)
je 0x21037
testb %bpl, %bpl
je 0x20f6d
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x41c0
testl %eax, %eax
jne 0x20fc3
movq %r13, %rdi
leaq 0xcb25(%rip), %rsi      # 0x2da9c
callq 0x211a6
movq %r13, %rdi
leaq 0xcb1c(%rip), %rsi      # 0x2daa2
callq 0x211a6
movq %r13, %rdi
leaq 0x4bc7(%rip), %rsi      # 0x25b5c
callq 0x211a6
movq %r13, %rdi
leaq 0xcb03(%rip), %rsi      # 0x2daa7
callq 0x211a6
movq %r13, %rdi
leaq 0xcaf8(%rip), %rsi      # 0x2daab
callq 0x211a6
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4170
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x41a0
testq %rax, %rax
jne 0x20e8f
jmp 0x2105d
movb $0x0, (%rax)
cmpl $0x0, 0x4(%rsp)
movq 0x18(%rsp), %r12
je 0x2100d
movq %r14, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6321
movq %rax, 0x8(%rsp)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
movq %r14, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x6321
movq %rax, 0x10(%rsp)
movq %rax, %rdi
movq %r14, %rsi
callq 0x40b0
movl $0x0, 0x4(%rsp)
jmp 0x21044
movl $0xa, %edi
movq %rbx, %rsi
callq 0x4190
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x41a0
testq %rax, %rax
jne 0x20e79
leaq 0x179b4(%rip), %rax     # 0x38a18
cmpl $0x0, (%rax)
jne 0x21113
movq %r12, %rdi
callq 0x77d0
movq %rbx, %rdi
callq 0x77d0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x14f62(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc886(%rip), %rsi      # 0x2d926
movq %r14, %rdx
xorl %eax, %eax
callq 0x41d0
jmp 0x210da
movq 0x14f45(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc9b9(%rip), %rsi      # 0x2da76
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x41d0
jmp 0x20bfd
movq %r14, %rdi
movq %r12, %rsi
callq 0x5d38
leaq 0x2ad3(%rip), %rdi      # 0x23bb4
callq 0x4080
movl $0x1, %edi
callq 0x42b0
movq 0x14f01(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc973(%rip), %rsi      # 0x2da74
movq %r14, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0x41d0
jmp 0x20e2b
movq 0x14ede(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc98c(%rip), %rsi      # 0x2dab0
movq %r12, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x41d0
jmp 0x2106d
movq 0x14ebb(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc92f(%rip), %rsi      # 0x2da76
movq %r15, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x41d0
jmp 0x20ccd
movq 0x14e98(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc880(%rip), %rsi      # 0x2d9ea
movq %r13, %rdx
xorl %eax, %eax
callq 0x41d0
jmp 0x20d13
movq %r15, %rdi
callq 0x5d0d
jmp 0x20dac
movq 0x14e6b(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0xc8bc(%rip), %rsi      # 0x2da53
movq %r15, %rdx
xorl %eax, %eax
callq 0x41d0
jmp 0x20df2