// File: /workspace/github_c_makefile_star2_O2/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, %r12
movq %rsi, %r14
movq %rdi, %r15
movb $0x49, (%rdi)
leaq 0x891f(%rip), %rsi      # 0x277ef
movq %r14, %rdi
callq 0x4270
testq %rax, %rax
je 0x1f32c
movq %rax, %rbx
leaq 0x17b2d(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f349
leaq 0xc964(%rip), %rdi      # 0x2b85f
pushq $0x16
popq %rsi
pushq $0x1
popq %r13
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc962(%rip), %rdi      # 0x2b876
pushq $0x15
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc963(%rip), %rdi      # 0x2b88c
pushq $0x1c
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc96b(%rip), %rdi      # 0x2b8a9
pushq $0x1b
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc972(%rip), %rdi      # 0x2b8c5
pushq $0x14
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc972(%rip), %rdi      # 0x2b8da
pushq $0x12
popq %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0x3d1e(%rip), %rsi      # 0x22c9b
movq %r12, %rdi
callq 0x4270
testq %rax, %rax
je 0x1eff1
movq %rax, %r13
leaq 0xc959(%rip), %rdi      # 0x2b8ed
pushq $0x1c
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0x17a6f(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f3f7
leaq 0x20(%rsp), %r12
movq %r12, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x4190
testq %rax, %rax
je 0x1efd9
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4170
jmp 0x1efb7
leaq 0x17a38(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f41a
movq %r13, %rdi
callq 0x59e0
leaq 0xc91f(%rip), %rdi      # 0x2b917
pushq $0x1f
popq %rsi
pushq $0x1
popq %r12
movq %r12, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc926(%rip), %rdi      # 0x2b937
pushq $0x13
popq %r13
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc921(%rip), %rdi      # 0x2b94b
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0xc920(%rip), %rdi      # 0x2b95f
movq %r13, %rsi
movq %r12, %rdx
movq %rbx, %rcx
callq 0x42c0
leaq 0x179fc(%rip), %r13     # 0x36a50
movq (%r13), %rdi
testq %rdi, %rdi
je 0x1f0c0
leaq 0x3c37(%rip), %rsi      # 0x22c9b
callq 0x4270
testq %rax, %rax
je 0x1f0c0
movq %rax, %r12
leaq 0x179a0(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f43a
leaq 0x20(%rsp), %r13
movq %r13, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdx
callq 0x4190
testq %rax, %rax
je 0x1f0a8
movq %r13, %rdi
movq %rbx, %rsi
callq 0x4170
jmp 0x1f086
leaq 0x17969(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f45e
movq %r12, %rdi
callq 0x59e0
movb $0x63, (%r15)
leaq 0x3bd0(%rip), %rsi      # 0x22c9b
movq %r14, %rdi
callq 0x4270
testq %rax, %rax
je 0x1f36c
movq %rax, %r13
leaq 0x17932(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f3b1
leaq 0xc8b0(%rip), %rsi      # 0x2b9a6
xorl %ebp, %ebp
movq %rbx, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x41c0
leaq 0x20(%rsp), %r14
xorl %r15d, %r15d
movq $0x0, 0x8(%rsp)
movq %rbx, 0x18(%rsp)
movq %r13, 0x10(%rsp)
testq %rbp, %rbp
setne %al
testq %r15, %r15
setne %cl
andb %al, %cl
movb %cl, 0x7(%rsp)
movq %r14, %rdi
movl $0x400, %esi            # imm = 0x400
movq %r13, %rdx
callq 0x4190
testq %rax, %rax
je 0x1f2fa
cmpb $0x23, 0x20(%rsp)
jne 0x1f216
leaq 0x28(%rsp), %r12
movzbl -0x7(%r12), %eax
cmpl $0x20, %eax
je 0x1f16b
cmpl $0x9, %eax
jne 0x1f170
incq %r12
jmp 0x1f15b
movq %rbp, %rbx
movsbq %al, %r13
callq 0x42e0
movq (%rax), %rax
leaq -0x7(%r12), %rbp
testb $0x8, 0x1(%rax,%r13,2)
jne 0x1f1a2
movq %rbp, %rdi
leaq 0x2126(%rip), %rsi      # 0x212bc
pushq $0x4
popq %rdx
callq 0x40a0
testl %eax, %eax
jne 0x1f1cc
movq %rbp, %rdi
pushq $0x22
popq %rsi
callq 0x4130
testq %rax, %rax
je 0x1f1cc
movq %rax, %r13
incq %r13
movq %r13, %rdi
pushq $0x22
popq %rsi
callq 0x4130
testq %rax, %rax
jne 0x1f29b
movq %rbp, %rdi
leaq 0xc7de(%rip), %rsi      # 0x2b9b4
pushq $0x7
popq %rdx
callq 0x40a0
testl %eax, %eax
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rax
movq %rbx, %rbp
movq %rax, %rbx
jne 0x1f216
jmp 0x1f1f7
incq %r12
movzbl (%r12), %eax
cmpl $0x20, %eax
je 0x1f1f4
cmpl $0x9, %eax
je 0x1f1f4
cmpb $0x3c, %al
jne 0x1f216
leaq 0x1782f(%rip), %rax     # 0x36a40
cmpl $0x0, (%rax)
je 0x1f28b
cmpb $0x0, 0x7(%rsp)
je 0x1f230
movq %rbp, %rdi
movq %r15, %rsi
callq 0x41b0
testl %eax, %eax
jne 0x1f132
movq %r14, %rdi
leaq 0xc782(%rip), %rsi      # 0x2b9bc
callq 0x1f47e
movq %r14, %rdi
leaq 0xc779(%rip), %rsi      # 0x2b9c2
callq 0x1f47e
movq %r14, %rdi
leaq 0x4804(%rip), %rsi      # 0x23a5c
callq 0x1f47e
movq %r14, %rdi
leaq 0xc760(%rip), %rsi      # 0x2b9c7
callq 0x1f47e
movq %r14, %rdi
leaq 0xc755(%rip), %rsi      # 0x2b9cb
callq 0x1f47e
movq %r14, %rdi
movq %rbx, %rsi
callq 0x4170
jmp 0x1f132
pushq $0xa
popq %rdi
movq %rbx, %rsi
callq 0x4180
jmp 0x1f132
movb $0x0, (%rax)
testb $0x1, 0x8(%rsp)
movq %rbx, %rbp
jne 0x1f2c6
movq %r13, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x4739
movq %rax, %rbp
movq %rax, %rdi
movq %r13, %rsi
callq 0x40b0
movq %r13, %rdi
callq 0x4110
leal 0x1(%rax), %edi
callq 0x4739
movq %rax, %r15
movq %rax, %rdi
movq %r13, %rsi
callq 0x40b0
movb $0x1, %al
movq %rax, 0x8(%rsp)
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
jmp 0x1f120
leaq 0x17717(%rip), %rax     # 0x36a18
cmpl $0x0, (%rax)
jne 0x1f3d4
movq %r13, %rdi
callq 0x59e0
movq %rbx, %rdi
callq 0x59e0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x14cc5(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc509(%rip), %rsi      # 0x2b846
movq %r14, %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1f39d
movq 0x14ca8(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc63c(%rip), %rsi      # 0x2b996
movq %r14, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x41c0
jmp 0x1eef4
movq 0x14c85(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0x14e23(%rip), %rax     # 0x341a0
movq (%rax), %rdx
leaq 0xc5f9(%rip), %rsi      # 0x2b980
movq %r14, %rcx
xorl %eax, %eax
callq 0x41c0
movb $0x49, (%r15)
movq %r14, %rdi
callq 0x4080
leaq 0x2810(%rip), %rdi      # 0x21bb4
callq 0x4080
pushq $0x1
popq %rdi
callq 0x42b0
movq 0x14c40(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc5d2(%rip), %rsi      # 0x2b994
movq %r14, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x41c0
jmp 0x1f0ef
movq 0x14c1d(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc5eb(%rip), %rsi      # 0x2b9d0
movq %r13, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x41c0
jmp 0x1f30a
movq 0x14bfa(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc58e(%rip), %rsi      # 0x2b996
movq %r12, %rdx
movq %r13, %rcx
xorl %eax, %eax
callq 0x41c0
jmp 0x1efb2
movq 0x14bd7(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc4df(%rip), %rsi      # 0x2b90a
movq %r13, %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1efe9
movq 0x14bb7(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
movq (%r13), %rdx
leaq 0xc547(%rip), %rsi      # 0x2b996
movq %r12, %rcx
xorl %eax, %eax
callq 0x41c0
jmp 0x1f081
movq 0x14b93(%rip), %rax     # 0x33ff8
movq (%rax), %rdi
leaq 0xc504(%rip), %rsi      # 0x2b973
movq %r12, %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1f0b8