// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/window.c
// Function: manage_window
bool manage_window(xcb_window_t win, rule_consequence_t *csq, int fd)
{
	monitor_t *m = mon;
	desktop_t *d = mon->desk;
	node_t *f = mon->desk->focus;

	parse_rule_consequence(fd, csq);

	if (!ignore_ewmh_struts && ewmh_handle_struts(win)) {
		for (monitor_t *m = mon_head; m != NULL; m = m->next) {
			for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
				arrange(m, d);
			}
		}
	}

	if (!csq->manage) {
		free(csq->layer);
		free(csq->state);
		window_show(win);
		return false;
	}

	if (csq->node_desc[0] != '\0') {
		coordinates_t ref = {m, d, f};
		coordinates_t trg = {NULL, NULL, NULL};
		if (node_from_desc(csq->node_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.desktop;
			f = trg.node;
		}
	} else if (csq->desktop_desc[0] != '\0') {
		coordinates_t ref = {m, d, NULL};
		coordinates_t trg = {NULL, NULL, NULL};
		if (desktop_from_desc(csq->desktop_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.desktop;
			f = trg.desktop->focus;
		}
	} else if (csq->monitor_desc[0] != '\0') {
		coordinates_t ref = {m, NULL, NULL};
		coordinates_t trg = {NULL, NULL, NULL};
		if (monitor_from_desc(csq->monitor_desc, &ref, &trg) == SELECTOR_OK) {
			m = trg.monitor;
			d = trg.monitor->desk;
			f = trg.monitor->desk->focus;
		}
	}

	if (csq->sticky) {
		m = mon;
		d = mon->desk;
		f = mon->desk->focus;
	}

	if (csq->split_dir != NULL && f != NULL) {
		presel_dir(m, d, f, *csq->split_dir);
	}

	if (csq->split_ratio != 0 && f != NULL) {
		presel_ratio(m, d, f, csq->split_ratio);
	}

	node_t *n = make_node(win);
	client_t *c = make_client();
	c->border_width = csq->border ? d->border_width : 0;
	n->client = c;
	initialize_client(n);
	initialize_floating_rectangle(n);

	if (csq->rect != NULL) {
		c->floating_rectangle = *csq->rect;
		free(csq->rect);
	} else if (c->floating_rectangle.x == 0 && c->floating_rectangle.y == 0) {
		csq->center = true;
	}

	monitor_t *mm = monitor_from_client(c);
	embrace_client(mm, c);
	adapt_geometry(&mm->rectangle, &m->rectangle, n);

	if (csq->center) {
		window_center(m, c);
	}

	snprintf(c->class_name, sizeof(c->class_name), "%s", csq->class_name);
	snprintf(c->instance_name, sizeof(c->instance_name), "%s", csq->instance_name);

	if ((csq->state != NULL && (*(csq->state) == STATE_FLOATING || *(csq->state) == STATE_FULLSCREEN)) || csq->hidden) {
		n->vacant = true;
	}

	f = insert_node(m, d, n, f);
	clients_count++;
	if (single_monocle && d->layout == LAYOUT_MONOCLE && tiled_count(d->root, true) > 1) {
		set_layout(m, d, d->user_layout, false);
	}

	n->vacant = false;

	put_status(SBSC_MASK_NODE_ADD, "node_add 0x%08X 0x%08X 0x%08X 0x%08X\n", m->id, d->id, f!=NULL?f->id:0, win);

	if (f != NULL && f->client != NULL && csq->state != NULL && *(csq->state) == STATE_FLOATING) {
		c->layer = f->client->layer;
	}

	if (csq->layer != NULL) {
		c->layer = *(csq->layer);
	}

	if (csq->state != NULL) {
		set_state(m, d, n, *(csq->state));
	}

	if (csq->honor_size_hints != HONOR_SIZE_HINTS_DEFAULT) {
		c->honor_size_hints = csq->honor_size_hints;
	}

	set_hidden(m, d, n, csq->hidden);
	set_sticky(m, d, n, csq->sticky);
	set_private(m, d, n, csq->private);
	set_locked(m, d, n, csq->locked);
	set_marked(m, d, n, csq->marked);

	arrange(m, d);

	uint32_t values[] = {CLIENT_EVENT_MASK | (focus_follows_pointer ? XCB_EVENT_MASK_ENTER_WINDOW : 0)};
	xcb_change_window_attributes(dpy, win, XCB_CW_EVENT_MASK, values);
	set_window_state(win, XCB_ICCCM_WM_STATE_NORMAL);
	window_grab_buttons(win);

	if (d == m->desk) {
		show_node(d, n);
	} else {
		hide_node(d, n);
	}

	ewmh_update_client_list(false);
	ewmh_set_wm_desktop(n, d);

	if (!csq->hidden && csq->focus) {
		if (d == mon->desk || csq->follow) {
			focus_node(m, d, n);
		} else {
			activate_node(m, d, n);
		}
	} else {
		stack(d, n, false);
		draw_border(n, false, (m == mon));
	}

	free(csq->layer);
	free(csq->state);

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movl %edi, 0xc(%rsp)
leaq 0x19f1a(%rip), %rax     # 0x29710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %rbp
movl %edx, %edi
callq 0x1dcc4
leaq 0x1a5f5(%rip), %rax     # 0x29e04
cmpb $0x0, (%rax)
jne 0xf859
movl 0xc(%rsp), %edi
callq 0x1e250
leaq 0x19ee4(%rip), %rcx     # 0x29708
movq (%rcx), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xf859
movq 0x60(%r12), %r13
testq %r13, %r13
je 0xf84f
movq %r12, %rdi
movq %r13, %rsi
callq 0x8a5c
movq 0x48(%r13), %r13
jmp 0xf839
movq 0x78(%r12), %r12
testq %r12, %r12
jne 0xf834
movb 0x62b(%rbx), %al
movl %eax, %r13d
testb %al, %al
je 0xf997
cmpb $0x0, 0x500(%rbx)
je 0xf9c5
leaq 0x500(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
movq %r15, 0x8(%rsi)
movq %rbp, %r12
movq %rbp, 0x10(%rsi)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
callq 0x1a436
testl %eax, %eax
jne 0xf8bc
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r14
movl %r13d, %ebp
cmpb $0x1, 0x625(%rbx)
jne 0xf8da
leaq 0x19e41(%rip), %rax     # 0x29710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %r12
movq 0x600(%rbx), %rax
testq %rax, %rax
je 0xf8fb
testq %r12, %r12
je 0xf8fb
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x9059
movsd 0x608(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf90f
jnp 0xf922
testq %r12, %r12
je 0xf922
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x9104
movq %r12, 0x38(%rsp)
movl 0xc(%rsp), %edi
callq 0x97c2
movq %rax, %r13
callq 0xa7fd
movq %rax, %r12
xorl %eax, %eax
cmpb $0x1, 0x62d(%rbx)
jne 0xf94a
movl 0x64(%r15), %eax
movl %eax, 0x300(%r12)
movq %r12, 0x48(%r13)
movq %r13, %rdi
callq 0xa87d
movq %r13, %rdi
callq 0xfe19
movq 0x630(%rbx), %rax
testq %rax, %rax
movb %bpl, 0xb(%rsp)
je 0xfa1c
movq (%rax), %rax
movq %rax, 0x318(%r12)
movq 0x630(%rbx), %rdi
callq 0x4460
jmp 0xfa3b
movq 0x610(%rbx), %rdi
callq 0x4460
movq 0x618(%rbx), %rdi
callq 0x4460
movl 0xc(%rsp), %edi
movl $0x1, %esi
callq 0x1138c
movl %r13d, %ebp
jmp 0xfd96
cmpb $0x0, 0x400(%rbx)
movq %rbp, %r12
je 0xfda7
leaq 0x400(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
movq %r15, 0x8(%rsi)
xorl %eax, %eax
movq %rax, 0x10(%rsi)
leaq 0x10(%rsp), %rdx
movq %rax, 0x10(%rdx)
xorps %xmm0, %xmm0
movaps %xmm0, (%rdx)
callq 0x19fc7
testl %eax, %eax
movl %r13d, %ebp
jne 0xf8bf
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
jmp 0xfdf3
cmpw $0x0, 0x318(%r12)
jne 0xfa3b
cmpw $0x0, 0x31a(%r12)
jne 0xfa3b
movb $0x1, 0x629(%rbx)
movq %r12, %rdi
callq 0x7565
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
callq 0x71fa
addq $0x4c, %rbp
leaq 0x4c(%r14), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x6df4
cmpb $0x1, 0x629(%rbx)
jne 0xfa78
movq %r14, %rdi
movq %r12, %rsi
callq 0xfe60
movq %r14, 0x30(%rsp)
leaq 0xf5c3(%rip), %rbp      # 0x1f047
movl $0x100, %r14d           # imm = 0x100
movl $0x100, %esi            # imm = 0x100
movq %r12, %rdi
movq %rbp, %rdx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x4110
movq %r12, %rdi
addq %r14, %rdi
leaq (%rbx,%r14), %rcx
movl $0x100, %esi            # imm = 0x100
movq %rbp, %rdx
xorl %eax, %eax
callq 0x4110
movq 0x618(%rbx), %rax
testq %rax, %rax
je 0xface
movl (%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
je 0xfad7
cmpb $0x1, 0x624(%rbx)
jne 0xfadc
movb $0x1, 0x24(%r13)
movq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x38(%rsp), %rcx
callq 0x93a5
leaq 0x19bf9(%rip), %rcx     # 0x296f4
incl (%rcx)
movq %rax, %rbp
leaq 0x1a2f1(%rip), %rax     # 0x29df8
cmpb $0x1, (%rax)
jne 0xfb37
cmpl $0x1, 0x24(%r15)
jne 0xfb37
movq 0x30(%r15), %rdi
movl $0x1, %esi
callq 0x98c5
cmpl $0x2, %eax
jl 0xfb37
movl 0x28(%r15), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x7ec3
movb $0x0, 0x24(%r13)
movl 0x20(%r14), %edx
movl 0x20(%r15), %ecx
testq %rbp, %rbp
je 0xfb94
movl (%rbp), %r8d
leaq 0xfb8b(%rip), %rsi      # 0x1f6df
movl $0x8000, %edi           # imm = 0x8000
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1eb0b
movq 0x48(%rbp), %rax
testq %rax, %rax
movb 0xb(%rsp), %bpl
je 0xfbb4
movq 0x618(%rbx), %rcx
testq %rcx, %rcx
je 0xfbb4
cmpl $0x2, (%rcx)
jne 0xfbb4
movl 0x310(%rax), %eax
movl %eax, 0x310(%r12)
jmp 0xfbb4
leaq 0xfb44(%rip), %rsi      # 0x1f6df
movl $0x8000, %edi           # imm = 0x8000
xorl %r8d, %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1eb0b
movb 0xb(%rsp), %bpl
movq 0x610(%rbx), %rax
testq %rax, %rax
je 0xfbca
movl (%rax), %eax
movl %eax, 0x310(%r12)
movq 0x618(%rbx), %rax
testq %rax, %rax
je 0xfbe6
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc64b
movl 0x620(%rbx), %eax
cmpl $0x4, %eax
je 0xfbf9
movl %eax, 0x328(%r12)
movzbl 0x624(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc9f0
movzbl 0x625(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xcc51
movzbl 0x626(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xcd2e
movzbl 0x627(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xcd9c
movzbl 0x628(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9937
movq %r14, %rdi
movq %r15, %rsi
callq 0x8a5c
leaq 0x1a186(%rip), %rax     # 0x29dfa
movzbl (%rax), %eax
shll $0x4, %eax
orl $0x600000, %eax         # imm = 0x600000
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x19a3b(%rip), %r14     # 0x296c8
movq (%r14), %rdi
movl 0xc(%rsp), %r12d
movl %r12d, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x4700
leaq 0x40(%rsp), %rax
movq $0x1, (%rax)
movq $0x0, 0x8(%rax)
movq (%r14), %rdi
movq 0x30(%rsp), %r14
leaq 0x19abf(%rip), %rcx     # 0x29784
movl (%rcx), %ecx
xorl %esi, %esi
movl %r12d, %edx
movl %ecx, %r8d
movl $0x20, %r9d
pushq %rax
pushq $0x2
callq 0x48e0
addq $0x10, %rsp
movl %r12d, %edi
callq 0xed89
cmpq 0x58(%r14), %r15
je 0xfcfc
movq %r15, %rdi
movq %r13, %rsi
callq 0xa721
jmp 0xfd07
movq %r15, %rdi
movq %r13, %rsi
callq 0xa798
xorl %edi, %edi
callq 0x1e462
movq %r13, %rdi
movq %r15, %rsi
callq 0x1df7b
cmpb $0x0, 0x624(%rbx)
jne 0xfd58
cmpb $0x1, 0x62c(%rbx)
jne 0xfd58
leaq 0x199de(%rip), %rax     # 0x29710
movq (%rax), %rax
cmpq 0x58(%rax), %r15
je 0xfd48
cmpb $0x1, 0x62a(%rbx)
jne 0xfdfc
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xa2cd
jmp 0xfd7e
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd20e
xorl %edx, %edx
leaq 0x199a2(%rip), %rax     # 0x29710
cmpq (%rax), %r14
sete %dl
movq %r13, %rdi
xorl %esi, %esi
callq 0xff0c
movq 0x610(%rbx), %rdi
callq 0x4460
movq 0x618(%rbx), %rdi
callq 0x4460
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb $0x0, 0x300(%rbx)
movl %r13d, %ebp
je 0xf8bf
leaq 0x300(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rsi)
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
movq $0x0, 0x10(%rdx)
callq 0x19c02
testl %eax, %eax
jne 0xf8bf
movq 0x10(%rsp), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %r12
jmp 0xf8bf
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9af5
jmp 0xfd7e