// File: /workspace/github_c_makefile_star2_O3/mati75[P]evilwm/client_new.c
// Function: client_manage_new
void client_manage_new(Window w, struct screen *s) {
	struct client *c;
	char *name;
	XClassHint *class;
	unsigned window_type;

	LOG_ENTER("client_manage_new(window=%lx)", (unsigned long)w);

	XGrabServer(display.dpy);

	// First a bit of interaction with the error handler due to X's
	// tendency to batch event notifications.  We set a global variable to
	// the id of the window we're initialising then do simple X call on
	// that window.  If an error is raised by this (and nothing else should
	// do so as we've grabbed the server), the error handler resets the
	// variable indicating the window has already disappeared, so we stop
	// trying to manage it.

	initialising = w;
	XFetchName(display.dpy, w, &name);
	XSync(display.dpy, False);

	// If 'initialising' is now set to None, that means doing the
	// XFetchName raised BadWindow - the window has been removed before
	// we got a chance to grab the server. */

	if (initialising == None) {
		LOG_DEBUG("XError occurred for initialising window - aborting...\n");
		XUngrabServer(display.dpy);
		LOG_LEAVE();
		return;
	}
	initialising = None;
	LOG_DEBUG("screen=%d\n", s->screen);
	LOG_DEBUG("name=%s\n", name ? name : "Untitled");
	if (name)
		XFree(name);

	window_type = ewmh_get_net_wm_window_type(w);
	// Don't manage DESKTOP type windows
	if (window_type & EWMH_WINDOW_TYPE_DESKTOP) {
		XMapWindow(display.dpy, w);
		XUngrabServer(display.dpy);
		return;
	}

	// If allocation fails, don't crash the window manager.  Just don't
	// manage the window.
	c = malloc(sizeof(struct client));
	if (!c) {
		LOG_ERROR("out of memory allocating new client\n");
		XMapWindow(display.dpy, w);
		XUngrabServer(display.dpy);
		LOG_LEAVE();
		return;
	}
	clients_tab_order = list_prepend(clients_tab_order, c);
	clients_mapping_order = list_append(clients_mapping_order, c);
	clients_stacking_order = list_append(clients_stacking_order, c);

	c->screen = s;
	c->window = w;
	c->ignore_unmap = 0;
	c->remove = 0;

	// Ungrab the X server as soon as possible. Now that the client is
	// malloc()ed and attached to the list, it is safe for any subsequent
	// X calls to raise an X error and thus flag it for removal.

	XUngrabServer(display.dpy);

	update_window_type_flags(c, window_type);
	init_geometry(c);

#ifdef DEBUG
	{
		int i = 0;
		for (struct list *iter = clients_tab_order; iter; iter = iter->next)
			i++;
		LOG_DEBUG("new window %dx%d+%d+%d, wincount=%d\n", c->width, c->height, c->x, c->y, i);
	}
#endif

	XSelectInput(display.dpy, c->window, ColormapChangeMask | EnterWindowMask | PropertyChangeMask);

	reparent(c);

#ifdef SHAPE
	if (display.have_shape) {
		XShapeSelectInput(display.dpy, c->window, ShapeNotifyMask);
		set_shape(c);
	}
#endif

	// Read name/class information for client and check against list built
	// with -app options.
	class = XAllocClassHint();
	if (class) {
		XGetClassHint(display.dpy, w, class);
		for (struct list *iter = applications; iter; iter = iter->next) {
			struct application *a = iter->data;
			// Does resource name and class match?
			if ((!a->res_name || (class->res_name && !strcmp(class->res_name, a->res_name)))
					&& (!a->res_class || (class->res_class && !strcmp(class->res_class, a->res_class)))) {

				// Override width or height?
				if (a->geometry_mask & WidthValue)
					c->width = a->width * c->width_inc;
				if (a->geometry_mask & HeightValue)
					c->height = a->height * c->height_inc;

				// Override X or Y?
				if (a->geometry_mask & XValue) {
					if (a->geometry_mask & XNegative)
						c->x = a->x + DisplayWidth(display.dpy, s->screen)-c->width-c->border;
					else
						c->x = a->x + c->border;
				}
				if (a->geometry_mask & YValue) {
					if (a->geometry_mask & YNegative)
						c->y = a->y + DisplayHeight(display.dpy, s->screen)-c->height-c->border;
					else
						c->y = a->y + c->border;
				}

				// XXX better way of updating window geometry?
				client_moveresizeraise(c);

				// Force treating this app as a dock?
				if (a->is_dock)
					c->is_dock = 1;

				// Force app to specific vdesk?
				if (a->vdesk != VDESK_NONE)
					c->vdesk = a->vdesk;
			}
		}
		XFree(class->res_name);
		XFree(class->res_class);
		XFree(class);
	}

	// Set EWMH property on client advertising WM features
	ewmh_set_allowed_actions(c);

	// Update EWMH client list hints for screen
	ewmh_set_net_client_list(c->screen);
	ewmh_set_net_client_list_stacking(c->screen);

	// Only map the window frame (and thus the window) if it's supposed
	// to be visible on this virtual desktop.  Otherwise, set it to
	// IconicState (hidden).
	if (is_fixed(c) || c->vdesk == s->vdesk) {
		client_show(c);
		client_raise(c);
		// Don't focus windows that aren't on the same display as the
		// pointer.
		if (get_pointer_root_xy(c->window, NULL, NULL) &&
		    !(window_type & (EWMH_WINDOW_TYPE_DOCK|EWMH_WINDOW_TYPE_NOTIFICATION))) {
			select_client(c);
#ifdef WARP_POINTER
			setmouse(c->window, c->width + c->border - 1,
				 c->height + c->border - 1);
#endif
			discard_enter_events(c);
		}
	} else {
		set_wm_state(c, IconicState);
	}

	// Ensure whichever vdesk it ended up on is reflected in the EWMH hints
	ewmh_set_net_wm_desktop(c);

	LOG_LEAVE();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r15
leaq 0x8c5c(%rip), %rbx      # 0xf728
movq (%rbx), %rdi
callq 0x4110
leaq 0x8e85(%rip), %r14      # 0xf960
movq %r15, (%r14)
movq (%rbx), %rdi
leaq 0x20(%rsp), %rdx
movq %r15, %rsi
callq 0x45b0
movq (%rbx), %rdi
xorl %esi, %esi
callq 0x4500
cmpq $0x0, (%r14)
je 0x6ce7
movq $0x0, (%r14)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6b18
callq 0x4050
movq %r15, %rdi
callq 0x8132
movl %eax, %r13d
testb $0x1, %r13b
jne 0x6cdc
movl $0x98, %edi
callq 0x41e0
testq %rax, %rax
je 0x70d2
movq %rax, %r14
leaq 0x8bbe(%rip), %r12      # 0xf708
movq (%r12), %rdi
movq %rax, %rsi
callq 0x863c
movq %rax, (%r12)
leaq 0x8baf(%rip), %r12      # 0xf710
movq (%r12), %rdi
movq %r14, %rsi
callq 0x8675
movq %rax, (%r12)
leaq 0x8ba0(%rip), %r12      # 0xf718
movq (%r12), %rdi
movq %r14, %rsi
callq 0x8675
movq %rax, (%r12)
movq 0x10(%rsp), %rax
movq %rax, 0x10(%r14)
movq %r15, (%r14)
xorl %eax, %eax
movl %eax, 0x24(%r14)
movl %eax, 0x68(%r14)
movq (%rbx), %rdi
callq 0x43a0
movq %r14, %rdi
movl %r13d, %esi
callq 0x5343
movq (%r14), %rdi
callq 0x97da
movl %eax, 0x38(%r14)
movq (%r14), %rdi
movq 0x10(%r14), %rax
movl 0x60(%rax), %eax
movl %eax, 0x20(%r14)
movq 0xb8(%rbx), %rsi
movq %rsp, %rcx
movl $0x6, %edx
callq 0x975a
testq %rax, %rax
je 0x6c11
cmpq $0x0, (%rsp)
je 0x6c09
movl (%rax), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x6c05
leaq 0x8cf2(%rip), %rdx      # 0xf8f0
movl 0x2c(%rdx), %edx
cmpl %edx, %ecx
jae 0x6c09
movl %ecx, 0x20(%r14)
movq %rax, %rdi
callq 0x4050
movq (%rbx), %rdi
movq (%r14), %rsi
leaq 0x30(%rsp), %r12
movq %r12, %rdx
callq 0x4630
movl 0x10(%r12), %eax
movl %eax, 0x50(%r14)
movq 0x50(%r12), %rax
movq %rax, 0x18(%r14)
movq $0x0, 0x48(%r14)
movq (%r14), %rdi
movq 0x30(%rbx), %rsi
movq %rsp, %rcx
movl $0x6, %edx
callq 0x975a
testq %rax, %rax
je 0x6c73
cmpq $0x2, (%rsp)
jne 0x6c6b
movl (%rax), %ecx
movl %ecx, 0x40(%r14)
movl 0x8(%rax), %ecx
movl %ecx, 0x48(%r14)
movq %rax, %rdi
callq 0x4050
movq (%r14), %rdi
movq 0x38(%rbx), %rsi
movq %rsp, %rcx
movl $0x6, %edx
callq 0x975a
testq %rax, %rax
je 0x6ca8
cmpq $0x2, (%rsp)
jne 0x6ca0
movl (%rax), %ecx
movl %ecx, 0x44(%r14)
movl 0x8(%rax), %ecx
movl %ecx, 0x4c(%r14)
movq %rax, %rdi
callq 0x4050
cmpl $0x0, 0x48(%r14)
je 0x6cb8
xorl %eax, %eax
cmpl $0x0, 0x4c(%r14)
jne 0x6cbc
movl 0x38(%r14), %eax
movl %eax, 0x3c(%r14)
movq %r14, %rdi
callq 0x5234
movl 0x38(%rsp), %edi
movl 0x6c(%r14), %edx
cmpl %edx, %edi
jge 0x6cf4
movl 0x70(%r14), %esi
movb $0x1, %cl
jmp 0x6d0c
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x4440
movq (%rbx), %rdi
callq 0x43a0
jmp 0x70c0
movl 0x3c(%rsp), %esi
movl 0x70(%r14), %r8d
cmpl %r8d, %esi
jge 0x6d08
movb $0x1, %cl
movl %r8d, %esi
jmp 0x6d0c
xorl %ecx, %ecx
movl %edi, %edx
movl %edx, 0x30(%r14)
movl %esi, 0x34(%r14)
cmpl $0x2, 0x8c(%rsp)
movl %r13d, 0xc(%rsp)
je 0x6d96
andl $0x1, %eax
jne 0x6d96
movq (%rbx), %rax
movq 0xe8(%rax), %rax
movq 0x10(%r14), %rcx
movslq (%rcx), %rdx
shlq $0x7, %rdx
movl 0x18(%rax,%rdx), %ebp
movl 0x1c(%rax,%rdx), %r12d
movq 0x10(%rcx), %rdi
leaq 0x2c(%rsp), %r13
leaq 0x1c(%rsp), %rdx
movq %r13, %rsi
callq 0x9700
movl 0x3c(%r14), %ecx
movl 0x30(%r14), %edx
addl %ecx, %edx
movl %ebp, %eax
subl %edx, %eax
imull (%r13), %eax
cltd
idivl %ebp
movl 0xc(%rsp), %r13d
movl %eax, 0x28(%r14)
addl 0x34(%r14), %ecx
movl %r12d, %eax
subl %ecx, %eax
leaq 0x1c(%rsp), %rcx
imull (%rcx), %eax
cltd
idivl %r12d
movl %eax, 0x2c(%r14)
jmp 0x6da3
movq 0x30(%rsp), %rax
movq %rax, 0x28(%r14)
testb %cl, %cl
je 0x6dab
movq %r14, %rdi
callq 0x567f
movq (%r14), %rdi
movslq 0x3c(%r14), %rsi
callq 0x81c9
cmpl $0x2, 0x8c(%rsp)
jne 0x6dc5
incl 0x24(%r14)
movl 0x50(%r14), %esi
movq 0x28(%r14), %xmm0
movd %esi, %xmm1
pshufd $0x50, %xmm1, %xmm1     # xmm1 = xmm1[0,0,1,1]
paddd %xmm0, %xmm1
movq %xmm1, 0x28(%r14)
negl %esi
movq %r14, %rdi
callq 0x56df
movl 0x3c(%r14), %esi
movq %r14, %rdi
callq 0x56df
movq (%rbx), %rdi
movq (%r14), %rsi
movl $0xc00010, %edx         # imm = 0xC00010
callq 0x44b0
movq 0x10(%r14), %r10
movq 0x40(%r10), %rax
movq %rax, 0x48(%rsp)
movl $0x1, 0x88(%rsp)
movq $0x180014, 0x78(%rsp)   # imm = 0x180014
movq (%rbx), %rdi
movq 0x10(%r10), %rsi
movl 0x3c(%r14), %eax
movl 0x28(%r14), %edx
movl 0x2c(%r14), %ecx
subl %eax, %edx
subl %eax, %ecx
movl 0x30(%r14), %r8d
movl 0x34(%r14), %r9d
movq 0xe8(%rdi), %r11
movslq (%r10), %r10
shlq $0x7, %r10
movl 0x38(%r11,%r10), %r12d
leaq 0x30(%rsp), %rbp
pushq %rbp
pushq $0xa08                  # imm = 0xA08
pushq 0x40(%r11,%r10)
pushq $0x0
pushq %r12
pushq %rax
callq 0x4250
addq $0x30, %rsp
movq %rax, 0x8(%r14)
movq (%rbx), %rdi
movq (%r14), %rsi
callq 0x4350
movq (%rbx), %rdi
movq (%r14), %rsi
xorl %edx, %edx
callq 0x45a0
movq (%rbx), %rdi
movq (%r14), %rsi
movq 0x8(%r14), %rdx
xorl %ecx, %ecx
xorl %r8d, %r8d
callq 0x46d0
movq (%rbx), %rdi
movq (%r14), %rsi
callq 0x4440
movq %r14, %rdi
callq 0x4f9c
cmpl $0x0, 0x178(%rbx)
je 0x6edd
movq (%rbx), %rdi
movq (%r14), %rsi
movl $0x1, %edx
callq 0x4750
movq %r14, %rdi
callq 0x5aea
callq 0x40f0
testq %rax, %rax
je 0x7046
movq %rax, %r12
movq (%rbx), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4370
leaq 0x89dd(%rip), %rax      # 0xf8e0
movq (%rax), %r15
testq %r15, %r15
je 0x7026
movq 0x8(%r15), %r13
movq (%r13), %rsi
testq %rsi, %rsi
je 0x6f36
movq (%r12), %rdi
testq %rdi, %rdi
je 0x701e
callq 0x4540
testl %eax, %eax
jne 0x701e
movq 0x8(%r13), %rsi
testq %rsi, %rsi
je 0x6f5a
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x701e
callq 0x4540
testl %eax, %eax
jne 0x701e
movl 0x10(%r13), %eax
testb $0x4, %al
je 0x6f6f
movl 0x7c(%r14), %ecx
imull 0x1c(%r13), %ecx
movl %ecx, 0x30(%r14)
testb $0x8, %al
je 0x6f83
movl 0x80(%r14), %ecx
imull 0x20(%r13), %ecx
movl %ecx, 0x34(%r14)
testb $0x1, %al
je 0x6fbd
movl 0x14(%r13), %ecx
testb $0x10, %al
jne 0x6f95
addl 0x3c(%r14), %ecx
jmp 0x6fb9
movq (%rbx), %rdx
movq 0xe8(%rdx), %rdx
movq 0x10(%rsp), %rsi
movslq (%rsi), %rsi
shlq $0x7, %rsi
addl 0x18(%rdx,%rsi), %ecx
movl 0x30(%r14), %edx
addl 0x3c(%r14), %edx
subl %edx, %ecx
movl %ecx, 0x28(%r14)
testb $0x2, %al
je 0x6ff7
movl 0x18(%r13), %ecx
testb $0x20, %al
jne 0x6fcf
addl 0x3c(%r14), %ecx
jmp 0x6ff3
movq (%rbx), %rax
movq 0xe8(%rax), %rax
movq 0x10(%rsp), %rdx
movslq (%rdx), %rdx
shlq $0x7, %rdx
addl 0x1c(%rax,%rdx), %ecx
movl 0x34(%r14), %eax
addl 0x3c(%r14), %eax
subl %eax, %ecx
movl %ecx, 0x2c(%r14)
movq %r14, %rdi
callq 0x615d
cmpl $0x0, 0x24(%r13)
je 0x7011
movl $0x1, 0x94(%r14)
movl 0x28(%r13), %eax
cmpl $-0x2, %eax
je 0x701e
movl %eax, 0x20(%r14)
movq (%r15), %r15
jmp 0x6f06
movq (%r12), %rdi
callq 0x4050
movq 0x8(%r12), %rdi
callq 0x4050
movq %r12, %rdi
callq 0x4050
movl 0xc(%rsp), %r13d
movq %r14, %rdi
callq 0x7e83
movq 0x10(%r14), %rdi
callq 0x7d21
movq 0x10(%r14), %rdi
callq 0x7dd2
movl 0x20(%r14), %eax
cmpl $-0x1, %eax
je 0x7073
movq 0x10(%rsp), %rcx
cmpl 0x60(%rcx), %eax
jne 0x70ab
movq %r14, %rdi
callq 0x55bc
movq %r14, %rdi
callq 0x5611
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x9700
testb $0x6, %r13b
jne 0x70b8
testl %eax, %eax
je 0x70b8
movq %r14, %rdi
callq 0x5780
movq %r14, %rdi
callq 0x9911
jmp 0x70b8
movq %r14, %rdi
movl $0x3, %esi
callq 0x557c
movq %r14, %rdi
callq 0x80f7
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x47b0
jmp 0x70c0