// File: /workspace/github_c_makefile_star2_O3/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 0x61fb
movq %rdi, %r15
movl $0x1, %edi
movl $0x130, %esi            # imm = 0x130
callq 0x3500
movq %rax, %rbx
movq %r15, (%rax)
movq 0x8a35(%rip), %rdi      # 0xebb0
leaq 0x8(%rax), %rdx
movq %r15, %rsi
callq 0x35c0
testl %eax, %eax
je 0x61f3
xorl %eax, %eax
cmpl $0x2, 0x64(%rbx)
sete %al
movw %ax, 0x102(%rbx)
movq 0x8b6e(%rip), %rsi      # 0xed10
leaq 0xa0(%rbx), %r14
leaq 0x9000(%rip), %rdx      # 0xf1b0
leaq 0x9001(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movq %r14, %r8
movl $0x8, %r9d
callq 0x5d60
testl %eax, %eax
je 0x61df
cmpq $0x4, 0x8fdc(%rip)      # 0xf1b0
jne 0x61df
cmpl $0x0, 0x8fdb(%rip)      # 0xf1b8
jne 0x61e6
movq $0x0, (%r14)
cmpl $0x0, 0x80(%rbx)
je 0x620f
xorl %eax, %eax
jmp 0x623b
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 0x8afd(%rip), %rcx      # 0xed18
je 0x623b
cmpq 0x8b0c(%rip), %rcx      # 0xed30
je 0x623b
cmpq 0x8af3(%rip), %rcx      # 0xed20
je 0x623b
xorl %eax, %eax
cmpq 0x8af0(%rip), %rcx      # 0xed28
setne %al
movw %ax, 0x104(%rbx)
cmpq $0x0, 0x8f9e(%rip)      # 0xf1e8
je 0x62aa
movslq 0x851d(%rip), %rcx      # 0xe770
testq %rcx, %rcx
jle 0x62aa
leaq 0x8991(%rip), %rdx      # 0xebf0
xorl %esi, %esi
movw $0x1, %di
xorl %r8d, %r8d
movq (%rdx,%r8,8), %r9
testq %r9, %r9
je 0x627a
movq 0x8(%r9), %r9
cmpq (%rbx), %r9
je 0x6285
incq %r8
cmpq $0x3, %r8
jne 0x6268
jmp 0x629e
movw %di, 0x10c(%rbx)
movw %di, 0x112(%rbx)
movw $0x0, 0x104(%rbx)
xorl %eax, %eax
incq %rsi
addq $0x48, %rdx
cmpq %rcx, %rsi
jne 0x6265
movq 0x8f8f(%rip), %rcx      # 0xf240
testq %rcx, %rcx
je 0x62eb
movq 0x648(%rcx), %rcx
testq %rcx, %rcx
je 0x62eb
movq 0x8(%rcx), %rcx
cmpq (%rbx), %rcx
jne 0x62eb
movw $0x1, %ax
movw %ax, 0x10c(%rbx)
movw %ax, 0x114(%rbx)
movw $0x0, 0x104(%rbx)
jmp 0x61fd
testw %ax, %ax
je 0x61fd
movq 0x88b5(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
leaq 0x90(%rbx), %rdx
callq 0x3620
movq 0x8a6f(%rip), %rsi      # 0xed80
leaq 0x98(%rbx), %r12
leaq 0x8e91(%rip), %rdx      # 0xf1b0
leaq 0x8e92(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movq %r12, %r8
movl $0x8, %r9d
callq 0x5d60
testl %eax, %eax
je 0x634e
cmpq $0x21, 0x8e6d(%rip)     # 0xf1b0
jne 0x634e
cmpl $0x0, 0x8e6c(%rip)      # 0xf1b8
jne 0x6356
movq $0x0, (%r12)
movq $0x1, 0x118(%rbx)
movslq 0x8408(%rip), %rdx      # 0xe770
movl 0x8(%rbx), %eax
testq %rdx, %rdx
jle 0x6441
movl 0x10(%rbx), %ecx
movl %ecx, %edi
shrl $0x1f, %edi
addl %ecx, %edi
sarl %edi
leal (%rdi,%rax), %esi
incl %esi
addl %eax, %edi
leal -0x1(%rdx), %ecx
leaq (%rcx,%rcx,8), %r8
leaq 0x882b(%rip), %rcx      # 0xebc0
leaq (%rcx,%r8,8), %r8
xorl %r9d, %r9d
movswl (%rcx), %r10d
cmpl %r10d, %edi
sete %bpl
movzwl 0x4(%rcx), %r11d
cmpw $0x1, %r11w
sete %r12b
testb %r12b, %bpl
jne 0x63d4
movswl %r11w, %r11d
addl %r10d, %r11d
cmpl %edi, %r11d
cmovgl %esi, %r11d
cmpl %r10d, %edi
cmovgl %edi, %r10d
cmpl %r10d, %r11d
jle 0x6422
movswl 0x2(%rcx), %r10d
movl 0x14(%rbx), %ebp
movl %ebp, %r11d
shrl $0x1f, %r11d
addl %ebp, %r11d
sarl %r11d
addl 0xc(%rbx), %r11d
cmpl %r10d, %r11d
sete %r12b
movzwl 0x6(%rcx), %ebp
cmpw $0x1, %bp
sete %r13b
testb %r13b, %r12b
jne 0x6437
movswl %bp, %ebp
addl %r10d, %ebp
leal 0x1(%r11), %r12d
cmpl %r11d, %ebp
cmovlel %ebp, %r12d
cmpl %r10d, %r11d
cmovgl %r11d, %r10d
cmpl %r10d, %r12d
jg 0x6437
incq %r9
addq $0x48, %rcx
cmpq %r9, %rdx
jne 0x639c
movq %r8, %rcx
jmp 0x6448
movw %r9w, 0x100(%rbx)
jmp 0x6448
leaq 0x8778(%rip), %rcx      # 0xebc0
movswl 0x10(%rcx), %edx
movzwl 0x14(%rcx), %esi
movl %esi, %edi
shrl $0xf, %edi
addl %esi, %edi
movswl %di, %edi
sarl %edi
addl %edx, %edi
movl %eax, %r8d
xorl %edi, %r8d
movl 0x10(%rbx), %edx
movl %edx, %r9d
xorl $0x1, %r9d
movl $0x1, %esi
orl %r8d, %r9d
je 0x6492
movl %edx, %esi
addl %eax, %esi
leal 0x1(%rdi), %r8d
cmpl %edi, %esi
cmovlel %esi, %r8d
cmpl %edi, %eax
cmovgl %eax, %edi
cmpl %edi, %r8d
jle 0x64ea
movl %edx, %esi
movl 0xc(%rbx), %edx
movl 0x14(%rbx), %edi
movswl 0x12(%rcx), %r9d
movzwl 0x16(%rcx), %r8d
movl %r8d, %r10d
shrl $0xf, %r10d
addl %r8d, %r10d
movswl %r10w, %r8d
sarl %r8d
addl %r9d, %r8d
movl %edx, %r9d
xorl %r8d, %r9d
movl %edi, %r10d
xorl $0x1, %r10d
movb $0x1, %bpl
orl %r9d, %r10d
je 0x64e6
addl %edx, %edi
leal 0x1(%r8), %r9d
cmpl %r8d, %edi
cmovlel %edi, %r9d
cmpl %r8d, %edx
cmovgl %edx, %r8d
cmpl %r8d, %r9d
setg %bpl
movl %esi, %edx
jmp 0x64ec
xorl %ebp, %ebp
movswl 0x18(%rcx), %esi
movzwl 0x1c(%rcx), %edi
movl %edi, %r8d
shrl $0xf, %r8d
addl %edi, %r8d
movswl %r8w, %edi
sarl %edi
addl %esi, %edi
movl %eax, %r8d
xorl %edi, %r8d
movl %edx, %esi
xorl $0x1, %esi
orl %esi, %r8d
je 0x652f
leal (%rdx,%rax), %r8d
leal 0x1(%rdi), %r9d
cmpl %edi, %r8d
cmovlel %r8d, %r9d
cmpl %edi, %eax
cmovgl %eax, %edi
cmpl %edi, %r9d
jle 0x6587
movl 0xc(%rbx), %edi
movl 0x14(%rbx), %r8d
movswl 0x1a(%rcx), %r10d
movzwl 0x1e(%rcx), %r9d
movl %r9d, %r11d
shrl $0xf, %r11d
addl %r9d, %r11d
movswl %r11w, %r9d
sarl %r9d
addl %r10d, %r9d
movl %edi, %r10d
xorl %r9d, %r10d
movl %r8d, %r11d
xorl $0x1, %r11d
movb $0x1, %r13b
orl %r10d, %r11d
je 0x658a
addl %edi, %r8d
leal 0x1(%r9), %r10d
cmpl %r9d, %r8d
cmovlel %r8d, %r10d
cmpl %r9d, %edi
cmovgl %edi, %r9d
cmpl %r9d, %r10d
setg %r13b
jmp 0x658a
xorl %r13d, %r13d
movswl 0x20(%rcx), %r8d
movzwl 0x24(%rcx), %edi
movl %edi, %r9d
shrl $0xf, %r9d
addl %edi, %r9d
movswl %r9w, %edi
sarl %edi
addl %r8d, %edi
movl %eax, %r8d
xorl %edi, %r8d
orl %esi, %r8d
je 0x65c4
addl %eax, %edx
leal 0x1(%rdi), %esi
cmpl %edi, %edx
cmovlel %edx, %esi
cmpl %edi, %eax
cmovgl %eax, %edi
cmpl %edi, %esi
jle 0x6631
movl 0xc(%rbx), %eax
movl 0x14(%rbx), %edx
movswl 0x22(%rcx), %esi
movzwl 0x26(%rcx), %ecx
movl %ecx, %edi
shrl $0xf, %edi
addl %ecx, %edi
movswl %di, %ecx
sarl %ecx
addl %esi, %ecx
movl %eax, %esi
xorl %ecx, %esi
movl %edx, %edi
xorl $0x1, %edi
orl %esi, %edi
jne 0x65f6
movl $0x3, %ecx
xorl %eax, %eax
jmp 0x6649
addl %eax, %edx
leal 0x1(%rcx), %esi
cmpl %ecx, %edx
cmovlel %edx, %esi
cmpl %ecx, %eax
cmovgl %eax, %ecx
movzbl %r13b, %edx
incq %rdx
cmpl %ecx, %esi
setle %al
setg %sil
movl $0x3, %ecx
cmovleq %rdx, %rcx
movl %r13d, %edx
orb %bpl, %dl
orb %sil, %dl
movb $0x1, %sil
testb $0x1, %dl
jne 0x6649
jmp 0x6652
movl %r13d, %ecx
orb %bpl, %cl
movb $0x1, %al
testb $0x1, %cl
je 0x68f9
movzbl %r13b, %ecx
incq %rcx
movq %rcx, 0x118(%rbx)
movl %eax, %esi
cmpw $0x0, 0x102(%rbx)
je 0x61fd
movb %sil, 0x7(%rsp)
movq (%rbx), %rdi
movq 0x86d1(%rip), %rsi      # 0xed40
leaq 0xa8(%rbx), %r12
leaq 0x8b33(%rip), %rdx      # 0xf1b0
leaq 0x8b34(%rip), %rcx      # 0xf1b8
movq %r12, %r8
movl $0x50, %r9d
callq 0x5d60
testl %eax, %eax
je 0x66a9
cmpq $0x4, 0x8b12(%rip)      # 0xf1b0
jne 0x66a9
cmpl $0x0, 0x8b11(%rip)      # 0xf1b8
jne 0x66c9
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 0x868b(%rip), %rcx      # 0xed60
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x66ec
cmpq %rcx, %rdx
je 0x66f0
incq %rax
cmpq $0x1f, %rax
jne 0x66d5
xorl %eax, %eax
jmp 0x66f4
movw $0x1, %ax
movw %ax, 0x108(%rbx)
movl $0x15, %eax
movq 0x8641(%rip), %rcx      # 0xed48
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x671e
cmpq %rcx, %rdx
je 0x6722
incq %rax
cmpq $0x1f, %rax
jne 0x6707
xorl %eax, %eax
jmp 0x6726
movw $0x1, %ax
movw %ax, 0x10a(%rbx)
movl $0x15, %eax
movq 0x8617(%rip), %rcx      # 0xed50
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x6750
cmpq %rcx, %rdx
je 0x6754
incq %rax
cmpq $0x1f, %rax
jne 0x6739
xorl %eax, %eax
jmp 0x6758
movw $0x1, %ax
movw %ax, 0x10e(%rbx)
movl $0x15, %eax
movq 0x85ed(%rip), %rcx      # 0xed58
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x6782
cmpq %rcx, %rdx
je 0x6786
incq %rax
cmpq $0x1f, %rax
jne 0x676b
xorl %eax, %eax
jmp 0x678a
movw $0x1, %ax
movw %ax, 0x110(%rbx)
movl $0x15, %eax
movq 0x85cb(%rip), %rcx      # 0xed68
movq (%rbx,%rax,8), %rdx
testq %rdx, %rdx
je 0x67b4
cmpq %rcx, %rdx
je 0x67b8
incq %rax
cmpq $0x1f, %rax
jne 0x679d
xorl %eax, %eax
jmp 0x67bc
movw $0x1, %ax
movw %ax, 0x116(%rbx)
movq 0x84ee(%rip), %rsi      # 0xecb8
movq %rbx, %r8
addq $0x120, %r8             # imm = 0x120
leaq 0x89d5(%rip), %rdx      # 0xf1b0
leaq 0x89d6(%rip), %rcx      # 0xf1b8
movq %r15, %rdi
movl $0x8, %r9d
callq 0x5d60
cmpq $0x0, 0x120(%rbx)
setne %cl
movl $0x1, %eax
testb %bpl, %cl
jne 0x685a
cmpw $0x0, 0x10e(%rbx)
je 0x682d
movq (%r14), %rax
cmpq 0x851f(%rip), %rax      # 0xed38
setne %al
movl %ebp, %ecx
xorb $0x1, %cl
andb %al, %cl
movl $0x2, %eax
testb %r13b, %cl
jne 0x685a
cmpw $0x0, 0x110(%rbx)
je 0x6861
movq (%r14), %rax
cmpq 0x84f7(%rip), %rax      # 0xed38
sete %al
orb %r13b, %bpl
movb 0x7(%rsp), %cl
orb %bpl, %cl
orb %al, %cl
movl $0x3, %eax
testb $0x1, %cl
jne 0x6861
movq %rax, 0x118(%rbx)
movq 0x8348(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
callq 0x3370
testq %rax, %rax
je 0x68b2
movq (%rax), %rcx
xorl %edx, %edx
testb $0x1, %cl
je 0x6886
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 0x82f7(%rip), %rdi      # 0xebb0
movq (%rbx), %rsi
leaq 0x8(%rsp), %rdx
callq 0x32b0
testl %eax, %eax
je 0x61fd
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 0x61fd
movb $0x1, %sil
jmp 0x6652