// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
leaq 0x7d62(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movl $0xe00010, %edx         # imm = 0xE00010
callq 0x23b0
leaq 0x7d47(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq -0x38(%rbp), %rdx
callq 0x2450
cmpl $0x0, %eax
je 0x4c69
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xb8(%rax)
movq -0x30(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc0(%rax)
jmp 0x4c87
movq -0x8(%rbp), %rax
movq $0x0, 0xb8(%rax)
movq -0x8(%rbp), %rax
movq $0x0, 0xc0(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0x25, %esi
callq 0x5be0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xd0(%rax)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
movl $0x27, %esi
callq 0x5be0
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0xc8(%rax)
movq -0x8(%rbp), %rdi
callq 0x5a00
leaq 0x7ca3(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
callq 0x2530
movq %rax, -0x40(%rbp)
leaq 0x7c89(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rdx
addq $0x40, %rdx
leaq -0x28(%rbp), %rcx
callq 0x2130
cmpl $0x0, %eax
je 0x4d1a
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x4d26
movq -0x8(%rbp), %rax
movq $0x8, 0x40(%rax)
movq -0x8(%rbp), %rdi
callq 0x5850
movq -0x8(%rbp), %rdi
callq 0x5e00
movq -0x8(%rbp), %rdi
callq 0x53f0
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x5d80
cmpl $0x0, %eax
jne 0x4d79
cmpq $0x0, -0x40(%rbp)
je 0x4d69
movq -0x40(%rbp), %rax
movl 0xc(%rax), %eax
movl %eax, -0x54(%rbp)
jmp 0x4d73
movl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x4d73
movl -0x54(%rbp), %eax
movl %eax, -0x1c(%rbp)
cmpl $0x3, -0x1c(%rbp)
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x14(%rbp)
movl $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0xa, %rax
cmpq $0x0, %rax
je 0x4da8
movl $0x1, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0x30, %rax
cmpq $0x30, %rax
jne 0x4de1
movq -0x8(%rbp), %rax
movl 0x58(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x60(%rcx), %eax
jne 0x4de1
movq -0x8(%rbp), %rax
movl 0x5c(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x64(%rcx), %eax
jne 0x4de1
movl $0x1, -0x10(%rbp)
cmpl $0x0, -0xc(%rbp)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x10(%rbp)
je 0x4e44
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0x1, %rax
cmpq $0x0, %rax
je 0x4e11
movl $0x0, -0x18(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x4e30
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0x4, %rax
cmpq $0x0, %rax
je 0x4e30
movl $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x4e42
movl $0x0, -0x18(%rbp)
jmp 0x4e44
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0x100, %rax            # imm = 0x100
cmpq $0x0, %rax
je 0x4e82
movq -0x8(%rbp), %rax
movl 0x80(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x8(%rbp), %rax
movl 0x84(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x94(%rax)
jmp 0x4ed6
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
andq $0x10, %rax
cmpq $0x0, %rax
je 0x4eb8
movq -0x8(%rbp), %rax
movl 0x58(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x90(%rax)
movq -0x8(%rbp), %rax
movl 0x5c(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x94(%rax)
jmp 0x4ed4
movq -0x8(%rbp), %rax
movl $0x0, 0x94(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0x90(%rax)
jmp 0x4ed6
cmpq $0x0, -0x40(%rbp)
je 0x4ee6
movq -0x40(%rbp), %rdi
callq 0x2180
cmpl $0x0, -0x18(%rbp)
je 0x500c
leaq 0x7a81(%rip), %rax      # 0xc978
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0xf8(%rcx), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x18(%rax), %eax
movl %eax, -0x44(%rbp)
leaq 0x7a55(%rip), %rax      # 0xc978
movq (%rax), %rax
movq 0xe8(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0xf8(%rcx), %rcx
movslq (%rcx), %rcx
shlq $0x7, %rcx
addq %rcx, %rax
movl 0x1c(%rax), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq 0xf8(%rax), %rdx
leaq -0x4c(%rbp), %rdi
leaq -0x50(%rbp), %rsi
movb $0x0, %al
callq 0x8940
movl -0x4c(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x30(%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x50(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x34(%rax), %eax
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x8(%rbp), %rax
movl 0x28(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x30(%rcx), %eax
cmpl -0x44(%rbp), %eax
jle 0x4fbc
movl -0x44(%rbp), %ecx
movq -0x8(%rbp), %rax
subl 0x30(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x28(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x28(%rax)
jge 0x4fd1
movq -0x8(%rbp), %rax
movl $0x0, 0x28(%rax)
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %eax
movq -0x8(%rbp), %rcx
addl 0x34(%rcx), %eax
cmpl -0x48(%rbp), %eax
jle 0x4ff5
movl -0x48(%rbp), %ecx
movq -0x8(%rbp), %rax
subl 0x34(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x2c(%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x2c(%rax)
jge 0x500a
movq -0x8(%rbp), %rax
movl $0x0, 0x2c(%rax)
jmp 0x500c
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x5520
leaq 0x795a(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0xf8(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x28(%rax), %edx
leaq 0x72e2(%rip), %rax      # 0xc320
subl (%rax), %edx
movq -0x8(%rbp), %rax
movl 0x2c(%rax), %ecx
leaq 0x72d2(%rip), %rax      # 0xc320
subl (%rax), %ecx
movq -0x8(%rbp), %rax
movl 0x30(%rax), %r8d
leaq 0x72c1(%rip), %rax      # 0xc320
movl (%rax), %eax
subl $0x1, %eax
shll %eax
addl %eax, %r8d
movq -0x8(%rbp), %rax
movl 0x34(%rax), %r9d
leaq 0x72a8(%rip), %rax      # 0xc320
movl (%rax), %eax
subl $0x1, %eax
shll %eax
addl %eax, %r9d
movq -0x8(%rbp), %rax
movq 0xf8(%rax), %rax
movq 0x28(%rax), %r10
movq -0x8(%rbp), %rax
movq 0xf8(%rax), %rax
movq 0x30(%rax), %rax
movl $0x1, (%rsp)
movq %r10, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x2440
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x8(%rax)
leaq 0x78b0(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
movl $0x180000, %edx         # imm = 0x180000
callq 0x23b0
cmpl $0x0, -0xc(%rbp)
je 0x50f1
movq -0x8(%rbp), %rax
movl $0x1, 0xa0(%rax)
cmpl $0x0, -0x18(%rbp)
je 0x5121
cmpl $0x0, -0x10(%rbp)
jne 0x5121
leaq 0x7874(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movl 0x30(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x34(%rax), %ecx
callq 0x20d0
leaq 0x7850(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
xorl %edx, %edx
callq 0x22d0
leaq 0x7838(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x71c7(%rip), %rax      # 0xc320
movl (%rax), %ecx
subl $0x1, %ecx
leaq 0x71bb(%rip), %rax      # 0xc320
movl (%rax), %r8d
subl $0x1, %r8d
callq 0x2050
leaq 0x7800(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
callq 0x2430
cmpl $0x0, -0x14(%rbp)
je 0x519d
movq -0x8(%rbp), %rdi
movb $0x0, %al
callq 0x6500
jmp 0x5236
leaq 0x77d4(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rsi
callq 0x24c0
leaq 0x77be(%rip), %rax      # 0xc978
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x24c0
cmpl $0x0, -0x18(%rbp)
je 0x51dd
movq -0x8(%rbp), %rdi
movb $0x0, %al
callq 0x6b40
jmp 0x5228
movq -0x8(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x5219
leaq 0x7941(%rip), %rax      # 0xcb30
cmpq $0x0, (%rax)
je 0x5219
leaq 0x7934(%rip), %rax      # 0xcb30
movq (%rax), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0x5219
movq -0x8(%rbp), %rdi
movb $0x0, %al
callq 0x6b40
jmp 0x5226
movq -0x8(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x6900
jmp 0x5228
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x5d00
leaq 0x78f3(%rip), %rax      # 0xcb30
cmpq $0x0, (%rax)
je 0x5262
leaq 0x78e6(%rip), %rax      # 0xcb30
movq (%rax), %rax
cmpq -0x8(%rbp), %rax
je 0x5262
leaq 0x78d6(%rip), %rax      # 0xcb30
movq (%rax), %rdi
callq 0x56b0
movq -0x8(%rbp), %rax
movl $0x1, 0x9c(%rax)
movl $0x1, %eax
addq $0x70, %rsp
popq %rbp
retq
nopl (%rax,%rax)