// File: /workspace/github_c_makefile_star2_O3/seanpringle[P]xoat/xoat.c
// Function: main
int main(int argc, char *argv[])
{
	int i; XEvent ev; Atom msg = None;

	if (!(display = XOpenDisplay(0))) return 1;

	self   = argv[0];
	root   = DefaultRootWindow(display);
	xerror = XSetErrorHandler(oops);
	menu   = &spot_menu;

	for (i = 0; i < ATOMS; i++) atoms[i] = XInternAtom(display, atom_names[i], False);

	// check for restart/exit
	if (argc > 1)
	{
		Window cli = XCreateSimpleWindow(display, root, 0, 0, 1, 1, 0, None, None);
		     if (!strcmp(argv[1], "restart")) msg = atoms[XOAT_RESTART];
		else if (!strcmp(argv[1], "exit"))    msg = atoms[XOAT_EXIT];
		else errx(EXIT_FAILURE, "huh? %s", argv[1]);
		window_send_clientmessage(root, cli, msg, 0, SubstructureNotifyMask | SubstructureRedirectMask);
		exit(EXIT_SUCCESS);
	}

	configure();
	setup();

	// main event loop
	for (;;)
	{
		STACK_FREE(&windows);
		XNextEvent(display, &ev);
		if (handlers[ev.type])
			handlers[ev.type](&ev);
	}
	return EXIT_SUCCESS;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xe0, %rsp
movq %rsi, %rbx
movl %edi, %ebp
xorl %edi, %edi
callq 0x3210
movq %rax, 0x50e6(%rip)      # 0xebb0
testq %rax, %rax
je 0x9bbb
movq (%rbx), %rcx
movq %rcx, 0x5773(%rip)      # 0xf250
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movq 0x10(%rcx,%rax), %rax
movq %rax, 0x56ad(%rip)      # 0xf1a8
leaq -0xc8(%rip), %rdi       # 0x9a3a
callq 0x35f0
movq %rax, 0x5752(%rip)      # 0xf260
leaq 0x5753(%rip), %rax      # 0xf268
movq %rax, 0x5724(%rip)      # 0xf240
xorl %r14d, %r14d
leaq 0x485a(%rip), %r15      # 0xe380
leaq 0x5173(%rip), %r12      # 0xeca0
movq 0x507c(%rip), %rdi      # 0xebb0
movq (%r14,%r15), %rsi
xorl %edx, %edx
callq 0x3540
movq %rax, (%r14,%r12)
addq $0x8, %r14
cmpq $0xf8, %r14
jne 0x9b2d
cmpl $0x2, %ebp
jge 0x9bd0
callq 0x887a
callq 0x8eaf
leaq 0x20(%rsp), %rbx
leaq 0x4c15(%rip), %r14      # 0xe780
leaq 0x522e(%rip), %r15      # 0xeda0
movzwl 0x5227(%rip), %eax      # 0xeda0
testw %ax, %ax
je 0x9b97
decl %eax
movw %ax, 0x5219(%rip)       # 0xeda0
movswq %ax, %rax
movq 0x8(%r15,%rax,8), %rdi
callq 0x6901
jmp 0x9b72
movq 0x5012(%rip), %rdi      # 0xebb0
movq %rbx, %rsi
callq 0x3310
movslq 0x20(%rsp), %rax
movq (%r14,%rax,8), %rax
testq %rax, %rax
je 0x9b72
movq %rbx, %rdi
callq *%rax
jmp 0x9b72
movl $0x1, %eax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x4fd9(%rip), %rdi      # 0xebb0
movq 0x55ca(%rip), %rsi      # 0xf1a8
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsp)
movl $0x0, (%rsp)
xorl %edx, %edx
xorl %ecx, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
callq 0x31e0
movq %rax, %r14
movq 0x8(%rbx), %rbx
leaq 0xf4c(%rip), %rsi       # 0xab5c
movq %rbx, %rdi
callq 0x3470
testl %eax, %eax
jne 0x9c25
leaq 0x508d(%rip), %rax      # 0xecb0
jmp 0x9c3f
leaq 0xf38(%rip), %rsi       # 0xab64
movq %rbx, %rdi
callq 0x3470
testl %eax, %eax
jne 0x9c60
leaq 0x5069(%rip), %rax      # 0xeca8
movq (%rax), %rdx
movq 0x555f(%rip), %rdi      # 0xf1a8
movl $0x180000, %r8d         # imm = 0x180000
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x5fca
xorl %edi, %edi
callq 0x3100
leaq 0xf02(%rip), %rsi       # 0xab69
movl $0x1, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x35a0