// File: /workspace/github_c_makefile_star2_O3/9wm[P]9wm/9wm.c
// Function: main
int
main(int argc, char *argv[])
{
	int i, do_exit, do_restart;
	char *fname;
	int shape_event, dummy;
	myargv = argv;		/* for restart */

	do_exit = do_restart = 0;
	font = 0;
	fname = 0;
	for (i = 1; i < argc; i++)
		if (strcmp(argv[i], "-debug") == 0) {
			debug++;
#ifndef DEBUG
		fprintf(stderr,"9wm: WARNING! debug option enabled but debug code not compiled in!\nDebug info may not be complete!\n");
#endif
		} else if (strcmp(argv[i], "-font") == 0 && i + 1 < argc)
			fname = argv[++i];
		else if (strcmp(argv[i], "-term") == 0 && i + 1 < argc)
			termprog = argv[++i];
		else if (strcmp(argv[i], "-version") == 0) {
			fprintf(stderr, "%s\n", version[0]);
			exit(0);
		} else if (strcmp(argv[i],"-border") == 0)
			border++;
		else if (strcmp(argv[i],"-cursor")  == 0 && i + 1 < argc) {
			i++;
			if (strcmp(argv[i],"v1") == 0)
				curs = 1;
			else if (strcmp(argv[i],"blit") == 0)
				curs = 2;
		} else if ( (strcmp(argv[i], "-active") == 0 || strcmp(argv[i], "-inactive") == 0) && i + 1 < argc) {
#ifdef COLOR
			if(argv[i][1] == 'a')
				activestr = argv[++i];
			else
				inactivestr = argv[++i];
#else
			fprintf(stderr,"9wm: border set but COLOR not defined\n");
			i++;
#endif
		} else if (argv[i][0] == '-')
			usage();
		else
			break;
	for (; i < argc; i++)
		if (strcmp(argv[i], "exit") == 0)
			do_exit++;
		else if (strcmp(argv[i], "restart") == 0)
			do_restart++;
		else
			usage();

	if (do_exit && do_restart)
		usage();

	shell = (char *) getenv("SHELL");
	if (shell == NULL)
		shell = DEFSHELL;

	dpy = XOpenDisplay("");
	if (dpy == 0)
		fatal("can't open display");

	initting = 1;
	XSetErrorHandler(handler);
	if (signal(SIGTERM, sighandler) == SIG_IGN)
		signal(SIGTERM, SIG_IGN);
	if (signal(SIGINT, sighandler) == SIG_IGN)
		signal(SIGINT, SIG_IGN);
	if (signal(SIGHUP, sighandler) == SIG_IGN)
		signal(SIGHUP, SIG_IGN);
	{
		struct sigaction act = {0};

		act.sa_handler = sigchld;
		sigaction(SIGCHLD, &act, NULL);
	}

	exit_9wm = XInternAtom(dpy, "9WM_EXIT", False);
	restart_9wm = XInternAtom(dpy, "9WM_RESTART", False);

	curtime = -1;		/* don't care */
	if (do_exit) {
		sendcmessage(DefaultRootWindow(dpy), exit_9wm, 0L, 1);
		XSync(dpy, False);
		exit(0);
	}
	if (do_restart) {
		sendcmessage(DefaultRootWindow(dpy), restart_9wm, 0L, 1);
		XSync(dpy, False);
		exit(0);
	}

	wm_state = XInternAtom(dpy, "WM_STATE", False);
	wm_change_state = XInternAtom(dpy, "WM_CHANGE_STATE", False);
	wm_protocols = XInternAtom(dpy, "WM_PROTOCOLS", False);
	wm_delete = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
	wm_take_focus = XInternAtom(dpy, "WM_TAKE_FOCUS", False);
	wm_colormaps = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
	wm_moveresize = XInternAtom(dpy, "_NET_WM_MOVERESIZE", False);
	active_window = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
	net_wm_state = XInternAtom(dpy, "_NET_WM_STATE",False);
	net_wm_state_fullscreen = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False);
	utf8_string = XInternAtom(dpy, "UTF8_STRING", False);
	_9wm_running = XInternAtom(dpy, "_9WM_RUNNING", False);
	_9wm_hold_mode = XInternAtom(dpy, "_9WM_HOLD_MODE", False);

	if (fname != 0)
		if ((font = XLoadQueryFont(dpy, fname)) == 0)
			fprintf(stderr, "9wm: warning: can't load font %s\n", fname);

	if (font == 0) {
		i = 0;
		for (;;) {
			fname = fontlist[i++];
			if (fname == 0) {
				fprintf(stderr, "9wm: warning: can't find a font\n");
				break;
			}
			font = XLoadQueryFont(dpy, fname);
			if (font != 0)
				break;
		}
	}
	if (border) {
		_border--;
		_inset--;
	}
