// File: /workspace/github_c_makefile_star2_O3/nimble-code[P]Modex/Src/modex.c
// Function: main
int
main(int argc, char **argv)
{	FILE *fd;
	char cmd[256];

	context_t *o_ctx = NULL;

	file_name = "-";			/* default only */

	if (!BldCmds(argc,argv))		/* sets file_name */
	{	Usage(argv[0]);			/* command-line options */
	}

	printf("%s\n", VERSION);

	if ((!do_dflow || du_mode) && !preview && !predot)
	{	checkprx(file_name);		/* prx file options */
	} else
	{	new_cmd('x', "", 4);
	}

	if (!sawFile)				/* no %F command in prx file */
	{	char *z;
		if ((z = strstr(file_name, ".prx")) != NULL)
		{	z++; *z++ = 'c'; *z = '\0';	/* default .c */
			if ((fd = fopen(file_name, "r")) != NULL)
			{
if (debug_io) fprintf(stderr, "Open %s -> %p\n", file_name, fd);
				Fclose(fd);
				if (Verbose_cmds)
				{	printf("-- saw no %%F commands in prx file\n");
				}
				process_input(file_name, 0);
			} else
			{	printf("modex: warning: no file %s\n", file_name);
				exit(1);
			}
			*z-- = 'r'; *z = 'p';		/* restore */
	}	}

	strcpy(cur_in, file_name);

	if (strcmp(file_name, "-") != 0
	&&  strstr(file_name, ".prx") == NULL)
	{	process_input(file_name, 0);	/* parses file */
	}

	if (predot)
	{	dot_start(parse_tree);		/* ps_graph.c */
		exit(0);
	}

	/* model extraction functionality: */

	while (ActCmds())
	{	if (do_dflow && !du_mode)
		{	if (Verbose_cmds)
			fprintf(stdout, "/*** %s :: %s %s%s%s%s***/\n\n",
				file_name,
				parse_tree?parse_tree->hdr.fnm:"--",
				show_funcs?"+fcs ":"",
				show_syms?"+syms ":"",
				show_deps?"+deps ":"",
				show_code?"+code ":"");

			if (show_funcs)	show_fbase(stdout);
			if (show_syms)	show_symtab(contxt->syms, stdout);
			if (show_deps)	dep_show();
			if (show_code)  print_tree(parse_tree, stdout);
			fprintf(stdout, "\n");
			exit(0);
		} else
		{	if (0) fprintf(stderr, "Act %d %d -- %s\n", extended, flike, want);
			if (contxt)
			save_fcts(contxt->syms->root, stdout);
			modex_tree(parse_tree, lutt);	/* xtract.c */

			// call do_globals here to avoid losing the info
			// if a different file is parsed next
			if (o_ctx != NULL && contxt != o_ctx && o_ctx->syms)
			{	do_globals(0, o_ctx->syms->root, 0);
			}
			o_ctx = contxt;
	}	}

	if (redundancies)
	{	notimported(stdout);
	}

	if (contxt && contxt->syms)
	{	do_globals(0, contxt->syms->root, 1);
	} else
	{	do_globals(0, (scopetab_t *) 0, 1);
	}

	if (!hasdrv || !haspml)
	{	header(modelname, ".drv");
		def_inc_spn(fdrv);
		if (hasltl) fprintf(fdrv, "#include \"_modex_.ltl\"\n");
	} else if (!anybody) /* added Oct 20, 2012 */
	{	def_inc_spn(fdrv);
		if (hasltl) fprintf(fdrv, "#include \"_modex_.ltl\"\n");
	}

	if (fdrv)
	{
if (debug_io) fprintf(stderr, "close C %p\n", fdrv);
		Fclose(fdrv);
	}

	if (Verbose || Warnings || Verbose_cmds || new_lut)
	{	add_fnm("_modex_.run");
	}

	spitnames(stderr);
	alldone();

	if (Verbose || Verbose_cmds || Warnings || new_lut)
	{	fprintf(stderr, "./_modex_.run pprep\n");
		sprintf(cmd, "%s _modex_.run pprep", SH);
		system(cmd); /* preserve temp files */
	} else
	{	sprintf(cmd, "%s _modex_.run prep", SH);
		if (system(cmd) != 0)
		{	fprintf(stderr, "modex: model creation failed\n");
		}
		if (tagrun)
		{	sprintf(cmd, "%s _modex_.run run", SH);
			system(cmd);
		} else
		{	printf("created: model and _modex_.run\n");
	}	}
	exit(0);
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x100, %rsp            # imm = 0x100
leaq 0x193b7(%rip), %rax     # 0x23a9b
movq %rax, 0x2e39d(%rip)     # 0x38a88
callq 0x7fb2
movq 0x2ba99(%rip), %rdi     # 0x36190
callq 0x40d0
cmpl $0x0, 0x2e335(%rip)     # 0x38a38
setne %al
cmpl $0x0, 0x2e34b(%rip)     # 0x38a58
sete %cl
testb %cl, %al
jne 0xa734
cmpl $0x0, 0x2e321(%rip)     # 0x38a3c
jne 0xa734
cmpl $0x0, 0x2e310(%rip)     # 0x38a34
jne 0xa734
movq 0x2e35b(%rip), %rdi     # 0x38a88
callq 0x9fe1
jmp 0xa74a
leaq 0x1b956(%rip), %rsi     # 0x26091
movl $0x78, %edi
movl $0x4, %edx
callq 0x7e6f
cmpl $0x0, 0x2e9eb(%rip)     # 0x3913c
movq 0x2e330(%rip), %r14     # 0x38a88
jne 0xa81e
leaq 0x19183(%rip), %rsi     # 0x238e8
movq %r14, %rdi
callq 0x42d0
testq %rax, %rax
je 0xa81e
movq %rax, %rbx
movw $0x63, 0x1(%rax)
movq 0x2e302(%rip), %rdi     # 0x38a88
leaq 0x1a60e(%rip), %rsi     # 0x24d9b
callq 0x4270
testq %rax, %rax
jne 0xa7b6
movq 0x2e2ea(%rip), %rsi     # 0x38a88
leaq 0x192bc(%rip), %rdi     # 0x23a61
xorl %eax, %eax
callq 0x4140
movl $0x1, %edi
callq 0x42b0
movq %rax, %r14
cmpl $0x0, 0x2e258(%rip)     # 0x38a18
je 0xa7e4
movq 0x2b82f(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
movq 0x2e2b5(%rip), %rdx     # 0x38a88
leaq 0x18b0f(%rip), %rsi     # 0x232e9
movq %r14, %rcx
xorl %eax, %eax
callq 0x41d0
movq %r14, %rdi
callq 0x77d0
cmpl $0x0, 0x2e229(%rip)     # 0x38a1c
je 0xa803
leaq 0x19241(%rip), %rdi     # 0x23a3d
xorl %eax, %eax
callq 0x4140
movq 0x2e27e(%rip), %rdi     # 0x38a88
xorl %esi, %esi
callq 0x8b88
movw $0x7270, 0x1(%rbx)      # imm = 0x7270
movq 0x2e26a(%rip), %r14     # 0x38a88
leaq 0x2e92b(%rip), %rdi     # 0x39150
movq %r14, %rsi
callq 0x40b0
cmpb $0x2d, (%r14)
jne 0xa83a
cmpb $0x0, 0x1(%r14)
je 0xa858
leaq 0x190a7(%rip), %rsi     # 0x238e8
movq %r14, %rdi
callq 0x42d0
testq %rax, %rax
jne 0xa858
movq %r14, %rdi
xorl %esi, %esi
callq 0x8b88
cmpl $0x0, 0x2e1d5(%rip)     # 0x38a34
jne 0xa934
callq 0x8737
testl %eax, %eax
je 0xa903
xorl %r14d, %r14d
movq 0x2b754(%rip), %rbx     # 0x35fd0
cmpl $0x0, 0x2e1b5(%rip)     # 0x38a38
je 0xa892
cmpl $0x0, 0x2e1cc(%rip)     # 0x38a58
je 0xa945
movq 0x2eab7(%rip), %rax     # 0x39350
testq %rax, %rax
je 0xa8ad
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq (%rbx), %rsi
callq 0x73d4
movq 0x2eaa4(%rip), %rdi     # 0x39358
movq 0x2b8f5(%rip), %rsi     # 0x361b0
callq 0x142b1
testq %r14, %r14
sete %al
movq 0x2ea83(%rip), %r15     # 0x39350
cmpq %r14, %r15
sete %cl
orb %al, %cl
jne 0xa8f3
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xa8f3
movq (%rax), %rsi
xorl %edi, %edi
xorl %edx, %edx
callq 0xe63e
movq 0x2ea5d(%rip), %r15     # 0x39350
callq 0x8737
movq %r15, %r14
testl %eax, %eax
jne 0xa87c
cmpl $0x0, 0x2e3b2(%rip)     # 0x38cbc
je 0xa91b
movq 0x2b6bd(%rip), %rax     # 0x35fd0
movq (%rax), %rdi
callq 0xfe02
movq 0x2ea2e(%rip), %rax     # 0x39350
testq %rax, %rax
je 0xa930
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0xa978
xorl %esi, %esi
jmp 0xa97b
movq 0x2ea1d(%rip), %rdi     # 0x39358
callq 0x21523
jmp 0xabb0
cmpl $0x0, 0x2e0d0(%rip)     # 0x38a1c
je 0xab50
movq (%rbx), %rdi
movq 0x2e12c(%rip), %rdx     # 0x38a88
movq 0x2e9f5(%rip), %rax     # 0x39358
testq %rax, %rax
jne 0xaae7
leaq 0x19127(%rip), %rcx     # 0x23a9a
jmp 0xaaeb
movq (%rax), %rsi
xorl %edi, %edi
movl $0x1, %edx
callq 0xe63e
cmpb $0x1, 0x2e372(%rip)     # 0x38d00
jne 0xa9b9
testb $0x1, 0x2e7a9(%rip)     # 0x39140
je 0xa9b9
cmpl $0x0, 0x2e2f8(%rip)     # 0x38c98
jne 0xa9fe
movq 0x2e33f(%rip), %rdi     # 0x38ce8
callq 0xedf1
cmpb $0x1, 0x2e783(%rip)     # 0x39138
je 0xa9e1
jmp 0xa9fe
movq 0x2b800(%rip), %rdi     # 0x361c0
leaq 0x1893d(%rip), %rsi     # 0x23304
callq 0x8f1e
movq 0x2e315(%rip), %rdi     # 0x38ce8
callq 0xedf1
cmpb $0x0, 0x2e759(%rip)     # 0x39138
je 0xa9fe
movq 0x2e300(%rip), %rcx     # 0x38ce8
leaq 0x190c9(%rip), %rdi     # 0x23ab8
movl $0x17, %esi
movl $0x1, %edx
callq 0x42c0
movq 0x2e2e3(%rip), %rdx     # 0x38ce8
testq %rdx, %rdx
je 0xaa3a
cmpl $0x0, 0x2e007(%rip)     # 0x38a18
je 0xaa32
movq 0x2b5de(%rip), %rax     # 0x35ff8
movq (%rax), %rdi
leaq 0x190ac(%rip), %rsi     # 0x23ad0
xorl %eax, %eax
callq 0x41d0
movq 0x2e2b6(%rip), %rdx     # 0x38ce8
movq %rdx, %rdi
callq 0x77d0
cmpl $0x0, 0x2e03b(%rip)     # 0x38a7c
jne 0xaa5e
cmpl $0x0, 0x2e036(%rip)     # 0x38a80
jne 0xaa5e
cmpl $0x0, 0x2dfc9(%rip)     # 0x38a1c
jne 0xaa5e
cmpl $0x0, 0x2e250(%rip)     # 0x38cac
je 0xaa6a
leaq 0x1914f(%rip), %rdi     # 0x23bb4
callq 0xe5e3
movq 0x2b587(%rip), %r14     # 0x35ff8
movq (%r14), %rdi
callq 0xec0b
callq 0x1425f
cmpl $0x0, 0x2dff7(%rip)     # 0x38a7c
jne 0xaaa6
cmpl $0x0, 0x2df8e(%rip)     # 0x38a1c
jne 0xaaa6
cmpl $0x0, 0x2dfe9(%rip)     # 0x38a80
jne 0xaaa6
cmpl $0x0, 0x2e20c(%rip)     # 0x38cac
je 0xabb7
movq (%r14), %rcx
leaq 0x1902c(%rip), %rdi     # 0x23adc
movl $0x14, %esi
movl $0x1, %edx
callq 0x42c0
leaq 0x1902b(%rip), %rsi     # 0x23af1
leaq 0x18d16(%rip), %rdx     # 0x237e3
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42a0
movq %rbx, %rdi
callq 0x4120
jmp 0xabb0
movq 0x8(%rax), %rcx
cmpl $0x0, 0x2df82(%rip)     # 0x38a74
leaq 0x1b598(%rip), %rax     # 0x26091
leaq 0x18f9d(%rip), %r8      # 0x23a9d
cmoveq %rax, %r8
cmpl $0x0, 0x2df6d(%rip)     # 0x38a78
leaq 0x18f91(%rip), %r9      # 0x23aa3
cmoveq %rax, %r9
cmpl $0x0, 0x2df53(%rip)     # 0x38a70
leaq 0x18f86(%rip), %r10     # 0x23aaa
cmoveq %rax, %r10
cmpl $0x0, 0x2df3d(%rip)     # 0x38a6c
leaq 0x18f7b(%rip), %r11     # 0x23ab1
cmoveq %rax, %r11
leaq 0x18f3c(%rip), %rsi     # 0x23a7d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x41d0
addq $0x10, %rsp
cmpl $0x0, 0x2df1d(%rip)     # 0x38a74
je 0xab61
movq (%rbx), %rdi
callq 0x1e9c9
cmpl $0x0, 0x2df10(%rip)     # 0x38a78
je 0xab7d
movq 0x2e7df(%rip), %rax     # 0x39350
movq 0x10(%rax), %rdi
movq (%rbx), %rsi
callq 0x7331
cmpl $0x0, 0x2deec(%rip)     # 0x38a70
je 0xab8b
callq 0x1e104
cmpl $0x0, 0x2deda(%rip)     # 0x38a6c
je 0xaba3
movq 0x2e7bd(%rip), %rdi     # 0x39358
movq (%rbx), %rsi
callq 0x209ca
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x4190
xorl %edi, %edi
callq 0x42b0
leaq 0x18f48(%rip), %rsi     # 0x23b06
leaq 0x18c1e(%rip), %rdx     # 0x237e3
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x42a0
movq %rbx, %rdi
callq 0x4120
testl %eax, %eax
je 0xabf7
movq (%r14), %rcx
leaq 0x18f32(%rip), %rdi     # 0x23b1a
movl $0x1d, %esi
movl $0x1, %edx
callq 0x42c0
cmpl $0x0, 0x2de5e(%rip)     # 0x38a5c
jne 0xac0e
leaq 0x18f9a(%rip), %rdi     # 0x23ba1
callq 0x40d0
jmp 0xabb0
leaq 0x18f23(%rip), %rsi     # 0x23b38
jmp 0xaac6
nop