// File: /workspace/github_c_makefile_star2_O1/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 %r14
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
leaq 0x1a251(%rip), %rax     # 0x24a9b
movq %rax, 0x2f227(%rip)     # 0x39a78
callq 0x8125
movq 0x2c923(%rip), %rdi     # 0x37180
callq 0x40d0
cmpl $0x0, 0x2f1bf(%rip)     # 0x39a28
setne %al
cmpl $0x0, 0x2f1d5(%rip)     # 0x39a48
sete %cl
testb %cl, %al
jne 0xa89a
cmpl $0x0, 0x2f1ab(%rip)     # 0x39a2c
jne 0xa89a
cmpl $0x0, 0x2f19a(%rip)     # 0x39a24
jne 0xa89a
movq 0x2f1e5(%rip), %rdi     # 0x39a78
callq 0xa14c
jmp 0xa8b0
leaq 0x1c7f3(%rip), %rsi     # 0x27094
movl $0x78, %edi
movl $0x4, %edx
callq 0x7fdb
cmpl $0x0, 0x2f875(%rip)     # 0x3a12c
jne 0xa97a
movq 0x2f1b4(%rip), %rdi     # 0x39a78
leaq 0x1a01d(%rip), %rsi     # 0x248e8
callq 0x42c0
testq %rax, %rax
je 0xa97a
movq %rax, %rbx
movw $0x63, 0x1(%rax)
movq 0x2f18f(%rip), %rdi     # 0x39a78
leaq 0x1b4ab(%rip), %rsi     # 0x25d9b
callq 0x4260
testq %rax, %rax
jne 0xa919
movq 0x2f177(%rip), %rsi     # 0x39a78
leaq 0x1a159(%rip), %rdi     # 0x24a61
xorl %eax, %eax
callq 0x4140
movl $0x1, %edi
callq 0x42a0
movq %rax, %r14
cmpl $0x0, 0x2f0e5(%rip)     # 0x39a08
je 0xa947
movq 0x2c6cc(%rip), %rax     # 0x36ff8
movq (%rax), %rdi
movq 0x2f142(%rip), %rdx     # 0x39a78
leaq 0x199ac(%rip), %rsi     # 0x242e9
movq %r14, %rcx
xorl %eax, %eax
callq 0x41c0
movq %r14, %rdi
callq 0x793c
cmpl $0x0, 0x2f0b6(%rip)     # 0x39a0c
je 0xa966
leaq 0x1a0de(%rip), %rdi     # 0x24a3d
xorl %eax, %eax
callq 0x4140
movq 0x2f10b(%rip), %rdi     # 0x39a78
xorl %esi, %esi
callq 0x8d18
movw $0x7270, 0x1(%rbx)      # imm = 0x7270
movq 0x2f0f7(%rip), %rbx     # 0x39a78
leaq 0x2f7b8(%rip), %rdi     # 0x3a140
movq %rbx, %rsi
callq 0x40b0
leaq 0x1a104(%rip), %rsi     # 0x24a9b
movq %rbx, %rdi
callq 0x41b0
testl %eax, %eax
je 0xa9c1
leaq 0x19f3e(%rip), %rsi     # 0x248e8
movq %rbx, %rdi
callq 0x42c0
testq %rax, %rax
jne 0xa9c1
movq %rbx, %rdi
xorl %esi, %esi
callq 0x8d18
cmpl $0x0, 0x2f05c(%rip)     # 0x39a24
jne 0xaa8d
callq 0x88bb
testl %eax, %eax
je 0xaa5c
xorl %r14d, %r14d
movq 0x2c5eb(%rip), %rbx     # 0x36fd0
cmpl $0x0, 0x2f03c(%rip)     # 0x39a28
je 0xa9fb
cmpl $0x0, 0x2f053(%rip)     # 0x39a48
je 0xaa9e
movq 0x2f93e(%rip), %rax     # 0x3a340
testq %rax, %rax
je 0xaa16
movq 0x10(%rax), %rax
movq (%rax), %rdi
movq (%rbx), %rsi
callq 0x7529
movq 0x2f92b(%rip), %rdi     # 0x3a348
movq 0x2c77c(%rip), %rsi     # 0x371a0
callq 0x141a2
testq %r14, %r14
je 0xaa4c
cmpq %r14, 0x2f90b(%rip)     # 0x3a340
je 0xaa4c
movq 0x10(%r14), %rax
testq %rax, %rax
je 0xaa4c
movq (%rax), %rsi
xorl %edi, %edi
xorl %edx, %edx
callq 0xe783
movq 0x2f8ed(%rip), %r14     # 0x3a340
callq 0x88bb
testl %eax, %eax
jne 0xa9e5
cmpl $0x0, 0x2f249(%rip)     # 0x39cac
je 0xaa74
movq 0x2c564(%rip), %rax     # 0x36fd0
movq (%rax), %rdi
callq 0xfefa
movq 0x2f8c5(%rip), %rax     # 0x3a340
testq %rax, %rax
je 0xaa89
movq 0x10(%rax), %rax
testq %rax, %rax
jne 0xaad1
xorl %esi, %esi
jmp 0xaad4
movq 0x2f8b4(%rip), %rdi     # 0x3a348
callq 0x21eef
jmp 0xad06
cmpl $0x0, 0x2ef67(%rip)     # 0x39a0c
je 0xaca6
movq (%rbx), %rdi
movq 0x2efc3(%rip), %rdx     # 0x39a78
movq 0x2f88c(%rip), %rax     # 0x3a348
testq %rax, %rax
jne 0xac3d
leaq 0x19fce(%rip), %rcx     # 0x24a9a
jmp 0xac41
movq (%rax), %rsi
xorl %edi, %edi
movl $0x1, %edx
callq 0xe783
cmpb $0x1, 0x2f209(%rip)     # 0x39cf0
jne 0xab12
testb $0x1, 0x2f640(%rip)     # 0x3a130
je 0xab12
cmpl $0x0, 0x2f18f(%rip)     # 0x39c88
jne 0xab57
movq 0x2f1d6(%rip), %rdi     # 0x39cd8
callq 0xef49
cmpb $0x1, 0x2f61a(%rip)     # 0x3a128
je 0xab3a
jmp 0xab57
movq 0x2c697(%rip), %rdi     # 0x371b0
leaq 0x197e4(%rip), %rsi     # 0x24304
callq 0x90da
movq 0x2f1ac(%rip), %rdi     # 0x39cd8
callq 0xef49
cmpb $0x0, 0x2f5f0(%rip)     # 0x3a128
je 0xab57
movq 0x2f197(%rip), %rcx     # 0x39cd8
leaq 0x19f70(%rip), %rdi     # 0x24ab8
movl $0x17, %esi
movl $0x1, %edx
callq 0x42b0
movq 0x2f17a(%rip), %rdx     # 0x39cd8
testq %rdx, %rdx
je 0xab90
cmpl $0x0, 0x2ee9e(%rip)     # 0x39a08
je 0xab84
movq 0x2c485(%rip), %rax     # 0x36ff8
movq (%rax), %rdi
leaq 0x19f53(%rip), %rsi     # 0x24ad0
xorl %eax, %eax
callq 0x41c0
movq 0x2f14d(%rip), %rdi     # 0x39cd8
callq 0x793c
cmpl $0x0, 0x2eed5(%rip)     # 0x39a6c
jne 0xabb4
cmpl $0x0, 0x2eed0(%rip)     # 0x39a70
jne 0xabb4
cmpl $0x0, 0x2ee63(%rip)     # 0x39a0c
jne 0xabb4
cmpl $0x0, 0x2f0ea(%rip)     # 0x39c9c
je 0xabc0
leaq 0x19ff9(%rip), %rdi     # 0x24bb4
callq 0xe728
movq 0x2c431(%rip), %r14     # 0x36ff8
movq (%r14), %rdi
callq 0xed63
callq 0x14153
cmpl $0x0, 0x2ee91(%rip)     # 0x39a6c
jne 0xabfc
cmpl $0x0, 0x2ee28(%rip)     # 0x39a0c
jne 0xabfc
cmpl $0x0, 0x2ee83(%rip)     # 0x39a70
jne 0xabfc
cmpl $0x0, 0x2f0a6(%rip)     # 0x39c9c
je 0xad0d
movq (%r14), %rcx
leaq 0x19ed6(%rip), %rdi     # 0x24adc
movl $0x14, %esi
movl $0x1, %edx
callq 0x42b0
leaq 0x19ed5(%rip), %rsi     # 0x24af1
leaq 0x19bc0(%rip), %rdx     # 0x247e3
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
callq 0x4120
jmp 0xad06
movq 0x8(%rax), %rcx
cmpl $0x0, 0x2ee1c(%rip)     # 0x39a64
leaq 0x1c445(%rip), %rax     # 0x27094
leaq 0x19e47(%rip), %r8      # 0x24a9d
cmoveq %rax, %r8
cmpl $0x0, 0x2ee07(%rip)     # 0x39a68
leaq 0x19e3b(%rip), %r9      # 0x24aa3
cmoveq %rax, %r9
cmpl $0x0, 0x2eded(%rip)     # 0x39a60
leaq 0x19e30(%rip), %r10     # 0x24aaa
cmoveq %rax, %r10
cmpl $0x0, 0x2edd7(%rip)     # 0x39a5c
leaq 0x19e25(%rip), %r11     # 0x24ab1
cmoveq %rax, %r11
leaq 0x19de6(%rip), %rsi     # 0x24a7d
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x41c0
addq $0x10, %rsp
cmpl $0x0, 0x2edb7(%rip)     # 0x39a64
je 0xacb7
movq (%rbx), %rdi
callq 0x1f3e4
cmpl $0x0, 0x2edaa(%rip)     # 0x39a68
je 0xacd3
movq 0x2f679(%rip), %rax     # 0x3a340
movq 0x10(%rax), %rdi
movq (%rbx), %rsi
callq 0x7486
cmpl $0x0, 0x2ed86(%rip)     # 0x39a60
je 0xace1
callq 0x1eb4a
cmpl $0x0, 0x2ed74(%rip)     # 0x39a5c
je 0xacf9
movq 0x2f657(%rip), %rdi     # 0x3a348
movq (%rbx), %rsi
callq 0x213a8
movq (%rbx), %rsi
movl $0xa, %edi
callq 0x4190
xorl %edi, %edi
callq 0x42a0
leaq 0x19df2(%rip), %rsi     # 0x24b06
leaq 0x19ac8(%rip), %rdx     # 0x247e3
movq %rsp, %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x4290
movq %rbx, %rdi
callq 0x4120
testl %eax, %eax
je 0xad4d
movq (%r14), %rcx
leaq 0x19ddc(%rip), %rdi     # 0x24b1a
movl $0x1d, %esi
movl $0x1, %edx
callq 0x42b0
cmpl $0x0, 0x2ecf8(%rip)     # 0x39a4c
jne 0xad64
leaq 0x19e44(%rip), %rdi     # 0x24ba1
callq 0x40d0
jmp 0xad06
leaq 0x19dcd(%rip), %rsi     # 0x24b38
jmp 0xac1c