// File: /workspace/github_c_makefile_star2_O1/seanpringle[P]xoat/./client.c
// Function: window_build_client
Client* window_build_client(Window win)
{
	int i, j; XClassHint chint; XWMHints *hints; Monitor *m;
	if (win == None) return NULL;

	Client *c = calloc(1, sizeof(Client));
	c->window = win;

	if (XGetWindowAttributes(display, c->window, &c->attr))
	{
		c->visible = c->attr.map_state == IsViewable ? 1:0;
		if (!GETPROP_ATOM(win, atoms[_NET_WM_WINDOW_TYPE], &c->type, 1)) c->type = 0;

		c->manage = !c->attr.override_redirect
			&& c->type != atoms[_NET_WM_WINDOW_TYPE_DESKTOP]
			&& c->type != atoms[_NET_WM_WINDOW_TYPE_NOTIFICATION]
			&& c->type != atoms[_NET_WM_WINDOW_TYPE_DOCK]
			&& c->type != atoms[_NET_WM_WINDOW_TYPE_SPLASH]
			? 1:0;

		// detect our own title bars
		if (settings.title)
			for_monitors(i, m) for_spots(j)
				if (m->bars[j] && m->bars[j]->window == c->window)
					{ c->ours = 1; c->bar = 1; c->manage = 0; break; }

		// detect our own menus
		if (menu && menu->mb && menu->mb->window == c->window)
			{ c->ours = 1; c->menu = 1; c->manage = 0; }

		if (c->manage)
		{
			XGetTransientForHint(display, c->window, &c->transient);
			if (!GETPROP_WIND(win, atoms[WM_CLIENT_LEADER], &c->leader, 1)) c->leader = None;
			c->spot = SPOT1; m = &monitors[0];

			for_monitors(i, m)
				if (INTERSECT(m->x, m->y, m->w, m->h, c->attr.x + c->attr.width/2, c->attr.y+c->attr.height/2, 1, 1))
					{ c->monitor = i; break; }

			int intersect_1 = INTERSECT(c->attr.x, c->attr.y, c->attr.width, c->attr.height,
				m->spots[SPOT1].x + m->spots[SPOT1].w/2, m->spots[SPOT1].y + m->spots[SPOT1].h/2, 1, 1);

			int intersect_2 = INTERSECT(c->attr.x, c->attr.y, c->attr.width, c->attr.height,
				m->spots[SPOT2].x + m->spots[SPOT2].w/2, m->spots[SPOT2].y + m->spots[SPOT2].h/2, 1, 1);

			int intersect_3 = INTERSECT(c->attr.x, c->attr.y, c->attr.width, c->attr.height,
				m->spots[SPOT3].x + m->spots[SPOT3].w/2, m->spots[SPOT3].y + m->spots[SPOT3].h/2, 1, 1);

			     if (intersect_3) c->spot = SPOT3;
			else if (intersect_2) c->spot = SPOT2;
			else if (intersect_1) c->spot = SPOT1;

			if (c->visible)
			{
				if (!GETPROP_ATOM(c->window, atoms[_NET_WM_STATE], c->states, ATOMLIST))
					memset(c->states, 0, sizeof(Atom) * ATOMLIST);

				c->urgent = client_has_state(c, atoms[_NET_WM_STATE_DEMANDS_ATTENTION]);
				c->full   = client_has_state(c, atoms[_NET_WM_STATE_FULLSCREEN]);
				c->maxv   = client_has_state(c, atoms[_NET_WM_STATE_MAXIMIZE_VERT]);
				c->maxh   = client_has_state(c, atoms[_NET_WM_STATE_MAXIMIZE_HORZ]);
				c->above  = client_has_state(c, atoms[_NET_WM_STATE_ABOVE]);

				GETPROP_LONG(win, atoms[XOAT_MAXIMIZE], &c->max, 1);

				// proper spot detection based on toggled atoms.
				// XOAT_MAXIMIZE may apply to spot1 windows. Detect...
				if (c->max && intersect_1)
				{
					c->spot = SPOT1;
				}
				else
				// _NET_WM_STATE_MAXIMIZE_VERT may apply to spot2 windows. Detect...
				if (c->maxv && c->type != atoms[_NET_WM_WINDOW_TYPE_DIALOG]
					&& !intersect_1 && intersect_2)
				{
					c->spot = SPOT2;
				}
				else
				// _NET_WM_STATE_MAXIMIZE_HORZ may apply to spot3 windows with c->max. Detect...
				if (c->maxh && c->type != atoms[_NET_WM_WINDOW_TYPE_DIALOG]
					&& !intersect_1 && !intersect_2 && intersect_3)
				{
					c->spot = SPOT3;
				}
				if ((hints = XGetWMHints(display, c->window)))
				{
					c->input  = hints->flags & InputHint && hints->input ? 1:0;
					c->urgent = c->urgent || hints->flags & XUrgencyHint ? 1:0;
					XFree(hints);
				}
				if (XGetClassHint(display, c->window, &chint))
				{
					c->class = strdup(chint.res_class);
					XFree(chint.res_class); XFree(chint.res_name);
				}
			}
		}
		return c;
	}
	free(c);
	return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
testq %rdi, %rdi
je 0x6201
movq %rdi, %r15
movl $0x1, %edi
movl $0x130, %esi            # imm = 0x130
callq 0x3500
movq %rax, %rbx
movq %r15, (%rax)
movq 0x8a32(%rip), %rdi      # 0xebb0
leaq 0x8(%rax), %r12
movq %r15, %rsi
movq %r12, %rdx
callq 0x35c0
testl %eax, %eax
je 0x61f9
xorl %eax, %eax
cmpl $0x2, 0x64(%rbx)
sete %al
movw %ax, 0x102(%rbx)
movq 0x8b68(%rip), %rsi      # 0xed10
leaq 0xa0(%rbx), %r14
leaq 0x8ffa(%rip), %rdx      # 0xf1b0
leaq 0x8ffb(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movq %r14, %r8
movl $0x8, %r9d
callq 0x5d7b
testl %eax, %eax
je 0x61e5
cmpq $0x4, 0x8fd6(%rip)      # 0xf1b0
jne 0x61e5
cmpl $0x0, 0x8fd5(%rip)      # 0xf1b8
jne 0x61ec
movq $0x0, (%r14)
cmpl $0x0, 0x80(%rbx)
je 0x6215
xorl %eax, %eax
jmp 0x6241
movq %rbx, %rdi
callq 0x3220
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rcx
xorl %eax, %eax
cmpq 0x8af7(%rip), %rcx      # 0xed18
je 0x6241
cmpq 0x8b06(%rip), %rcx      # 0xed30
je 0x6241
cmpq 0x8aed(%rip), %rcx      # 0xed20
je 0x6241
xorl %eax, %eax
cmpq 0x8aea(%rip), %rcx      # 0xed28
setne %al
movw %ax, 0x104(%rbx)
cmpq $0x0, 0x8f98(%rip)      # 0xf1e8
je 0x62ad
movslq 0x8517(%rip), %rax      # 0xe770
testq %rax, %rax
jle 0x62ad
leaq 0x898b(%rip), %rcx      # 0xebf0
xorl %edx, %edx
movw $0x1, %si
xorl %edi, %edi
movq (%rcx,%rdi,8), %r8
testq %r8, %r8
je 0x627f
movq 0x8(%r8), %r8
cmpq (%rbx), %r8
je 0x628a
incq %rdi
cmpq $0x3, %rdi
jne 0x626d
jmp 0x62a1
movw %si, 0x10c(%rbx)
movw %si, 0x112(%rbx)
movw $0x0, 0x104(%rbx)
incq %rdx
addq $0x48, %rcx
cmpq %rax, %rdx
jne 0x626b
movq 0x8f8c(%rip), %rax      # 0xf240
testq %rax, %rax
je 0x62e9
movq 0x648(%rax), %rax
testq %rax, %rax
je 0x62e9
movq 0x8(%rax), %rax
cmpq (%rbx), %rax
jne 0x62e9
movw $0x1, %ax
movw %ax, 0x10c(%rbx)
movw %ax, 0x114(%rbx)
movw $0x0, 0x104(%rbx)
cmpw $0x0, 0x104(%rbx)
je 0x6203
movq 0x88b2(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
leaq 0x90(%rbx), %rdx
callq 0x3620
movq 0x8a6c(%rip), %rsi      # 0xed80
leaq 0x98(%rbx), %r13
leaq 0x8e8e(%rip), %rdx      # 0xf1b0
leaq 0x8e8f(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movq %r13, %r8
movl $0x8, %r9d
callq 0x5d7b
testl %eax, %eax
je 0x6351
cmpq $0x21, 0x8e6a(%rip)     # 0xf1b0
jne 0x6351
cmpl $0x0, 0x8e69(%rip)      # 0xf1b8
jne 0x6359
movq $0x0, (%r13)
movq $0x1, 0x118(%rbx)
movslq 0x8405(%rip), %rcx      # 0xe770
testq %rcx, %rcx
jle 0x6420
movl 0x8(%rbx), %eax
movl 0x10(%rbx), %edx
movl %edx, %esi
shrl $0x1f, %esi
addl %edx, %esi
sarl %esi
leal (%rsi,%rax), %edx
addl %eax, %esi
incl %esi
leal -0x1(%rcx), %eax
leaq (%rax,%rax,8), %rdi
leaq 0x8828(%rip), %rax      # 0xebc0
leaq (%rax,%rdi,8), %rdi
xorl %r8d, %r8d
movswl (%rax), %r9d
cmpl %r9d, %edx
jne 0x63af
cmpw $0x1, 0x4(%rax)
je 0x63ca
movswl 0x4(%rax), %r10d
addl %r9d, %r10d
cmpl %edx, %r10d
cmovgl %esi, %r10d
cmpl %r9d, %edx
cmovgl %edx, %r9d
cmpl %r9d, %r10d
jle 0x640f
movswl 0x2(%rax), %r9d
movl 0x14(%rbx), %r11d
movl %r11d, %r10d
shrl $0x1f, %r10d
addl %r11d, %r10d
sarl %r10d
addl 0xc(%rbx), %r10d
cmpl %r9d, %r10d
jne 0x63f0
cmpw $0x1, 0x6(%rax)
je 0x6429
movswl 0x6(%rax), %r11d
addl %r9d, %r11d
leal 0x1(%r10), %ebp
cmpl %r10d, %r11d
cmovlel %r11d, %ebp
cmpl %r9d, %r10d
cmovgl %r10d, %r9d
cmpl %r9d, %ebp
jg 0x6429
incq %r8
addq $0x48, %rax
cmpq %r8, %rcx
jne 0x639f
movq %rdi, %rax
jmp 0x6431
leaq 0x8799(%rip), %rax      # 0xebc0
jmp 0x6431
movw %r8w, 0x100(%rbx)
movl (%r12), %ecx
movswl 0x10(%rax), %esi
movzwl 0x14(%rax), %edx
movl %edx, %edi
shrl $0xf, %edi
addl %edx, %edi
movswl %di, %edx
sarl %edx
addl %esi, %edx
cmpl %edx, %ecx
jne 0x6455
cmpl $0x1, 0x10(%rbx)
je 0x646b
movl 0x10(%rbx), %esi
addl %ecx, %esi
leal 0x1(%rdx), %edi
cmpl %edx, %esi
cmovlel %esi, %edi
cmpl %edx, %ecx
cmovgl %ecx, %edx
cmpl %edx, %edi
jle 0x64b2
movl 0xc(%rbx), %edx
movswl 0x12(%rax), %edi
movzwl 0x16(%rax), %esi
movl %esi, %r8d
shrl $0xf, %r8d
addl %esi, %r8d
movswl %r8w, %esi
sarl %esi
addl %edi, %esi
cmpl %esi, %edx
jne 0x6495
movb $0x1, %bpl
cmpl $0x1, 0x14(%rbx)
je 0x64b4
movl 0x14(%rbx), %edi
addl %edx, %edi
leal 0x1(%rsi), %r8d
cmpl %esi, %edi
cmovlel %edi, %r8d
cmpl %esi, %edx
cmovgl %edx, %esi
cmpl %esi, %r8d
setg %bpl
jmp 0x64b4
xorl %ebp, %ebp
movswl 0x18(%rax), %esi
movzwl 0x1c(%rax), %edx
movl %edx, %edi
shrl $0xf, %edi
addl %edx, %edi
movswl %di, %edx
sarl %edx
addl %esi, %edx
cmpl %edx, %ecx
jne 0x64d4
cmpl $0x1, 0x10(%rbx)
je 0x64ea
movl 0x10(%rbx), %esi
addl %ecx, %esi
leal 0x1(%rdx), %edi
cmpl %edx, %esi
cmovlel %esi, %edi
cmpl %edx, %ecx
cmovgl %ecx, %edx
cmpl %edx, %edi
jle 0x6531
movl 0xc(%rbx), %edx
movswl 0x1a(%rax), %edi
movzwl 0x1e(%rax), %esi
movl %esi, %r8d
shrl $0xf, %r8d
addl %esi, %r8d
movswl %r8w, %esi
sarl %esi
addl %edi, %esi
cmpl %esi, %edx
jne 0x6514
movb $0x1, %r13b
cmpl $0x1, 0x14(%rbx)
je 0x6534
movl 0x14(%rbx), %edi
addl %edx, %edi
leal 0x1(%rsi), %r8d
cmpl %esi, %edi
cmovlel %edi, %r8d
cmpl %esi, %edx
cmovgl %edx, %esi
cmpl %esi, %r8d
setg %r13b
jmp 0x6534
xorl %r13d, %r13d
movq %r14, (%rsp)
movswl 0x20(%rax), %esi
movzwl 0x24(%rax), %edx
movl %edx, %edi
shrl $0xf, %edi
addl %edx, %edi
movswl %di, %edx
sarl %edx
addl %esi, %edx
cmpl %edx, %ecx
jne 0x6558
cmpl $0x1, 0x10(%rbx)
je 0x656e
movl 0x10(%rbx), %esi
addl %ecx, %esi
leal 0x1(%rdx), %edi
cmpl %edx, %esi
cmovlel %esi, %edi
cmpl %edx, %ecx
cmovgl %ecx, %edx
cmpl %edx, %edi
jle 0x65ae
movl 0xc(%rbx), %ecx
movswl 0x22(%rax), %edx
movzwl 0x26(%rax), %eax
movl %eax, %esi
shrl $0xf, %esi
addl %eax, %esi
movswl %si, %eax
sarl %eax
addl %edx, %eax
cmpl %eax, %ecx
jne 0x6594
movb $0x1, %r14b
cmpl $0x1, 0x14(%rbx)
je 0x65b1
movl 0x14(%rbx), %edx
addl %ecx, %edx
leal 0x1(%rax), %esi
cmpl %eax, %edx
cmovlel %edx, %esi
cmpl %eax, %ecx
cmovgl %ecx, %eax
cmpl %eax, %esi
setg %r14b
jmp 0x65b1
xorl %r14d, %r14d
movl %r14d, %eax
orb %r13b, %al
orb %bpl, %al
testb $0x1, %al
je 0x65d8
movzbl %r13b, %eax
incq %rax
testb %r14b, %r14b
movl $0x3, %ecx
cmoveq %rax, %rcx
movq %rcx, 0x118(%rbx)
cmpw $0x0, 0x102(%rbx)
je 0x6203
movq (%rbx), %rdi
movq 0x8750(%rip), %rsi      # 0xed40
leaq 0xa8(%rbx), %r12
leaq 0x8bb2(%rip), %rdx      # 0xf1b0
leaq 0x8bb3(%rip), %rcx      # 0xf1b8
movq %r12, %r8
movl $0x50, %r9d
callq 0x5d7b
testl %eax, %eax
je 0x662a
cmpq $0x4, 0x8b91(%rip)      # 0xf1b0
jne 0x662a
cmpl $0x0, 0x8b90(%rip)      # 0xf1b8
jne 0x664a
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%r12)
movups %xmm0, 0x30(%r12)
movups %xmm0, 0x20(%r12)
movups %xmm0, 0x10(%r12)
movups %xmm0, (%r12)
movl $0x15, %eax
movq 0x870a(%rip), %rcx      # 0xed60
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x666d
cmpq %rcx, %rdx
je 0x6671
incq %rax
cmpq $0x1f, %rax
jne 0x6656
xorl %eax, %eax
jmp 0x6675
movw $0x1, %ax
movw %ax, 0x108(%rbx)
movl $0x15, %eax
movq 0x86c0(%rip), %rcx      # 0xed48
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x669f
cmpq %rcx, %rdx
je 0x66a3
incq %rax
cmpq $0x1f, %rax
jne 0x6688
xorl %eax, %eax
jmp 0x66a7
movw $0x1, %ax
movw %ax, 0x10a(%rbx)
movl $0x15, %eax
movq 0x8696(%rip), %rcx      # 0xed50
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x66d1
cmpq %rcx, %rdx
je 0x66d5
incq %rax
cmpq $0x1f, %rax
jne 0x66ba
xorl %eax, %eax
jmp 0x66d9
movw $0x1, %ax
movw %ax, 0x10e(%rbx)
movl $0x15, %eax
movq 0x866c(%rip), %rcx      # 0xed58
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x6703
cmpq %rcx, %rdx
je 0x6707
incq %rax
cmpq $0x1f, %rax
jne 0x66ec
xorl %eax, %eax
jmp 0x670b
movw $0x1, %ax
movw %ax, 0x110(%rbx)
movl $0x15, %eax
movq 0x864a(%rip), %rcx      # 0xed68
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x6735
cmpq %rcx, %rdx
je 0x6739
incq %rax
cmpq $0x1f, %rax
jne 0x671e
xorl %eax, %eax
jmp 0x673d
movw $0x1, %ax
movw %ax, 0x116(%rbx)
movq 0x856d(%rip), %rsi      # 0xecb8
movq %rbx, %r8
addq $0x120, %r8             # imm = 0x120
leaq 0x8a54(%rip), %rdx      # 0xf1b0
leaq 0x8a55(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movl $0x8, %r9d
callq 0x5d7b
cmpq $0x0, 0x120(%rbx)
setne %cl
movl $0x1, %eax
testb %bpl, %cl
jne 0x67e5
cmpw $0x0, 0x10e(%rbx)
je 0x67b2
movq (%rsp), %rax
movq (%rax), %rax
cmpq 0x859a(%rip), %rax      # 0xed38
setne %al
movl %ebp, %ecx
xorb $0x1, %cl
andb %al, %cl
movl $0x2, %eax
testb %r13b, %cl
jne 0x67e5
cmpw $0x0, 0x110(%rbx)
je 0x67ec
movq (%rsp), %rax
movq (%rax), %rax
cmpq 0x856e(%rip), %rax      # 0xed38
sete %al
orb %r13b, %bpl
orb %al, %bpl
xorb $0x1, %bpl
andb %bpl, %r14b
movl $0x3, %eax
cmpb $0x1, %r14b
jne 0x67ec
movq %rax, 0x118(%rbx)
movq 0x83bd(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
callq 0x3370
testq %rax, %rax
je 0x683d
movq (%rax), %rcx
xorl %edx, %edx
testb $0x1, %cl
je 0x6811
cmpl $0x0, 0x8(%rax)
setne %dl
movw %dx, 0x106(%rbx)
shrl $0x8, %ecx
andl $0x1, %ecx
cmpw $0x0, 0x108(%rbx)
movl $0x1, %edx
cmovel %ecx, %edx
movw %dx, 0x108(%rbx)
movq %rax, %rdi
callq 0x3050
movq 0x836c(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
leaq 0x8(%rsp), %rdx
callq 0x32b0
testl %eax, %eax
je 0x6203
movq 0x10(%rsp), %r14
movq %r14, %rdi
callq 0x3430
movq %rax, 0x128(%rbx)
movq %r14, %rdi
callq 0x3050
movq 0x8(%rsp), %rdi
callq 0x3050
jmp 0x6203