#ifdef	SHAPE
	shape = XShapeQueryExtension(dpy, &shape_event, &dummy);
#endif

	num_screens = ScreenCount(dpy);
	screens = (ScreenInfo *) malloc(sizeof(ScreenInfo) * num_screens);

	for (i = 0; i < num_screens; i++)
		initscreen(&screens[i], i);

	/*
	 * set selection so that 9term knows we're running 
	 */
	curtime = CurrentTime;
	XSetSelectionOwner(dpy, _9wm_running, screens[0].menuwin, timestamp());

	XSync(dpy, False);
	initting = 0;

	nofocus();

	for (i = 0; i < num_screens; i++)
		scanwins(&screens[i]);

	mainloop(shape_event);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rsi, 0x8e9e(%rip)      # 0xb958
movq $0x0, 0x8e9b(%rip) # 0xb960
movq %rdi, (%rsp)
movl $0x1, %ebp
cmpl $0x2, %edi
jl 0x2c52
movq $0x0, 0x8(%rsp)
leaq 0x4664(%rip), %r12      # 0x714b
leaq 0x46c8(%rip), %r14      # 0x71b6
leaq 0x46c7(%rip), %r13      # 0x71bc
movslq %ebp, %rax
movq (%r15,%rax,8), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2280
testl %eax, %eax
je 0x2c34
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2280
testl %eax, %eax
jne 0x2b34
leal 0x1(%rbp), %eax
cmpl (%rsp), %eax
jge 0x2b34
movslq %eax, %rcx
movq (%r15,%rcx,8), %rcx
movq %rcx, 0x8(%rsp)
jmp 0x2b59
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2280
testl %eax, %eax
jne 0x2b60
leal 0x1(%rbp), %eax
cmpl (%rsp), %eax
jge 0x2b60
movslq %eax, %rcx
movq (%r15,%rcx,8), %rcx
movq %rcx, 0x8e17(%rip)      # 0xb970
movl %eax, %ebp
jmp 0x2c39
movq %rbx, %rdi
leaq 0x4658(%rip), %rsi      # 0x71c2
callq 0x2280
testl %eax, %eax
je 0x313f
movq %rbx, %rdi
leaq 0x464a(%rip), %rsi      # 0x71cb
callq 0x2280
testl %eax, %eax
je 0x2c2c
movq %r14, %r12
movq %r13, %r14
movq %rbx, %rdi
leaq 0x4635(%rip), %rsi      # 0x71d3
callq 0x2280
testl %eax, %eax
jne 0x2be5
leal 0x1(%rbp), %r13d
cmpl (%rsp), %r13d
jge 0x2be5
movslq %r13d, %rax
movq (%r15,%rax,8), %rdi
cmpb $0x76, (%rdi)
jne 0x2bc9
cmpb $0x31, 0x1(%rdi)
jne 0x2bc9
cmpb $0x0, 0x2(%rdi)
je 0x2c46
leaq 0x44d1(%rip), %rsi      # 0x70a1
callq 0x2280
testl %eax, %eax
jne 0x2c1a
movl $0x2, 0x8d99(%rip)      # 0xb97c
jmp 0x2c1a
movq %rbx, %rdi
leaq 0x45ec(%rip), %rsi      # 0x71db
callq 0x2280
testl %eax, %eax
je 0x2c0b
movq %rbx, %rdi
leaq 0x45e1(%rip), %rsi      # 0x71e3
callq 0x2280
testl %eax, %eax
jne 0x2c5d
leal 0x1(%rbp), %r13d
cmpl (%rsp), %r13d
jge 0x2c5d
callq 0x2645
movl %r13d, %ebp
movq %r14, %r13
movq %r12, %r14
leaq 0x4521(%rip), %r12      # 0x714b
jmp 0x2c39
incl 0x8d46(%rip)            # 0xb978
jmp 0x2c39
callq 0x2688
incl %ebp
cmpl (%rsp), %ebp
jl 0x2af5
jmp 0x2c66
movl $0x1, 0x8d2c(%rip)      # 0xb97c
jmp 0x2c1a
movq $0x0, 0x8(%rsp)
jmp 0x2c66
cmpb $0x2d, (%rbx)
je 0x31a4
xorl %r13d, %r13d
movl $0x0, %r12d
movq (%rsp), %rax
subl %ebp, %eax
movq %rax, (%rsp)
jle 0x2ce9
xorl %r14d, %r14d
movslq %ebp, %rax
leaq (%r15,%rax,8), %rbp
leaq 0x4588(%rip), %rbx      # 0x7214
xorl %r15d, %r15d
xorl %r13d, %r13d
movq (%rbp,%r15,8), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2280
testl %eax, %eax
je 0x2cc2
movq %r12, %rdi
leaq 0x4569(%rip), %rsi      # 0x7219
callq 0x2280
testl %eax, %eax
jne 0x313a
incl %r13d
jmp 0x2cc5
incl %r14d
incq %r15
cmpl %r15d, (%rsp)
jne 0x2c92
testl %r14d, %r14d
setne %al
testl %r13d, %r13d
movq %rax, %r13
setne %r12b
andb %r12b, %al
cmpb $0x1, %al
je 0x319f
leaq 0x4531(%rip), %rdi      # 0x7221
callq 0x2060
testq %rax, %rax
leaq 0x4528(%rip), %rcx      # 0x7227
cmovneq %rax, %rcx
movq %rcx, 0x8c76(%rip)      # 0xb980
leaq 0x44a4(%rip), %rdi      # 0x71b5
callq 0x22b0
movq %rax, 0x8c6b(%rip)      # 0xb988
testq %rax, %rax
jne 0x2d30
leaq 0x4506(%rip), %rdi      # 0x722f
xorl %eax, %eax
callq 0x6bf8
movl $0x1, 0x8c56(%rip)      # 0xb990
leaq 0x3efd(%rip), %rdi      # 0x6c3e
callq 0x2320
leaq 0x7b1(%rip), %rsi       # 0x34fe
movl $0xf, %edi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2d6c
movl $0x1, %esi
movl $0xf, %edi
callq 0x22a0
leaq 0x78b(%rip), %rsi       # 0x34fe
movl $0x2, %edi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2d92
movl $0x1, %esi
movl $0x2, %edi
callq 0x22a0
leaq 0x765(%rip), %rsi       # 0x34fe
movl $0x1, %edi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2db8
movl $0x1, %esi
movl $0x1, %edi
callq 0x22a0
leaq 0x18(%rsp), %rbx
movl $0x90, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21d0
leaq -0x377(%rip), %rax      # 0x2a5c
movq %rax, -0x8(%rbx)
leaq 0x10(%rsp), %rsi
movl $0x11, %edi
xorl %edx, %edx
callq 0x20f0
movq 0x8b99(%rip), %rdi      # 0xb988
leaq 0x444c(%rip), %rsi      # 0x7242
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b94(%rip)      # 0xb998
movq 0x8b7d(%rip), %rdi      # 0xb988
leaq 0x4439(%rip), %rsi      # 0x724b
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b80(%rip)      # 0xb9a0
movl $0xffffffff, 0x8b7e(%rip) # imm = 0xFFFFFFFF
movq 0x8b57(%rip), %rdi      # 0xb988
testb %r13b, %r13b
jne 0x3144
testb %r12b, %r12b
jne 0x3164
leaq 0x4488(%rip), %rsi      # 0x72d2
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b58(%rip)      # 0xb9b0
movq 0x8b29(%rip), %rdi      # 0xb988
leaq 0x43f1(%rip), %rsi      # 0x7257
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b44(%rip)      # 0xb9b8
movq 0x8b0d(%rip), %rdi      # 0xb988
leaq 0x43e5(%rip), %rsi      # 0x7267
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b30(%rip)      # 0xb9c0
movq 0x8af1(%rip), %rdi      # 0xb988
leaq 0x43d6(%rip), %rsi      # 0x7274
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b1c(%rip)      # 0xb9c8
movq 0x8ad5(%rip), %rdi      # 0xb988
leaq 0x43cb(%rip), %rsi      # 0x7285
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8b08(%rip)      # 0xb9d0
movq 0x8ab9(%rip), %rdi      # 0xb988
leaq 0x43bd(%rip), %rsi      # 0x7293
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8af4(%rip)      # 0xb9d8
movq 0x8a9d(%rip), %rdi      # 0xb988
leaq 0x43b5(%rip), %rsi      # 0x72a7
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8ae0(%rip)      # 0xb9e0
movq 0x8a81(%rip), %rdi      # 0xb988
leaq 0x43ac(%rip), %rsi      # 0x72ba
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8acc(%rip)      # 0xb9e8
movq 0x8a65(%rip), %rdi      # 0xb988
leaq 0x43a3(%rip), %rsi      # 0x72cd
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8ab8(%rip)      # 0xb9f0
movq 0x8a49(%rip), %rdi      # 0xb988
leaq 0x4395(%rip), %rsi      # 0x72db
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8aa4(%rip)      # 0xb9f8
movq 0x8a2d(%rip), %rdi      # 0xb988
leaq 0x4392(%rip), %rsi      # 0x72f4
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8a90(%rip)      # 0xba00
movq 0x8a11(%rip), %rdi      # 0xb988
leaq 0x4382(%rip), %rsi      # 0x7300
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8a7c(%rip)      # 0xba08
movq 0x89f5(%rip), %rdi      # 0xb988
leaq 0x4373(%rip), %rsi      # 0x730d
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8a68(%rip)      # 0xba10
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x2fe8
movq 0x89cf(%rip), %rdi      # 0xb988
movq %rbx, %rsi
callq 0x21f0
movq %rax, 0x8998(%rip)      # 0xb960
testq %rax, %rax
jne 0x3021
movq 0x8024(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x433e(%rip), %rsi      # 0x731c
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22c0
cmpq $0x0, 0x8970(%rip)      # 0xb960
jne 0x3021
leaq 0x8347(%rip), %rbx      # 0xb340
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x3130
movq 0x897c(%rip), %rdi      # 0xb988
callq 0x21f0
movq %rax, 0x8948(%rip)      # 0xb960
addq $0x8, %rbx
testq %rax, %rax
je 0x2ff9
cmpl $0x0, 0x8950(%rip)      # 0xb978
je 0x3036
decl 0x8300(%rip)            # 0xb330
decl 0x82fe(%rip)            # 0xb334
movq 0x894b(%rip), %rbx      # 0xb988
movslq 0xe4(%rbx), %r14
movl %r14d, 0x89cd(%rip)     # 0xba18
imulq $0x178, %r14, %rdi      # imm = 0x178
callq 0x2340
movq %rax, 0x89c2(%rip)      # 0xba20
testq %r14, %r14
jle 0x309d
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x89b1(%rip), %rdi      # 0xba20
addq %r14, %rdi
movl %ebx, %esi
callq 0x31a9
incq %rbx
movslq 0x8995(%rip), %rax      # 0xba18
addq $0x178, %r14            # imm = 0x178
cmpq %rax, %rbx
jl 0x3068
movq 0x88f2(%rip), %rbx      # 0xb988
movq 0x8983(%rip), %rax      # 0xba20
xorl %ebp, %ebp
movl %ebp, 0x8903(%rip)      # 0xb9a8
movq 0x895c(%rip), %r14      # 0xba08
movq 0x10(%rax), %r15
callq 0x33a8
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x23f0
movq 0x88bb(%rip), %rdi      # 0xb988
xorl %esi, %esi
callq 0x23b0
movl %ebp, 0x88b6(%rip)      # 0xb990
xorl %eax, %eax
callq 0x576c
cmpl %ebp, 0x8931(%rip)      # 0xba18
jle 0x3115
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x892b(%rip), %rdi      # 0xba20
addq %rbx, %rdi
xorl %eax, %eax
callq 0x477c
incq %r14
movslq 0x890f(%rip), %rax      # 0xba18
addq $0x178, %rbx            # imm = 0x178
cmpq %rax, %r14
jl 0x30ee
xorl %eax, %eax
callq 0x378c
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x26cf
jmp 0x3021
callq 0x26aa
callq 0x2661
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rdi
movq 0x8836(%rip), %rsi      # 0xb998
jmp 0x317e
movq 0xe8(%rdi), %rcx
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x10(%rcx,%rdx), %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x1, %ecx
callq 0x3420
movq 0x87f7(%rip), %rdi      # 0xb988
xorl %esi, %esi
callq 0x23b0
xorl %edi, %edi
callq 0x2530
callq 0x26f1
callq 0x2620