// File: /workspace/github_c_makefile_star2_O3/9wm[P]9wm/manage.c
// Function: manage
int
manage(Client * c, int mapped)
{
	int fixsize, dohide, doreshape, state;
	long msize;
	XClassHint class;
	XWMHints *hints;

	trace("manage", c, 0);
	XSelectInput(dpy, c->window, ColormapChangeMask | EnterWindowMask | PropertyChangeMask | FocusChangeMask);

	/*
	 * Get loads of hints 
	 */

	if (XGetClassHint(dpy, c->window, &class) != 0) {	/* ``Success'' */
		c->instance = class.res_name;
		c->class = class.res_class;
	} else {
		c->instance = 0;
		c->class = 0;
	}
	c->iconname = getprop(c->window, XA_WM_ICON_NAME);
	c->name = getprop(c->window, XA_WM_NAME);
	setlabel(c);

	hints = XGetWMHints(dpy, c->window);
	if (XGetWMNormalHints(dpy, c->window, &c->size, &msize) == 0 || c->size.flags == 0)
		c->size.flags = PSize;	/* not specified - punt */

	getcmaps(c);
	getproto(c);
	gettrans(c);

	/*
	 * Figure out what to do with the window from hints 
	 */

	if (!getwstate(c->window, &state))
		state = hints ? hints->initial_state : NormalState;
	dohide = (state == IconicState);

	fixsize = 0;
	if ((c->size.flags & (USSize | PSize)))
		fixsize = 1;
	if ((c->size.flags & (PMinSize | PMaxSize)) == (PMinSize | PMaxSize) && c->size.min_width == c->size.max_width
	    && c->size.min_height == c->size.max_height)
		fixsize = 1;
	doreshape = !mapped;
	if (fixsize) {
		if (c->size.flags & USPosition)
			doreshape = 0;
		if (dohide && (c->size.flags & PPosition))
			doreshape = 0;
		if (c->trans != None)
			doreshape = 0;
	}
	if (c->size.flags & PBaseSize) {
		c->min_dx = c->size.base_width;
		c->min_dy = c->size.base_height;
	} else if (c->size.flags & PMinSize) {
		c->min_dx = c->size.min_width;
		c->min_dy = c->size.min_height;
	} else
		c->min_dx = c->min_dy = 0;

	if (hints)
		XFree(hints);

	/*
	 * Now do it!!! 
	 */

	if (doreshape) {
		int xmax = DisplayWidth(dpy, c->screen->num);
		int ymax = DisplayHeight(dpy, c->screen->num);
		int x, y;

		getmouse(&x, &y, c->screen);

		c->x = x - (c->dx / 2);
		c->y = y - (c->dy / 2);

		if (c->x + c->dx > xmax) {
			c->x = xmax - c->dx;
		}
		if (c->x < 0) {
			c->x = 0;
		}

		if (c->y + c->dy > ymax) {
			c->y = ymax - c->dy;
		}
		if (c->y < 0) {
			c->y = 0;
		}
	}
	gravitate(c, 0);

	c->parent = XCreateSimpleWindow(dpy, c->screen->root,
					c->x - BORDER, c->y - BORDER,
					c->dx + 2 * (BORDER - 1), c->dy + 2 * (BORDER - 1), 1, c->screen->black, c->screen->white);
	XSelectInput(dpy, c->parent, SubstructureRedirectMask | SubstructureNotifyMask);
	if (mapped)
		c->reparenting = 1;
	if (doreshape && !fixsize)
		XResizeWindow(dpy, c->window, c->dx, c->dy);
	XSetWindowBorderWidth(dpy, c->window, 0);
	XReparentWindow(dpy, c->window, c->parent, BORDER - 1, BORDER - 1);
#ifdef	SHAPE
	if (shape) {
		XShapeSelectInput(dpy, c->window, ShapeNotifyMask);
		ignore_badwindow = 1;	/* magic */
		setshape(c);
		ignore_badwindow = 0;
	}
#endif
	XAddToSaveSet(dpy, c->window);
	if (dohide)
		hide(c);
	else {
		XMapWindow(dpy, c->window);
		XMapWindow(dpy, c->parent);
		if (doreshape)
			active(c);
		else if (c->trans != None && current && current->window == c->trans)
			active(c);
		else
			setactive(c, 0);
		setwstate(c, NormalState);
	}
	if (current && (current != c))
		cmapfocus(current);
	c->init = 1;
	return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %ebp
movq %rdi, %rbx
leaq 0x768e(%rip), %r13      # 0xb988
movq (%r13), %rdi
movq (%rbx), %rsi
movl $0xe00010, %edx         # imm = 0xE00010
callq 0x23c0
movq (%r13), %rdi
movq (%rbx), %rsi
leaq 0x50(%rsp), %r14
movq %r14, %rdx
callq 0x2460
xorl %ecx, %ecx
testl %eax, %eax
sete %cl
movd %ecx, %xmm0
pshufd $0x0, %xmm0, %xmm0      # xmm0 = xmm0[0,0,0,0]
pslld $0x1f, %xmm0
psrad $0x1f, %xmm0
pandn (%r14), %xmm0
movdqu %xmm0, 0xb8(%rbx)
movq (%rbx), %rdi
leaq 0x76b0(%rip), %r15      # 0xba00
movq (%r15), %rdx
leaq 0x20(%rsp), %r8
movl $0x25, %esi
movl $0x64, %ecx
callq 0x4cc0
xorl %r14d, %r14d
movl $0x0, %ecx
testl %eax, %eax
jle 0x4378
movq 0x20(%rsp), %rcx
movq %rcx, 0xd0(%rbx)
movq (%rbx), %rdi
movq (%r15), %rdx
leaq 0x20(%rsp), %r8
movl $0x27, %esi
movl $0x64, %ecx
callq 0x4cc0
testl %eax, %eax
jle 0x43a2
movq 0x20(%rsp), %r14
movq %r14, 0xc8(%rbx)
movq %rbx, %rdi
callq 0x4c31
movq (%r13), %rdi
movq (%rbx), %rsi
callq 0x2550
movq %rax, %r15
movq (%r13), %rdi
movq (%rbx), %rsi
leaq 0x40(%rbx), %r12
leaq 0x48(%rsp), %rcx
movq %r12, %rdx
callq 0x2120
testl %eax, %eax
je 0x43e3
cmpq $0x0, (%r12)
jne 0x43eb
movq $0x8, (%r12)
movq %rbx, %rdi
callq 0x4afb
movq %rbx, %rdi
callq 0x4e48
xorl %r14d, %r14d
leaq 0x20(%rsp), %rdx
movq %r14, (%rdx)
movq (%r13), %rdi
movq (%rbx), %rsi
callq 0x2470
testl %eax, %eax
je 0x441b
movq 0x20(%rsp), %r14
movq %r14, 0x10(%rbx)
movq (%rbx), %rdi
leaq 0x40(%rsp), %rsi
callq 0x4dfc
testl %eax, %eax
je 0x4436
movl 0x40(%rsp), %esi
jmp 0x4446
testq %r15, %r15
je 0x4441
movl 0xc(%r15), %esi
jmp 0x4446
movl $0x1, %esi
movq (%r12), %rax
movl %eax, %ecx
notl %ecx
testb $0x30, %cl
jne 0x4478
movl 0x58(%rbx), %ecx
cmpl 0x60(%rbx), %ecx
jne 0x4478
xorl %r14d, %r14d
testl %ebp, %ebp
sete %bpl
movb %bpl, %r14b
testb $0xa, %al
jne 0x4488
movl 0x64(%rbx), %ecx
cmpl %ecx, 0x5c(%rbx)
je 0x4488
xorl %r12d, %r12d
jmp 0x44b0
xorl %r14d, %r14d
testl %ebp, %ebp
sete %bpl
movb %bpl, %r14b
testb $0xa, %al
je 0x4473
xorl %ecx, %ecx
testb $0x1, %al
cmovnel %ecx, %r14d
testb $0x4, %al
movl $0x0, %edx
cmovel %r14d, %edx
cmpl $0x3, %esi
cmovnel %r14d, %edx
cmpq $0x0, 0x10(%rbx)
cmovnel %ecx, %edx
movb $0x1, %r12b
movl %edx, %r14d
btl $0x8, %eax
movl %esi, 0x3c(%rsp)
jb 0x44cb
testb $0x10, %al
jne 0x44d4
movq $0x0, 0x90(%rbx)
jmp 0x44df
movq 0x80(%rbx), %rax
jmp 0x44d8
movq 0x58(%rbx), %rax
movq %rax, 0x90(%rbx)
testq %r15, %r15
je 0x44ec
movq %r15, %rdi
callq 0x2170
testl %r14d, %r14d
je 0x45b1
movl %r12d, 0x38(%rsp)
movb %bpl, 0x1f(%rsp)
movq (%r13), %rax
movq 0xe8(%rax), %rax
movq 0xf8(%rbx), %rdx
movslq (%rdx), %rcx
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %ebp
movl 0x1c(%rax,%rcx), %r13d
leaq 0x20(%rsp), %r15
leaq 0x44(%rsp), %r12
movq %r15, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x697b
movl (%r15), %esi
movl 0x30(%rbx), %edi
movl 0x34(%rbx), %eax
movl %edi, %ecx
shrl $0x1f, %ecx
addl %edi, %ecx
sarl %ecx
subl %ecx, %esi
movl %esi, 0x28(%rbx)
movl (%r12), %ecx
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
subl %edx, %ecx
movl %ecx, 0x2c(%rbx)
leal (%rsi,%rdi), %r8d
movl %ebp, %edx
subl %edi, %edx
cmpl %ebp, %r8d
cmovlel %esi, %edx
jg 0x4575
testl %edx, %edx
jns 0x4582
testl %edx, %edx
movl $0x0, %esi
cmovgl %edx, %esi
movl %esi, 0x28(%rbx)
leal (%rcx,%rax), %esi
movl %r13d, %edx
subl %eax, %edx
cmpl %r13d, %esi
cmovlel %ecx, %edx
jg 0x4596
testl %edx, %edx
jns 0x45a0
xorl %eax, %eax
testl %edx, %edx
cmovgl %edx, %eax
movl %eax, 0x2c(%rbx)
leaq 0x73e1(%rip), %r13      # 0xb988
movb 0x1f(%rsp), %bpl
movl 0x38(%rsp), %r12d
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4962
movq (%r13), %rdi
movq 0xf8(%rbx), %rax
movq 0x8(%rax), %rsi
leaq 0x6d5f(%rip), %r15      # 0xb330
movl (%r15), %r8d
movl 0x28(%rbx), %edx
movl 0x2c(%rbx), %ecx
subl %r8d, %edx
subl %r8d, %ecx
leal -0x2(,%r8,2), %r9d
movl 0x30(%rbx), %r8d
addl %r9d, %r8d
addl 0x34(%rbx), %r9d
movups 0x28(%rax), %xmm0
movups %xmm0, 0x8(%rsp)
movl $0x1, (%rsp)
callq 0x2450
movq %rax, 0x8(%rbx)
movq (%r13), %rdi
movl $0x180000, %edx         # imm = 0x180000
movq %rax, %rsi
callq 0x23c0
testb %bpl, %bpl
jne 0x462c
movl $0x1, 0xa0(%rbx)
testl %r14d, %r14d
sete %al
orb %al, %r12b
jne 0x4649
movq (%r13), %rdi
movq (%rbx), %rsi
movl 0x30(%rbx), %edx
movl 0x34(%rbx), %ecx
callq 0x20c0
movq (%r13), %rdi
movq (%rbx), %rsi
xorl %edx, %edx
callq 0x22e0
movq (%r13), %rdi
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
movl (%r15), %ecx
decl %ecx
movl %ecx, %r8d
callq 0x2050
movq (%r13), %rdi
movq (%rbx), %rsi
callq 0x2440
cmpl $0x3, 0x3c(%rsp)
jne 0x4691
movq %rbx, %rdi
xorl %eax, %eax
callq 0x530b
jmp 0x473f
movq (%r13), %rdi
movq (%rbx), %rsi
callq 0x24d0
movq (%r13), %rdi
movq 0x8(%rbx), %rsi
callq 0x24d0
testl %r14d, %r14d
je 0x46bb
movq %rbx, %rdi
xorl %eax, %eax
callq 0x56cd
jmp 0x46f0
movq 0x10(%rbx), %rax
testq %rax, %rax
setne %dl
leaq 0x7474(%rip), %rcx      # 0xbb40
movq (%rcx), %rcx
testq %rcx, %rcx
setne %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x46e4
cmpq %rax, (%rcx)
je 0x46af
movq %rbx, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x5568
movq $0x1, 0x20(%rsp)
movq $0x0, 0x28(%rsp)
movl $0x1, 0x98(%rbx)
movq (%r13), %rdi
movq (%rbx), %rsi
leaq 0x7296(%rip), %rax      # 0xb9b0
movq (%rax), %rcx
leaq 0x20(%rsp), %rax
movq %rax, (%rsp)
movl $0x2, 0x8(%rsp)
movq %rcx, %rdx
movl $0x20, %r8d
xorl %r9d, %r9d
callq 0x2370
leaq 0x73fa(%rip), %rax      # 0xbb40
movq (%rax), %rdi
testq %rdi, %rdi
sete %al
cmpq %rbx, %rdi
sete %cl
orb %al, %cl
jne 0x475e
callq 0x4a0e
movl $0x1, 0x9c(%rbx)
movl $0x1, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq