// File: /workspace/github_c_makefile_star2_O1/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 0x9b0c(%rip), %rbx      # 0x10738
movq (%rbx), %rdi
callq 0x4110
leaq 0x9d35(%rip), %r14      # 0x10970
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 0x6e55
movq $0x0, (%r14)
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x6c78
callq 0x4050
movq %r15, %rdi
callq 0x828b
movl %eax, %r13d
testb $0x1, %r13b
jne 0x6e4a
movl $0x98, %edi
callq 0x41e0
testq %rax, %rax
je 0x7220
movq %rax, %r14
leaq 0x9a6e(%rip), %r12      # 0x10718
movq (%r12), %rdi
movq %rax, %rsi
callq 0x8789
movq %rax, (%r12)
leaq 0x9a5f(%rip), %r12      # 0x10720
movq (%r12), %rdi
movq %r14, %rsi
callq 0x87cb
movq %rax, (%r12)
leaq 0x9a50(%rip), %r12      # 0x10728
movq (%r12), %rdi
movq %r14, %rsi
callq 0x87cb
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 0x53a4
movq (%r14), %rdi
callq 0x998d
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 0x990d
testq %rax, %rax
je 0x6d71
cmpq $0x0, (%rsp)
je 0x6d69
movl (%rax), %ecx
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
cmpq %rdx, %rcx
je 0x6d65
leaq 0x9ba2(%rip), %rdx      # 0x10900
movl 0x2c(%rdx), %edx
cmpl %edx, %ecx
jae 0x6d69
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 0x990d
testq %rax, %rax
je 0x6dd3
cmpq $0x2, (%rsp)
jne 0x6dcb
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 0x990d
testq %rax, %rax
je 0x6e08
cmpq $0x2, (%rsp)
jne 0x6e00
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 0x6e18
xorl %eax, %eax
cmpl $0x0, 0x4c(%r14)
jne 0x6e1c
movl 0x38(%r14), %eax
movl %eax, 0x3c(%r14)
movq %r14, %rdi
callq 0x526c
movl 0x38(%rsp), %ecx
movl 0x6c(%r14), %esi
cmpl %esi, %ecx
jl 0x6e3e
movl 0x3c(%rsp), %edx
cmpl 0x70(%r14), %edx
jge 0x6e62
movl %esi, 0x30(%r14)
movl 0x70(%r14), %edx
movb $0x1, %cl
jmp 0x6e68
movq (%rbx), %rdi
movq %r15, %rsi
callq 0x4440
movq (%rbx), %rdi
callq 0x43a0
jmp 0x720e
movl %ecx, 0x30(%r14)
xorl %ecx, %ecx
movl %edx, 0x34(%r14)
cmpl $0x2, 0x8c(%rsp)
movl %r13d, 0xc(%rsp)
je 0x6eee
andl $0x1, %eax
jne 0x6eee
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 0x98b3
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 0x6f02
movl 0x30(%rsp), %eax
movl %eax, 0x28(%r14)
movl 0x34(%rsp), %eax
movl %eax, 0x2c(%r14)
testb %cl, %cl
je 0x6f0a
movq %r14, %rdi
callq 0x5755
movq (%r14), %rdi
movslq 0x3c(%r14), %rsi
callq 0x8322
cmpl $0x2, 0x8c(%rsp)
jne 0x6f24
incl 0x24(%r14)
movl 0x50(%r14), %esi
addl %esi, 0x28(%r14)
addl %esi, 0x2c(%r14)
negl %esi
movq %r14, %rdi
callq 0x57c7
movl 0x3c(%r14), %esi
movq %r14, %rdi
callq 0x57c7
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 0x4fd0
cmpl $0x0, 0x178(%rbx)
je 0x702b
movq (%rbx), %rdi
movq (%r14), %rsi
movl $0x1, %edx
callq 0x4760
movq %r14, %rdi
callq 0x5bdd
callq 0x40f0
testq %rax, %rax
je 0x7194
movq %rax, %r12
movq (%rbx), %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x4370
leaq 0x989f(%rip), %rax      # 0x108f0
movq (%rax), %r15
testq %r15, %r15
je 0x7174
movq 0x8(%r15), %r13
movq (%r13), %rsi
testq %rsi, %rsi
je 0x7084
movq (%r12), %rdi
testq %rdi, %rdi
je 0x716c
callq 0x4540
testl %eax, %eax
jne 0x716c
movq 0x8(%r13), %rsi
testq %rsi, %rsi
je 0x70a8
movq 0x8(%r12), %rdi
testq %rdi, %rdi
je 0x716c
callq 0x4540
testl %eax, %eax
jne 0x716c
movl 0x10(%r13), %eax
testb $0x4, %al
je 0x70bd
movl 0x7c(%r14), %ecx
imull 0x1c(%r13), %ecx
movl %ecx, 0x30(%r14)
testb $0x8, %al
je 0x70d1
movl 0x80(%r14), %ecx
imull 0x20(%r13), %ecx
movl %ecx, 0x34(%r14)
testb $0x1, %al
je 0x710b
movl 0x14(%r13), %ecx
testb $0x10, %al
jne 0x70e3
addl 0x3c(%r14), %ecx
jmp 0x7107
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 0x7145
movl 0x18(%r13), %ecx
testb $0x20, %al
jne 0x711d
addl 0x3c(%r14), %ecx
jmp 0x7141
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 0x628d
cmpl $0x0, 0x24(%r13)
je 0x715f
movl $0x1, 0x94(%r14)
movl 0x28(%r13), %eax
cmpl $-0x2, %eax
je 0x716c
movl %eax, 0x20(%r14)
movq (%r15), %r15
jmp 0x7054
movq (%r12), %rdi
callq 0x4050
movq 0x8(%r12), %rdi
callq 0x4050
movq %r12, %rdi
callq 0x4050
movl 0xc(%rsp), %r13d
movq %r14, %rdi
callq 0x7fe7
movq 0x10(%r14), %rdi
callq 0x7e85
movq 0x10(%r14), %rdi
callq 0x7f36
movl 0x20(%r14), %eax
cmpl $-0x1, %eax
je 0x71c1
movq 0x10(%rsp), %rcx
cmpl 0x60(%rcx), %eax
jne 0x71f9
movq %r14, %rdi
callq 0x5692
movq %r14, %rdi
callq 0x56e7
movq (%r14), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x98b3
testb $0x6, %r13b
jne 0x7206
testl %eax, %eax
je 0x7206
movq %r14, %rdi
callq 0x5868
movq %r14, %rdi
callq 0x9ac4
jmp 0x7206
movq %r14, %rdi
movl $0x3, %esi
callq 0x5652
movq %r14, %rdi
callq 0x8250
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x47c0
jmp 0x720e
nop