// File: /workspace/github_c_makefile_star2_O2/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
movl %edi, %ebp
movq %rsi, (%rsp)
movq %rsi, 0x91ea(%rip)      # 0xb958
andq $0x0, 0x91ea(%rip)      # 0xb960
pushq $0x1
popq %r12
movq $0x0, 0x8(%rsp)
leaq 0x49c1(%rip), %r15      # 0x714b
movslq %r12d, %r13
cmpl %ebp, %r12d
jge 0x2940
movq (%rsp), %rax
movq (%rax,%r13,8), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x2280
testl %eax, %eax
je 0x28f7
movq %rbx, %rdi
leaq 0x49fb(%rip), %rsi      # 0x71b6
callq 0x2280
testl %eax, %eax
jne 0x27df
leal 0x1(%r12), %eax
cmpl %ebp, %eax
jge 0x27df
movslq %eax, %rcx
movq (%rsp), %rdx
movq (%rdx,%rcx,8), %rcx
movq %rcx, 0x8(%rsp)
jmp 0x280d
movq %rbx, %rdi
leaq 0x49d3(%rip), %rsi      # 0x71bc
callq 0x2280
testl %eax, %eax
jne 0x2815
leal 0x1(%r12), %eax
cmpl %ebp, %eax
jge 0x2815
movslq %eax, %rcx
movq (%rsp), %rdx
movq (%rdx,%rcx,8), %rcx
movq %rcx, 0x9163(%rip)      # 0xb970
movl %eax, %r12d
jmp 0x292f
movq %rbx, %rdi
leaq 0x49a3(%rip), %rsi      # 0x71c2
callq 0x2280
testl %eax, %eax
je 0x2df3
movq %rbx, %rdi
leaq 0x4995(%rip), %rsi      # 0x71cb
callq 0x2280
testl %eax, %eax
je 0x28ef
movq %rbx, %rdi
leaq 0x4986(%rip), %rsi      # 0x71d3
callq 0x2280
testl %eax, %eax
jne 0x28a3
leal 0x1(%r12), %r15d
cmpl %ebp, %r15d
jge 0x28a3
movslq %r15d, %rax
movq (%rsp), %rcx
movq (%rcx,%rax,8), %rdi
cmpb $0x76, (%rdi)
jne 0x2880
cmpb $0x31, 0x1(%rdi)
jne 0x2880
cmpb $0x0, 0x2(%rdi)
je 0x291b
leaq 0x481a(%rip), %rsi      # 0x70a1
callq 0x2280
testl %eax, %eax
jne 0x2925
movl $0x2, 0x90de(%rip)      # 0xb97c
jmp 0x2925
movq %rbx, %rdi
leaq 0x492e(%rip), %rsi      # 0x71db
callq 0x2280
testl %eax, %eax
je 0x28c9
movq %rbx, %rdi
leaq 0x4923(%rip), %rsi      # 0x71e3
callq 0x2280
testl %eax, %eax
jne 0x2937
incl %r12d
cmpl %ebp, %r12d
jge 0x2937
movq 0x8720(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x490b(%rip), %rdi      # 0x71ed
pushq $0x26
popq %rsi
pushq $0x1
popq %rdx
callq 0x2540
jmp 0x2928
incl 0x9083(%rip)            # 0xb978
jmp 0x292f
incl 0x906b(%rip)            # 0xb968
movq 0x86f4(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x4844(%rip), %rdi      # 0x7152
pushq $0x63
popq %rsi
pushq $0x1
popq %rdx
callq 0x2540
jmp 0x292f
movl $0x1, 0x9057(%rip)      # 0xb97c
movl %r15d, %r12d
leaq 0x481c(%rip), %r15      # 0x714b
incl %r12d
jmp 0x278a
cmpb $0x2d, (%rbx)
je 0x2dee
movslq %ebp, %r15
xorl %ebp, %ebp
leaq 0x48c8(%rip), %rbx      # 0x7214
xorl %r14d, %r14d
cmpq %r15, %r13
jge 0x298e
movq (%rsp), %rax
movq (%rax,%r13,8), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2280
testl %eax, %eax
je 0x2986
movq %r12, %rdi
leaq 0x48a4(%rip), %rsi      # 0x7219
callq 0x2280
testl %eax, %eax
jne 0x2dee
incl %ebp
jmp 0x2989
incl %r14d
incq %r13
jmp 0x294f
testl %r14d, %r14d
setne %al
testl %ebp, %ebp
setne %cl
andb %al, %cl
cmpb $0x1, %cl
je 0x2dee
leaq 0x4876(%rip), %rdi      # 0x7221
callq 0x2060
testq %rax, %rax
leaq 0x486d(%rip), %rcx      # 0x7227
cmovneq %rax, %rcx
movq %rcx, 0x8fbb(%rip)      # 0xb980
leaq 0x47e9(%rip), %rdi      # 0x71b5
callq 0x22b0
movq %rax, 0x8fb0(%rip)      # 0xb988
testq %rax, %rax
jne 0x29eb
leaq 0x484b(%rip), %rdi      # 0x722f
xorl %eax, %eax
callq 0x6684
movl $0x1, 0x8f9b(%rip)      # 0xb990
leaq 0x3cc6(%rip), %rdi      # 0x66c2
callq 0x2320
leaq 0x7cc(%rip), %rsi       # 0x31d4
pushq $0xf
popq %rdi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2a21
pushq $0xf
popq %rdi
pushq $0x1
popq %rsi
callq 0x22a0
leaq 0x7ac(%rip), %rsi       # 0x31d4
pushq $0x2
popq %rdi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2a41
pushq $0x2
popq %rdi
pushq $0x1
popq %rsi
callq 0x22a0
leaq 0x78c(%rip), %rsi       # 0x31d4
pushq $0x1
popq %rdi
callq 0x22a0
cmpq $0x1, %rax
jne 0x2a61
pushq $0x1
popq %rdi
pushq $0x1
popq %rsi
callq 0x22a0
leaq 0x18(%rsp), %rbx
movl $0x90, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21d0
leaq -0x370(%rip), %rax      # 0x270c
movq %rax, -0x8(%rbx)
pushq $0x11
popq %rdi
leaq 0x10(%rsp), %rsi
xorl %edx, %edx
callq 0x20f0
movq 0x8ef2(%rip), %rdi      # 0xb988
leaq 0x47a5(%rip), %rsi      # 0x7242
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8eed(%rip)      # 0xb998
movq 0x8ed6(%rip), %rdi      # 0xb988
leaq 0x4792(%rip), %rsi      # 0x724b
xorl %edx, %edx
callq 0x2360
orl $-0x1, 0x8ee1(%rip)     # 0xb9a8
movq %rax, 0x8ed2(%rip)      # 0xb9a0
movq 0x8eb3(%rip), %rdi      # 0xb988
testl %r14d, %r14d
jne 0x2e14
testl %ebp, %ebp
jne 0x2e37
leaq 0x47e5(%rip), %rsi      # 0x72d2
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8eb5(%rip)      # 0xb9b0
movq 0x8e86(%rip), %rdi      # 0xb988
leaq 0x474e(%rip), %rsi      # 0x7257
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8ea1(%rip)      # 0xb9b8
movq 0x8e6a(%rip), %rdi      # 0xb988
leaq 0x4742(%rip), %rsi      # 0x7267
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e8d(%rip)      # 0xb9c0
movq 0x8e4e(%rip), %rdi      # 0xb988
leaq 0x4733(%rip), %rsi      # 0x7274
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e79(%rip)      # 0xb9c8
movq 0x8e32(%rip), %rdi      # 0xb988
leaq 0x4728(%rip), %rsi      # 0x7285
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e65(%rip)      # 0xb9d0
movq 0x8e16(%rip), %rdi      # 0xb988
leaq 0x471a(%rip), %rsi      # 0x7293
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e51(%rip)      # 0xb9d8
movq 0x8dfa(%rip), %rdi      # 0xb988
leaq 0x4712(%rip), %rsi      # 0x72a7
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e3d(%rip)      # 0xb9e0
movq 0x8dde(%rip), %rdi      # 0xb988
leaq 0x4709(%rip), %rsi      # 0x72ba
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e29(%rip)      # 0xb9e8
movq 0x8dc2(%rip), %rdi      # 0xb988
leaq 0x4700(%rip), %rsi      # 0x72cd
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e15(%rip)      # 0xb9f0
movq 0x8da6(%rip), %rdi      # 0xb988
leaq 0x46f2(%rip), %rsi      # 0x72db
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8e01(%rip)      # 0xb9f8
movq 0x8d8a(%rip), %rdi      # 0xb988
leaq 0x46ef(%rip), %rsi      # 0x72f4
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8ded(%rip)      # 0xba00
movq 0x8d6e(%rip), %rdi      # 0xb988
leaq 0x46df(%rip), %rsi      # 0x7300
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8dd9(%rip)      # 0xba08
movq 0x8d52(%rip), %rdi      # 0xb988
leaq 0x46d0(%rip), %rsi      # 0x730d
xorl %edx, %edx
callq 0x2360
movq %rax, 0x8dc5(%rip)      # 0xba10
movq 0x8(%rsp), %rbx
testq %rbx, %rbx
je 0x2c8b
movq 0x8d2c(%rip), %rdi      # 0xb988
movq %rbx, %rsi
callq 0x21f0
movq %rax, 0x8cf5(%rip)      # 0xb960
testq %rax, %rax
jne 0x2cc4
movq 0x8381(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x469b(%rip), %rsi      # 0x731c
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22c0
cmpq $0x0, 0x8ccd(%rip)      # 0xb960
jne 0x2cc4
leaq 0x86a4(%rip), %rbx      # 0xb340
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x2dcd
movq 0x8cd9(%rip), %rdi      # 0xb988
callq 0x21f0
movq %rax, 0x8ca5(%rip)      # 0xb960
addq $0x8, %rbx
testq %rax, %rax
je 0x2c9c
cmpl $0x0, 0x8cad(%rip)      # 0xb978
je 0x2cd9
decl 0x865d(%rip)            # 0xb330
decl 0x865b(%rip)            # 0xb334
movq 0x8ca8(%rip), %rax      # 0xb988
movslq 0xe4(%rax), %r15
movl %r15d, 0x8d2a(%rip)     # 0xba18
imulq $0x178, %r15, %rdi      # imm = 0x178
callq 0x2340
movq %rax, 0x8d1f(%rip)      # 0xba20
xorl %r14d, %r14d
xorl %ebx, %ebx
movslq %r15d, %rax
cmpq %rax, %rbx
jge 0x2d32
movq 0x8d0b(%rip), %rdi      # 0xba20
addq %r14, %rdi
movl %ebx, %esi
callq 0x2e70
incq %rbx
movl 0x8cef(%rip), %r15d     # 0xba18
addq $0x178, %r14            # imm = 0x178
jmp 0x2d06
andl $0x0, 0x8c6f(%rip)      # 0xb9a8
movq 0x8c48(%rip), %rbx      # 0xb988
movq 0x8cc1(%rip), %r14      # 0xba08
movq 0x8cd2(%rip), %rax      # 0xba20
movq 0x10(%rax), %r15
callq 0x3073
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x23f0
movq 0x8c19(%rip), %rdi      # 0xb988
xorl %esi, %esi
callq 0x23b0
andl $0x0, 0x8c13(%rip)      # 0xb990
xorl %eax, %eax
callq 0x541d
xorl %ebx, %ebx
xorl %r14d, %r14d
movslq 0x8c88(%rip), %rax      # 0xba18
cmpq %rax, %r14
jge 0x2db2
movq 0x8c84(%rip), %rdi      # 0xba20
addq %rbx, %rdi
xorl %eax, %eax
callq 0x4427
incq %r14
addq $0x178, %rbx            # imm = 0x178
jmp 0x2d89
xorl %eax, %eax
callq 0x3450
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8224(%rip), %rax      # 0xaff8
movq (%rax), %rcx
leaq 0x4560(%rip), %rdi      # 0x733e
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
callq 0x2540
jmp 0x2cc4
callq 0x272b
movq 0x81fe(%rip), %rax      # 0xaff8
movq (%rax), %rdi
movq 0x851c(%rip), %rdx      # 0xb320
leaq 0x4a2f(%rip), %rsi      # 0x783a
xorl %eax, %eax
callq 0x22c0
jmp 0x2e69
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rdi
movq 0x8b66(%rip), %rsi      # 0xb998
pushq $0x1
popq %rcx
jmp 0x2e54
movq 0xe8(%rdi), %rcx
movslq 0xe0(%rdi), %rdx
shlq $0x7, %rdx
movq 0x10(%rcx,%rdx), %rdi
pushq $0x1
popq %rcx
movq %rax, %rsi
xorl %edx, %edx
callq 0x30e5
movq 0x8b26(%rip), %rdi      # 0xb988
xorl %esi, %esi
callq 0x23b0
xorl %edi, %edi
callq 0x2530