// File: /workspace/github_c_makefile_star2_O2/baskerville[P]bspwm/src/tree.c
// Function: focus_node
bool focus_node(monitor_t *m, desktop_t *d, node_t *n)
{
	if (m == NULL) {
		m = mon;
		if (m == NULL) {
			m = history_last_monitor(NULL);
		}
		if (m == NULL) {
			m = mon_head;
		}
	}

	if (m == NULL) {
		return false;
	}

	if (d == NULL) {
		d = m->desk;
		if (d == NULL) {
			d = history_last_desktop(m, NULL);
		}
		if (d == NULL) {
			d = m->desk_head;
		}
	}

	if (d == NULL) {
		return false;
	}

	bool guess = (n == NULL);

	if (n == NULL && d->root != NULL) {
		n = d->focus;
		if (n == NULL) {
			n = history_last_node(d, NULL);
		}
		if (n == NULL) {
			n = first_focusable_leaf(d->root);
		}
	}

	if (n != NULL && !is_focusable(n)) {
		return false;
	}

	if ((mon != NULL && mon->desk != d) || n == NULL || n->client == NULL) {
		clear_input_focus();
	}

	if (m->sticky_count > 0 && m->desk != NULL && d != m->desk) {
		if (guess && m->desk->focus != NULL && m->desk->focus->sticky) {
			n = m->desk->focus;
		}

		transfer_sticky_nodes(m, m->desk, m, d, m->desk->root);

		if (n == NULL && d->focus != NULL) {
			n = d->focus;
		}
	}

	if (d->focus != NULL && n != d->focus) {
		neutralize_occluding_windows(m, d, n);
	}

	if (n != NULL && n->client != NULL && n->client->urgent) {
		set_urgent(m, d, n, false);
	}

	if (mon != m) {
		if (mon != NULL) {
			for (desktop_t *e = mon->desk_head; e != NULL; e = e->next) {
				draw_border(e->focus, true, false);
			}
		}
		for (desktop_t *e = m->desk_head; e != NULL; e = e->next) {
			if (e == d) {
				continue;
			}
			draw_border(e->focus, true, true);
		}
	}

	if (d->focus != n) {
		for (node_t *f = first_extrema(d->focus); f != NULL; f = next_leaf(f, d->focus)) {
			if (f->client != NULL && !is_descendant(f, n)) {
				window_draw_border(f->id, get_border_color(false, true));
			}
		}
	}

	draw_border(n, true, true);

	bool desk_changed = (m != mon || m->desk != d);
	bool has_input_focus = false;

	if (mon != m) {
		mon = m;

		if (pointer_follows_monitor) {
			center_pointer(m->rectangle);
		}

		put_status(SBSC_MASK_MONITOR_FOCUS, "monitor_focus 0x%08X\n", m->id);
	}

	if (m->desk != d) {
		show_desktop(d);
		set_input_focus(n);
		has_input_focus = true;
		hide_desktop(m->desk);
		m->desk = d;
	}

	if (desk_changed) {
		ewmh_update_current_desktop();
		put_status(SBSC_MASK_DESKTOP_FOCUS, "desktop_focus 0x%08X 0x%08X\n", m->id, d->id);
	}

	d->focus = n;
	if (!has_input_focus) {
		set_input_focus(n);
	}
	ewmh_update_active_window();
	history_add(m, d, n, true);

	put_status(SBSC_MASK_REPORT);

	if (n == NULL) {
		if (focus_follows_pointer) {
			update_motion_recorder();
		}
		return true;
	}

	put_status(SBSC_MASK_NODE_FOCUS, "node_focus 0x%08X 0x%08X 0x%08X\n", m->id, d->id, n->id);

	stack(d, n, true);

	if (pointer_follows_focus) {
		center_pointer(get_rectangle(m, d, n));
	} else if (focus_follows_pointer) {
		update_motion_recorder();
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
testq %rdi, %rdi
jne 0x9d3c
leaq 0x1e9fa(%rip), %rax     # 0x28710
movq (%rax), %r14
testq %r14, %r14
jne 0x9d28
xorl %edi, %edi
callq 0xcd4d
movq %rax, %r14
testq %r14, %r14
jne 0x9d37
leaq 0x1e9d4(%rip), %rax     # 0x28708
movq (%rax), %r14
testq %r14, %r14
je 0x9d97
testq %rbx, %rbx
jne 0x9d65
movq 0x58(%r14), %rbx
testq %rbx, %rbx
jne 0x9d65
movq %r14, %rdi
xorl %esi, %esi
callq 0xcd21
movq %rax, %rbx
testq %rax, %rax
jne 0x9d65
movq 0x60(%r14), %rbx
testq %rbx, %rbx
je 0x9d97
movq %r12, %r15
testq %r12, %r12
je 0x9d9e
movq %r15, %rdi
callq 0x9519
testb %al, %al
je 0x9d97
leaq 0x1e990(%rip), %rax     # 0x28710
movq (%rax), %rax
testq %rax, %rax
je 0x9d8e
cmpq %rbx, 0x58(%rax)
jne 0x9dd3
cmpq $0x0, 0x48(%r15)
jne 0x9dd8
jmp 0x9dd3
xorl %ebx, %ebx
jmp 0xa061
cmpq $0x0, 0x30(%rbx)
je 0x9dd0
movq 0x38(%rbx), %r15
testq %r15, %r15
jne 0x9d6d
movq %rbx, %rdi
xorl %esi, %esi
callq 0xccbc
testq %rax, %rax
jne 0x9dcb
movq 0x30(%rbx), %rdi
callq 0x97a0
testq %rax, %rax
je 0x9dd0
movq %rax, %r15
jmp 0x9d6d
xorl %r15d, %r15d
callq 0x105cd
cmpl $0x0, 0x40(%r14)
je 0x9e24
movq 0x58(%r14), %rsi
testq %rsi, %rsi
sete %al
cmpq %rsi, %rbx
sete %cl
orb %al, %cl
jne 0x9e24
testq %r12, %r12
jne 0x9e09
movq 0x38(%rsi), %rax
testq %rax, %rax
je 0x9e09
cmpb $0x0, 0x26(%rax)
cmovneq %rax, %r15
movq 0x30(%rsi), %r8
movq %r14, %rdi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x98bc
testq %r15, %r15
jne 0x9e24
movq 0x38(%rbx), %r15
movq 0x38(%rbx), %rax
testq %rax, %rax
je 0x9e40
cmpq %rax, %r15
je 0x9e40
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x97ca
testq %r15, %r15
je 0x9e67
movq 0x48(%r15), %rax
testq %rax, %rax
je 0x9e67
cmpb $0x1, 0x304(%rax)
jne 0x9e67
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xa072
leaq 0x1e8a2(%rip), %rax     # 0x28710
movq (%rax), %r12
cmpq %r14, %r12
je 0x9ec8
testq %r12, %r12
je 0x9e9f
addq $0x60, %r12
pushq $0x1
popq %rbp
movq (%r12), %r12
testq %r12, %r12
je 0x9e9f
movq 0x38(%r12), %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0xf25d
addq $0x48, %r12
jmp 0x9e82
leaq 0x60(%r14), %r12
pushq $0x1
popq %rbp
movq (%r12), %r12
testq %r12, %r12
je 0x9ec8
cmpq %rbx, %r12
je 0x9ec2
movq 0x38(%r12), %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0xf25d
addq $0x48, %r12
jmp 0x9ea6
movq 0x38(%rbx), %r13
cmpq %r15, %r13
je 0x9f26
movq %r13, %rdi
callq 0x8e72
movq %rax, %r12
pushq $0x1
popq %rbp
testq %r12, %r12
je 0x9f26
cmpq $0x0, 0x48(%r12)
je 0x9f16
movq %r12, %rdi
movq %r15, %rsi
callq 0x9892
testb %al, %al
jne 0x9f16
movl (%r12), %r13d
xorl %edi, %edi
movl %ebp, %esi
callq 0xf813
movl %r13d, %edi
movl %eax, %esi
callq 0xf83d
movq 0x38(%rbx), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x8ed0
movq %rax, %r12
jmp 0x9edf
pushq $0x1
popq %rdx
movq %r15, %rdi
movl %edx, %esi
callq 0xf25d
leaq 0x1e7d6(%rip), %rax     # 0x28710
cmpq (%rax), %r14
je 0x9f75
movq %r14, (%rax)
leaq 0x1eeb3(%rip), %rax     # 0x28dfc
cmpb $0x1, (%rax)
jne 0x9f57
movq 0x4c(%r14), %rdi
callq 0x10648
movl 0x20(%r14), %edx
leaq 0x147b7(%rip), %rsi     # 0x1e719
pushq $0x20
popq %rdi
xorl %eax, %eax
callq 0x1d07d
movq 0x58(%r14), %r12
movb $0x1, %bpl
jmp 0x9f80
movq 0x58(%r14), %r12
cmpq %rbx, %r12
setne %bpl
cmpq %rbx, %r12
je 0x9fa2
movq %rbx, %rdi
callq 0x7978
movq %r15, %rdi
callq 0x1056b
movq 0x58(%r14), %rdi
callq 0x7987
movq %rbx, 0x58(%r14)
testb %bpl, %bpl
je 0x9fc6
callq 0x1c5f3
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
leaq 0x14775(%rip), %rsi     # 0x1e72f
movl $0x1000, %edi           # imm = 0x1000
xorl %eax, %eax
callq 0x1d07d
movq %r15, 0x38(%rbx)
cmpq %rbx, %r12
jne 0x9fd7
movq %r15, %rdi
callq 0x1056b
callq 0x1c508
pushq $0x1
popq %rbp
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl %ebp, %ecx
callq 0xc9b6
movl %ebp, %edi
xorl %eax, %eax
callq 0x1d07d
testq %r15, %r15
je 0xa04e
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
leaq 0x1473e(%rip), %rsi     # 0x1e74c
movl $0x80000, %edi          # imm = 0x80000
xorl %eax, %eax
callq 0x1d07d
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0xc7ea
leaq 0x1edcc(%rip), %rax     # 0x28dfb
cmpb $0x1, (%rax)
jne 0xa04e
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x932e
movq %rax, %rdi
callq 0x10648
movb $0x1, %bl
jmp 0xa061
leaq 0x1eda5(%rip), %rax     # 0x28dfa
movb $0x1, %bl
cmpb $0x1, (%rax)
jne 0xa061
callq 0x102fe
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq