// File: /workspace/github_c_makefile_star2_O1/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, 0x8e0e(%rip)      # 0xb948
movq $0x0, 0x8e0b(%rip) # 0xb950
movq %rdi, (%rsp)
movl $0x1, %ebp
cmpl $0x2, %edi
jl 0x2cdb
movq $0x0, 0x8(%rsp)
leaq 0x45e4(%rip), %r12      # 0x714b
leaq 0x4648(%rip), %r14      # 0x71b6
leaq 0x4647(%rip), %r13      # 0x71bc
movslq %ebp, %rax
movq (%r15,%rax,8), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2270
testl %eax, %eax
je 0x2cbd
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2270
testl %eax, %eax
jne 0x2bb4
leal 0x1(%rbp), %eax
cmpl (%rsp), %eax
jge 0x2bb4
movslq %eax, %rcx
movq (%r15,%rcx,8), %rcx
movq %rcx, 0x8(%rsp)
jmp 0x2bd9
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2270
testl %eax, %eax
jne 0x2be0
leal 0x1(%rbp), %eax
cmpl (%rsp), %eax
jge 0x2be0
movslq %eax, %rcx
movq (%r15,%rcx,8), %rcx
movq %rcx, 0x8d87(%rip)      # 0xb960
movl %eax, %ebp
jmp 0x2cc2
movq %rbx, %rdi
leaq 0x45d8(%rip), %rsi      # 0x71c2
callq 0x2270
testl %eax, %eax
je 0x31ce
movq %rbx, %rdi
leaq 0x45ca(%rip), %rsi      # 0x71cb
callq 0x2270
testl %eax, %eax
je 0x2cb5
movq %r14, %r12
movq %r13, %r14
movq %rbx, %rdi
leaq 0x45b5(%rip), %rsi      # 0x71d3
callq 0x2270
testl %eax, %eax
jne 0x2c6e
leal 0x1(%rbp), %r13d
cmpl (%rsp), %r13d
jge 0x2c6e
movslq %r13d, %rax
movq (%r15,%rax,8), %rbx
movq %rbx, %rdi
leaq 0x4599(%rip), %rsi      # 0x71db
callq 0x2270
testl %eax, %eax
je 0x2ccf
movq %rbx, %rdi
leaq 0x4448(%rip), %rsi      # 0x70a1
callq 0x2270
testl %eax, %eax
jne 0x2ca3
movl $0x2, 0x8d00(%rip)      # 0xb96c
jmp 0x2ca3
movq %rbx, %rdi
leaq 0x4566(%rip), %rsi      # 0x71de
callq 0x2270
testl %eax, %eax
je 0x2c94
movq %rbx, %rdi
leaq 0x455b(%rip), %rsi      # 0x71e6
callq 0x2270
testl %eax, %eax
jne 0x2ce6
leal 0x1(%rbp), %r13d
cmpl (%rsp), %r13d
jge 0x2ce6
callq 0x2635
movl %r13d, %ebp
movq %r14, %r13
movq %r12, %r14
leaq 0x4498(%rip), %r12      # 0x714b
jmp 0x2cc2
incl 0x8cad(%rip)            # 0xb968
jmp 0x2cc2
callq 0x2678
incl %ebp
cmpl (%rsp), %ebp
jl 0x2b75
jmp 0x2cef
movl $0x1, 0x8c93(%rip)      # 0xb96c
jmp 0x2ca3
movq $0x0, 0x8(%rsp)
jmp 0x2cef
cmpb $0x2d, (%rbx)
je 0x3233
xorl %r13d, %r13d
movl $0x0, %r12d
movq (%rsp), %rax
subl %ebp, %eax
movq %rax, (%rsp)
jle 0x2d65
xorl %r14d, %r14d
movslq %ebp, %rax
leaq (%r15,%rax,8), %rbp
leaq 0x4502(%rip), %rbx      # 0x7217
xorl %r15d, %r15d
xorl %r13d, %r13d
movq (%rbp,%r15,8), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2270
testl %eax, %eax
je 0x2d4b
movq %r12, %rdi
leaq 0x44e3(%rip), %rsi      # 0x721c
callq 0x2270
testl %eax, %eax
jne 0x31c9
incl %r13d
jmp 0x2d4e
incl %r14d
incq %r15
cmpl %r15d, (%rsp)
jne 0x2d1b
testl %r14d, %r14d
setne %r12b
testl %r13d, %r13d
setne %r13b
movl %r12d, %eax
andb %r13b, %al
cmpb $0x1, %al
je 0x31d3
leaq 0x44aa(%rip), %rdi      # 0x7224
callq 0x2060
testq %rax, %rax
leaq 0x44a1(%rip), %rcx      # 0x722a
cmovneq %rax, %rcx
movq %rcx, 0x8bdc(%rip)      # 0xb970
leaq 0x441a(%rip), %rdi      # 0x71b5
callq 0x22a0
movq %rax, 0x8bd1(%rip)      # 0xb978
testq %rax, %rax
jne 0x2dba
leaq 0x447f(%rip), %rdi      # 0x7232
xorl %eax, %eax
callq 0x6ca0
movl $0x1, 0x8bbc(%rip)      # 0xb980
leaq 0x3f1b(%rip), %rdi      # 0x6ce6
callq 0x2310
leaq 0x7c9(%rip), %rsi       # 0x35a0
movl $0xf, %edi
callq 0x2290
cmpq $0x1, %rax
jne 0x2df6
movl $0x1, %esi
movl $0xf, %edi
callq 0x2290
leaq 0x7a3(%rip), %rsi       # 0x35a0
movl $0x2, %edi
callq 0x2290
cmpq $0x1, %rax
jne 0x2e1c
movl $0x1, %esi
movl $0x2, %edi
callq 0x2290
leaq 0x77d(%rip), %rsi       # 0x35a0
movl $0x1, %edi
callq 0x2290
cmpq $0x1, %rax
jne 0x2e42
movl $0x1, %esi
movl $0x1, %edi
callq 0x2290
leaq 0x10(%rsp), %rbx
movl $0x98, %edx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x21d0
leaq -0x381(%rip), %rax      # 0x2adc
movq %rax, (%rbx)
movl $0x11, %edi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x20f0
movq 0x8b02(%rip), %rdi      # 0xb978
leaq 0x43c8(%rip), %rsi      # 0x7245
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8afd(%rip)      # 0xb988
movq 0x8ae6(%rip), %rdi      # 0xb978
leaq 0x43b5(%rip), %rsi      # 0x724e
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8ae9(%rip)      # 0xb990
movl $0xffffffff, 0x8ae7(%rip) # imm = 0xFFFFFFFF
movq 0x8ac0(%rip), %rdi      # 0xb978
testb %r12b, %r12b
jne 0x31d8
testb %r13b, %r13b
movq 0x8(%rsp), %rbx
jne 0x31f8
leaq 0x43ff(%rip), %rsi      # 0x72d5
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8abc(%rip)      # 0xb9a0
movq 0x8a8d(%rip), %rdi      # 0xb978
leaq 0x4368(%rip), %rsi      # 0x725a
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8aa8(%rip)      # 0xb9a8
movq 0x8a71(%rip), %rdi      # 0xb978
leaq 0x435c(%rip), %rsi      # 0x726a
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a94(%rip)      # 0xb9b0
movq 0x8a55(%rip), %rdi      # 0xb978
leaq 0x434d(%rip), %rsi      # 0x7277
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a80(%rip)      # 0xb9b8
movq 0x8a39(%rip), %rdi      # 0xb978
leaq 0x4342(%rip), %rsi      # 0x7288
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a6c(%rip)      # 0xb9c0
movq 0x8a1d(%rip), %rdi      # 0xb978
leaq 0x4334(%rip), %rsi      # 0x7296
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a58(%rip)      # 0xb9c8
movq 0x8a01(%rip), %rdi      # 0xb978
leaq 0x432c(%rip), %rsi      # 0x72aa
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a44(%rip)      # 0xb9d0
movq 0x89e5(%rip), %rdi      # 0xb978
leaq 0x4323(%rip), %rsi      # 0x72bd
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a30(%rip)      # 0xb9d8
movq 0x89c9(%rip), %rdi      # 0xb978
leaq 0x431a(%rip), %rsi      # 0x72d0
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a1c(%rip)      # 0xb9e0
movq 0x89ad(%rip), %rdi      # 0xb978
leaq 0x430c(%rip), %rsi      # 0x72de
xorl %edx, %edx
callq 0x2350
movq %rax, 0x8a08(%rip)      # 0xb9e8
movq 0x8991(%rip), %rdi      # 0xb978
leaq 0x4309(%rip), %rsi      # 0x72f7
xorl %edx, %edx
callq 0x2350
movq %rax, 0x89f4(%rip)      # 0xb9f0
movq 0x8975(%rip), %rdi      # 0xb978
leaq 0x42f9(%rip), %rsi      # 0x7303
xorl %edx, %edx
callq 0x2350
movq %rax, 0x89e0(%rip)      # 0xb9f8
movq 0x8959(%rip), %rdi      # 0xb978
leaq 0x42ea(%rip), %rsi      # 0x7310
xorl %edx, %edx
callq 0x2350
movq %rax, 0x89cc(%rip)      # 0xba00
testq %rbx, %rbx
je 0x3058
movq 0x8938(%rip), %rdi      # 0xb978
movq %rbx, %rsi
callq 0x21f0
movq %rax, 0x8901(%rip)      # 0xb950
testq %rax, %rax
je 0x319f
cmpq $0x0, 0x88f0(%rip)      # 0xb950
jne 0x3091
leaq 0x82c7(%rip), %rbx      # 0xb330
movq (%rbx), %rsi
testq %rsi, %rsi
je 0x31bf
movq 0x88fc(%rip), %rdi      # 0xb978
callq 0x21f0
movq %rax, 0x88c8(%rip)      # 0xb950
addq $0x8, %rbx
testq %rax, %rax
je 0x3069
cmpl $0x0, 0x88d0(%rip)      # 0xb968
je 0x30a6
decl 0x8280(%rip)            # 0xb320
decl 0x827e(%rip)            # 0xb324
movq 0x88cb(%rip), %rax      # 0xb978
movslq 0xe4(%rax), %rbx
movl %ebx, 0x894e(%rip)      # 0xba08
imulq $0x178, %rbx, %rdi      # imm = 0x178
callq 0x2330
movq %rax, 0x8943(%rip)      # 0xba10
testq %rbx, %rbx
jle 0x30fe
xorl %r14d, %r14d
xorl %ebx, %ebx
movq 0x8932(%rip), %rdi      # 0xba10
addq %r14, %rdi
movl %ebx, %esi
callq 0x3238
incq %rbx
movslq 0x8916(%rip), %rax      # 0xba08
addq $0x178, %r14            # imm = 0x178
cmpq %rax, %rbx
jl 0x30d7
xorl %ebp, %ebp
movl %ebp, 0x8892(%rip)      # 0xb998
movq 0x886b(%rip), %rbx      # 0xb978
movq 0x88e4(%rip), %r14      # 0xb9f8
movq 0x88f5(%rip), %rax      # 0xba10
movq 0x10(%rax), %r15
callq 0x3433
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %rax, %rcx
callq 0x23e0
movq 0x883c(%rip), %rdi      # 0xb978
xorl %esi, %esi
callq 0x23a0
movl %ebp, 0x8837(%rip)      # 0xb980
xorl %eax, %eax
callq 0x5785
cmpl %ebp, 0x88b2(%rip)      # 0xba08
jle 0x3184
xorl %ebx, %ebx
xorl %r14d, %r14d
movq 0x88ac(%rip), %rdi      # 0xba10
addq %rbx, %rdi
xorl %eax, %eax
callq 0x47a8
incq %r14
movslq 0x8890(%rip), %rax      # 0xba08
addq $0x178, %rbx            # imm = 0x178
cmpq %rax, %r14
jl 0x315d
xorl %eax, %eax
callq 0x3810
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7e52(%rip), %rax      # 0xaff8
movq (%rax), %rdi
leaq 0x416f(%rip), %rsi      # 0x731f
movq %rbx, %rdx
xorl %eax, %eax
callq 0x22b0
jmp 0x3058
callq 0x26bf
jmp 0x3091
callq 0x269a
callq 0x2651
callq 0x26e1
movq 0xe8(%rdi), %rax
movslq 0xe0(%rdi), %rcx
shlq $0x7, %rcx
movq 0x10(%rax,%rcx), %rdi
movq 0x8792(%rip), %rsi      # 0xb988
jmp 0x3212
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 0x34af
movq 0x8753(%rip), %rdi      # 0xb978
xorl %esi, %esi
callq 0x23a0
xorl %edi, %edi
callq 0x2520
callq 0x2610