// File: /workspace/github_c_makefile_star2_O3/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 0x19ebe(%rip), %rax     # 0x29710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %rbp
movl %edx, %edi
callq 0x1d955
leaq 0x1a599(%rip), %rax     # 0x29e04
cmpb $0x0, (%rax)
jne 0xf8b5
movl 0xc(%rsp), %edi
callq 0x1de79
leaq 0x19e88(%rip), %rcx     # 0x29708
movq (%rcx), %r12
testq %r12, %r12
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0xf8b5
movq 0x60(%r12), %r13
testq %r13, %r13
je 0xf8ab
movq %r12, %rdi
movq %r13, %rsi
callq 0x8958
movq 0x48(%r13), %r13
jmp 0xf895
movq 0x78(%r12), %r12
testq %r12, %r12
jne 0xf890
movb 0x62b(%rbx), %al
movl %eax, %r13d
testb %al, %al
je 0xf9f3
cmpb $0x0, 0x500(%rbx)
je 0xfa21
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 0x1a2ed
testl %eax, %eax
jne 0xf918
movq 0x20(%rsp), %r12
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r14
movl %r13d, %ebp
cmpb $0x1, 0x625(%rbx)
jne 0xf936
leaq 0x19de5(%rip), %rax     # 0x29710
movq (%rax), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %r12
movq 0x600(%rbx), %rax
testq %rax, %rax
je 0xf957
testq %r12, %r12
je 0xf957
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x8f4e
movsd 0x608(%rbx), %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0xf96b
jnp 0xf97e
testq %r12, %r12
je 0xf97e
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x8ff0
movq %r12, 0x38(%rsp)
movl 0xc(%rsp), %edi
callq 0x96c2
movq %rax, %r13
callq 0xa863
movq %rax, %r12
xorl %eax, %eax
cmpb $0x1, 0x62d(%rbx)
jne 0xf9a6
movl 0x64(%r15), %eax
movl %eax, 0x300(%r12)
movq %r12, 0x48(%r13)
movq %r13, %rdi
callq 0xa8b8
movq %r13, %rdi
callq 0xfe75
movq 0x630(%rbx), %rax
testq %rax, %rax
movb %bpl, 0xb(%rsp)
je 0xfa78
movq (%rax), %rax
movq %rax, 0x318(%r12)
movq 0x630(%rbx), %rdi
callq 0x4460
jmp 0xfa97
movq 0x610(%rbx), %rdi
callq 0x4460
movq 0x618(%rbx), %rdi
callq 0x4460
movl 0xc(%rsp), %edi
movl $0x1, %esi
callq 0x11398
movl %r13d, %ebp
jmp 0xfdf2
cmpb $0x0, 0x400(%rbx)
movq %rbp, %r12
je 0xfe03
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 0x19eaf
testl %eax, %eax
movl %r13d, %ebp
jne 0xf91b
movq 0x10(%rsp), %r14
movq 0x18(%rsp), %r15
jmp 0xfe4f
cmpw $0x0, 0x318(%r12)
jne 0xfa97
cmpw $0x0, 0x31a(%r12)
jne 0xfa97
movb $0x1, 0x629(%rbx)
movq %r12, %rdi
callq 0x747e
movq %rax, %rbp
movq %rax, %rdi
movq %r12, %rsi
callq 0x711f
addq $0x4c, %rbp
leaq 0x4c(%r14), %rsi
movq %rbp, %rdi
movq %r13, %rdx
callq 0x6d15
cmpb $0x1, 0x629(%rbx)
jne 0xfad4
movq %r14, %rdi
movq %r12, %rsi
callq 0xfebc
movq %r14, 0x30(%rsp)
leaq 0xf567(%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 0xfb2a
movl (%rax), %eax
andl $-0x2, %eax
cmpl $0x2, %eax
je 0xfb33
cmpb $0x1, 0x624(%rbx)
jne 0xfb38
movb $0x1, 0x24(%r13)
movq 0x30(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
movq 0x38(%rsp), %rcx
callq 0x92a8
leaq 0x19b9d(%rip), %rcx     # 0x296f4
incl (%rcx)
movq %rax, %rbp
leaq 0x1a295(%rip), %rax     # 0x29df8
cmpb $0x1, (%rax)
jne 0xfb93
cmpl $0x1, 0x24(%r15)
jne 0xfb93
movq 0x30(%r15), %rdi
movl $0x1, %esi
callq 0x97a3
cmpl $0x2, %eax
jl 0xfb93
movl 0x28(%r15), %edx
movq %r14, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x7d6e
movb $0x0, 0x24(%r13)
movl 0x20(%r14), %edx
movl 0x20(%r15), %ecx
testq %rbp, %rbp
je 0xfbf0
movl (%rbp), %r8d
leaq 0xfb1f(%rip), %rsi      # 0x1f6cf
movl $0x8000, %edi           # imm = 0x8000
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1e6b8
movq 0x48(%rbp), %rax
testq %rax, %rax
movb 0xb(%rsp), %bpl
je 0xfc10
movq 0x618(%rbx), %rcx
testq %rcx, %rcx
je 0xfc10
cmpl $0x2, (%rcx)
jne 0xfc10
movl 0x310(%rax), %eax
movl %eax, 0x310(%r12)
jmp 0xfc10
leaq 0xfad8(%rip), %rsi      # 0x1f6cf
movl $0x8000, %edi           # imm = 0x8000
xorl %r8d, %r8d
movl 0xc(%rsp), %r9d
xorl %eax, %eax
callq 0x1e6b8
movb 0xb(%rsp), %bpl
movq 0x610(%rbx), %rax
testq %rax, %rax
je 0xfc26
movl (%rax), %eax
movl %eax, 0x310(%r12)
movq 0x618(%rbx), %rax
testq %rax, %rax
je 0xfc42
movl (%rax), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xc70b
movl 0x620(%rbx), %eax
cmpl $0x4, %eax
je 0xfc55
movl %eax, 0x328(%r12)
movzbl 0x624(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xcab4
movzbl 0x625(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xccfe
movzbl 0x626(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xcde9
movzbl 0x627(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xce57
movzbl 0x628(%rbx), %ecx
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9840
movq %r14, %rdi
movq %r15, %rsi
callq 0x8958
leaq 0x1a12a(%rip), %rax     # 0x29dfa
movzbl (%rax), %eax
shll $0x4, %eax
orl $0x600000, %eax         # imm = 0x600000
leaq 0x10(%rsp), %rcx
movl %eax, (%rcx)
leaq 0x199df(%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 0x19a63(%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 0xedf5
cmpq 0x58(%r14), %r15
je 0xfd58
movq %r15, %rdi
movq %r13, %rsi
callq 0xa781
jmp 0xfd63
movq %r15, %rdi
movq %r13, %rsi
callq 0xa7fb
xorl %edi, %edi
callq 0x1e08b
movq %r13, %rdi
movq %r15, %rsi
callq 0x1dbc2
cmpb $0x0, 0x624(%rbx)
jne 0xfdb4
cmpb $0x1, 0x62c(%rbx)
jne 0xfdb4
leaq 0x19982(%rip), %rax     # 0x29710
movq (%rax), %rax
cmpq 0x58(%rax), %r15
je 0xfda4
cmpb $0x1, 0x62a(%rbx)
jne 0xfe58
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xa308
jmp 0xfdda
movq %r15, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd303
xorl %edx, %edx
leaq 0x19946(%rip), %rax     # 0x29710
cmpq (%rax), %r14
sete %dl
movq %r13, %rdi
xorl %esi, %esi
callq 0xff61
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 0xf91b
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 0x19b1a
testl %eax, %eax
jne 0xf91b
movq 0x10(%rsp), %r14
movq 0x58(%r14), %r15
movq 0x38(%r15), %r12
jmp 0xf91b
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x9a3d
jmp 0xfdda