// File: /workspace/github_c_makefile_star2_O2/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 0x19b3c(%rip), %rax     # 0x28710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %rbp
movl %edx, %edi
callq 0x1c3ee
leaq 0x1a217(%rip), %rax     # 0x28e04
cmpb $0x0, (%rax)
jne 0xec34
movl 0xc(%rsp), %edi
callq 0x1c860
testb %al, %al
je 0xec34
leaq 0x19b02(%rip), %r12     # 0x28708
movq (%r12), %r12
testq %r12, %r12
je 0xec34
leaq 0x60(%r12), %r13
movq (%r13), %r13
testq %r13, %r13
je 0xec2e
movq %r12, %rdi
movq %r13, %rsi
callq 0x8670
addq $0x48, %r13
jmp 0xec14
addq $0x78, %r12
jmp 0xec06
movb 0x62b(%rbx), %r12b
testb %r12b, %r12b
je 0xec96
movb %r12b, 0xb(%rsp)
cmpb $0x0, 0x500(%rbx)
je 0xecbc
leaq 0x500(%rbx), %rdi
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
movq %r15, 0x8(%rsi)
movq %rbp, 0x10(%rsi)
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
callq 0x18ebb
testl %eax, %eax
jne 0xed44
movq 0x20(%rsp), %rbp
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r14
jmp 0xed44
movq 0x610(%rbx), %rdi
callq 0x4460
movq 0x618(%rbx), %rdi
callq 0x4460
movl 0xc(%rsp), %edi
callq 0xf175
jmp 0xf153
cmpb $0x0, 0x400(%rbx)
je 0xed02
leaq 0x40(%rsp), %rsi
movq %r14, (%rsi)
movq %r15, 0x8(%rsi)
andq $0x0, 0x10(%rsi)
leaq 0x400(%rbx), %rdi
xorps %xmm0, %xmm0
leaq 0x10(%rsp), %rdx
movaps %xmm0, (%rdx)
andq $0x0, 0x10(%rdx)
callq 0x18a95
testl %eax, %eax
jne 0xed44
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
jmp 0xed40
cmpb $0x0, 0x300(%rbx)
je 0xed44
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)
andq $0x0, 0x10(%rdx)
callq 0x1876b
testl %eax, %eax
jne 0xed44
movq 0x10(%rsp), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %rbp
cmpb $0x1, 0x625(%rbx)
jne 0xed5f
leaq 0x199bc(%rip), %rax     # 0x28710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %rbp
movq 0x600(%rbx), %rax
testq %rax, %rax
je 0xed80
testq %rbp, %rbp
je 0xed80
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x8c3c
movsd 0x608(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xed94
jnp 0xeda7
testq %rbp, %rbp
je 0xeda7
movq %r14, %rdi
movq %r15, %rsi
movq %rbp, %rdx
callq 0x8cbe
movq %rbp, 0x30(%rsp)
movl 0xc(%rsp), %edi
callq 0x92e9
movq %rax, %r13
callq 0xa1f3
movq %rax, %r12
xorl %eax, %eax
cmpb $0x1, 0x62d(%rbx)
jne 0xedcf
movl 0x64(%r15), %eax
movl %eax, 0x300(%r12)
movq %r12, 0x48(%r13)
movq %r13, %rdi
callq 0xa246
movq %r13, %rdi
callq 0xf17d
movq 0x630(%rbx), %rax
testq %rax, %rax
je 0xee10
movq (%rax), %rax
movq %rax, 0x318(%r12)
movq 0x630(%rbx), %rdi
callq 0x4460
jmp 0xee2f
cmpw $0x0, 0x318(%r12)
jne 0xee2f
cmpw $0x0, 0x31a(%r12)
jne 0xee2f
movb $0x1, 0x629(%rbx)
movq %r12, %rdi
callq 0x7330
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
callq 0x6fef
addq $0x4c, %rbp
leaq 0x4c(%r14), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x6bfe
cmpb $0x1, 0x629(%rbx)
jne 0xee6c
movq %r14, %rdi
movq %r12, %rsi
callq 0xf1c4
movq %r14, 0x38(%rsp)
leaq 0xf1cf(%rip), %rbp      # 0x1e047
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 0xeec2
movl (%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
je 0xeecb
cmpb $0x1, 0x624(%rbx)
jne 0xeed0
movb $0x1, 0x24(%r13)
movq 0x38(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x30(%rsp), %rcx
callq 0x8f01
leaq 0x19805(%rip), %rcx     # 0x286f4
incl (%rcx)
movq %rax, %rbp
leaq 0x19efd(%rip), %rax     # 0x28df8
cmpb $0x1, (%rax)
jne 0xef29
cmpl $0x1, 0x24(%r15)
jne 0xef29
movq 0x30(%r15), %rdi
pushq $0x1
popq %rsi
callq 0x93c6
cmpl $0x2, %eax
jl 0xef29
movl 0x28(%r15), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x7b4b
movb $0x0, 0x24(%r13)
movl 0x20(%r14), %edx
movl 0x20(%r15), %ecx
testq %rbp, %rbp
je 0xef86
movl (%rbp), %r8d
leaq 0xf789(%rip), %rsi      # 0x1e6cf
movl $0x8000, %edi           # imm = 0x8000
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1d07d
movq 0x48(%rbp), %rax
testq %rax, %rax
movb 0xb(%rsp), %bpl
je 0xefa6
movq 0x618(%rbx), %rcx
testq %rcx, %rcx
je 0xefa6
cmpl $0x2, (%rcx)
jne 0xefa6
movl 0x310(%rax), %eax
movl %eax, 0x310(%r12)
jmp 0xefa6
leaq 0xf742(%rip), %rsi      # 0x1e6cf
movl $0x8000, %edi           # imm = 0x8000
xorl %r8d, %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1d07d
movb 0xb(%rsp), %bpl
movq 0x610(%rbx), %rax
testq %rax, %rax
je 0xefbc
movl (%rax), %eax
movl %eax, 0x310(%r12)
movq 0x618(%rbx), %rax
testq %rax, %rax
je 0xefd8
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xbd28
movl 0x620(%rbx), %eax
cmpl $0x4, %eax
je 0xefeb
movl %eax, 0x328(%r12)
movzbl 0x624(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc0c5
movzbl 0x625(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc2b8
movzbl 0x626(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc39e
movzbl 0x627(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc40a
movzbl 0x628(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9435
movq %r14, %rdi
movq %r15, %rsi
callq 0x8670
leaq 0x19d94(%rip), %rax     # 0x28dfa
movzbl (%rax), %eax
shll $0x4, %eax
orl $0x600000, %eax         # imm = 0x600000
leaq 0x40(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x19649(%rip), %rax     # 0x286c8
movq (%rax), %rdi
movl 0xc(%rsp), %r12d
movl %r12d, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x4700
pushq $0x1
popq %rsi
movl %r12d, %edi
callq 0xf220
movl %r12d, %edi
callq 0xe1a9
cmpq 0x58(%r14), %r15
je 0xf0ba
movq %r15, %rdi
movq %r13, %rsi
callq 0xa117
jmp 0xf0c5
movq %r15, %rdi
movq %r13, %rsi
callq 0xa18e
movl %ebp, %r12d
xorl %edi, %edi
callq 0x1ca74
movq %r13, %rdi
movq %r15, %rsi
callq 0x1c625
cmpb $0x0, 0x624(%rbx)
jne 0xf115
cmpb $0x1, 0x62c(%rbx)
jne 0xf115
leaq 0x1961d(%rip), %rax     # 0x28710
movq (%rax), %rax
cmpq 0x58(%rax), %r15
je 0xf105
cmpb $0x1, 0x62a(%rbx)
jne 0xf165
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9cf6
jmp 0xf13b
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xc7ea
xorl %edx, %edx
leaq 0x195e5(%rip), %rax     # 0x28710
cmpq (%rax), %r14
sete %dl
movq %r13, %rdi
xorl %esi, %esi
callq 0xf25d
movq 0x610(%rbx), %rdi
callq 0x4460
movq 0x618(%rbx), %rdi
callq 0x4460
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x95e4
jmp 0xf13b