// File: /workspace/github_c_makefile_star2_O1/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, 0x512e(%rip)      # 0xebb0
testq %rax, %rax
je 0x9b73
movq (%rbx), %rcx
movq %rcx, 0x57bb(%rip)      # 0xf250
movq 0xe8(%rax), %rcx
movslq 0xe0(%rax), %rax
shlq $0x7, %rax
movq 0x10(%rcx,%rax), %rax
movq %rax, 0x56f5(%rip)      # 0xf1a8
leaq -0xdf(%rip), %rdi       # 0x99db
callq 0x35f0
movq %rax, 0x579a(%rip)      # 0xf260
leaq 0x579b(%rip), %rax      # 0xf268
movq %rax, 0x576c(%rip)      # 0xf240
xorl %r14d, %r14d
leaq 0x48a2(%rip), %r15      # 0xe380
leaq 0x51bb(%rip), %r12      # 0xeca0
movq 0x50c4(%rip), %rdi      # 0xebb0
movq (%r14,%r15), %rsi
xorl %edx, %edx
callq 0x3540
movq %rax, (%r14,%r12)
addq $0x8, %r14
cmpq $0xf8, %r14
jne 0x9ae5
cmpl $0x2, %ebp
jge 0x9b88
callq 0x87fb
callq 0x8e32
leaq 0x20(%rsp), %rbx
leaq 0x4c5d(%rip), %r14      # 0xe780
leaq 0x5276(%rip), %r15      # 0xeda0
movzwl 0x526f(%rip), %eax      # 0xeda0
testw %ax, %ax
je 0x9b4f
decl %eax
movw %ax, 0x5261(%rip)       # 0xeda0
movswq %ax, %rax
movq 0x8(%r15,%rax,8), %rdi
callq 0x6884
jmp 0x9b2a
movq 0x505a(%rip), %rdi      # 0xebb0
movq %rbx, %rsi
callq 0x3310
movslq 0x20(%rsp), %rax
movq (%r14,%rax,8), %rax
testq %rax, %rax
je 0x9b2a
movq %rbx, %rdi
callq *%rax
jmp 0x9b2a
movl $0x1, %eax
addq $0xe0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x5021(%rip), %rdi      # 0xebb0
movq 0x5612(%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 0xf62(%rip), %rsi       # 0xab2a
movq %rbx, %rdi
callq 0x3470
testl %eax, %eax
jne 0x9bdd
leaq 0x50d5(%rip), %rax      # 0xecb0
jmp 0x9bf7
leaq 0xf4e(%rip), %rsi       # 0xab32
movq %rbx, %rdi
callq 0x3470
testl %eax, %eax
jne 0x9c18
leaq 0x50b1(%rip), %rax      # 0xeca8
movq (%rax), %rdx
movq 0x55a7(%rip), %rdi      # 0xf1a8
movl $0x180000, %r8d         # imm = 0x180000
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x5fe8
xorl %edi, %edi
callq 0x3100
leaq 0xf18(%rip), %rsi       # 0xab37
movl $0x1, %edi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x35a0