// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xd774
leaq 0x27fbe(%rip), %rax     # 0x35700
movq (%rax), %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xd75d
xorl %eax, %eax
movl %eax, %edi
callq 0x12ab0
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0xd772
leaq 0x27f8d(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0x10(%rbp)
jmp 0xd774
cmpq $0x0, -0x10(%rbp)
jne 0xd784
movb $0x0, -0x1(%rbp)
jmp 0xdc84
cmpq $0x0, -0x18(%rbp)
jne 0xd7c4
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xd7af
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12a30
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0xd7c2
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xd7c4
cmpq $0x0, -0x18(%rbp)
jne 0xd7d4
movb $0x0, -0x1(%rbp)
jmp 0xdc84
cmpq $0x0, -0x20(%rbp)
sete %al
andb $0x1, %al
movb %al, -0x21(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xd831
movq -0x18(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xd831
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xd817
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x12990
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0xd82f
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0xcec0
movq %rax, -0x20(%rbp)
jmp 0xd831
cmpq $0x0, -0x20(%rbp)
je 0xd84e
movq -0x20(%rbp), %rdi
callq 0xcb80
testb $0x1, %al
jne 0xd84e
movb $0x0, -0x1(%rbp)
jmp 0xdc84
leaq 0x27eab(%rip), %rax     # 0x35700
cmpq $0x0, (%rax)
je 0xd86f
leaq 0x27e9e(%rip), %rax     # 0x35700
movq (%rax), %rax
movq 0x58(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0xd881
cmpq $0x0, -0x20(%rbp)
je 0xd881
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xd886
callq 0x18950
movq -0x10(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jbe 0xd92d
movq -0x10(%rbp), %rax
cmpq $0x0, 0x58(%rax)
je 0xd92d
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
cmpq 0x58(%rcx), %rax
je 0xd92d
testb $0x1, -0x21(%rbp)
je 0xd8e8
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpq $0x0, 0x38(%rax)
je 0xd8e8
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rax), %rax
testb $0x1, 0x26(%rax)
je 0xd8e8
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rsi
movq -0x10(%rbp), %rdx
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
movq 0x30(%rax), %r8
callq 0xd0b0
cmpq $0x0, -0x20(%rbp)
jne 0xd92b
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0xd92b
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0xd92d
movq -0x18(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0xd957
movq -0x20(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq 0x38(%rcx), %rax
je 0xd957
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xcf30
cmpq $0x0, -0x20(%rbp)
je 0xd98d
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0xd98d
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
testb $0x1, 0x304(%rax)
je 0xd98d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
xorl %ecx, %ecx
callq 0xdc90
leaq 0x27d6c(%rip), %rax     # 0x35700
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
je 0xda2e
leaq 0x27d58(%rip), %rax     # 0x35700
cmpq $0x0, (%rax)
je 0xd9eb
leaq 0x27d4b(%rip), %rax     # 0x35700
movq (%rax), %rax
movq 0x60(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xd9e9
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movl $0x1, %esi
xorl %edx, %edx
callq 0x167c0
movq -0x30(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xd9c0
jmp 0xd9eb
movq -0x10(%rbp), %rax
movq 0x60(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0xda2c
movq -0x38(%rbp), %rax
cmpq -0x18(%rbp), %rax
jne 0xda0a
jmp 0xda1e
movq -0x38(%rbp), %rax
movq 0x38(%rax), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x167c0
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0xd9f7
jmp 0xda2e
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
cmpq -0x20(%rbp), %rax
je 0xdaaa
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0xbe70
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0xdaa8
movq -0x40(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0xda8f
movq -0x40(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd040
testb $0x1, %al
jne 0xda8f
movq -0x40(%rbp), %rax
movl (%rax), %eax
movl %eax, -0x50(%rbp)
xorl %edi, %edi
movl $0x1, %esi
callq 0x17110
movl -0x50(%rbp), %edi
movl %eax, %esi
callq 0x17180
jmp 0xda91
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xbf80
movq %rax, -0x40(%rbp)
jmp 0xda4d
jmp 0xdaaa
movq -0x20(%rbp), %rdi
movl $0x1, %edx
movl %edx, %esi
callq 0x167c0
movq -0x10(%rbp), %rcx
movb $0x1, %al
leaq 0x27c39(%rip), %rdx     # 0x35700
cmpq (%rdx), %rcx
movb %al, -0x51(%rbp)
jne 0xdae1
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x18(%rbp), %rax
setne %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
andb $0x1, %al
movb %al, -0x41(%rbp)
movb $0x0, -0x42(%rbp)
leaq 0x27c0c(%rip), %rax     # 0x35700
movq (%rax), %rax
cmpq -0x10(%rbp), %rax
je 0xdb3e
movq -0x10(%rbp), %rcx
leaq 0x27bf8(%rip), %rax     # 0x35700
movq %rcx, (%rax)
leaq 0x282da(%rip), %rax     # 0x35dec
testb $0x1, (%rax)
je 0xdb24
movq -0x10(%rbp), %rax
movq 0x4c(%rax), %rdi
callq 0x18a20
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
movl $0x20, %edi
leaq 0x1fd8a(%rip), %rsi     # 0x2d8c1
movb $0x0, %al
callq 0x2c0b0
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0xdb7b
movq -0x18(%rbp), %rdi
callq 0x9b20
movq -0x20(%rbp), %rdi
callq 0x188b0
movb $0x1, -0x42(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rdi
callq 0x9b50
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x58(%rax)
testb $0x1, -0x41(%rbp)
je 0xdba7
callq 0x2ae60
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movl $0x1000, %edi           # imm = 0x1000
leaq 0x1fd37(%rip), %rsi     # 0x2d8d7
movb $0x0, %al
callq 0x2c0b0
movq -0x20(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
testb $0x1, -0x42(%rbp)
jne 0xdbc2
movq -0x20(%rbp), %rdi
callq 0x188b0
callq 0x2ac40
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
movl $0x1, %ecx
callq 0x12420
movl $0x1, %edi
movb $0x0, %al
callq 0x2c0b0
cmpq $0x0, -0x20(%rbp)
jne 0xdc07
leaq 0x281f3(%rip), %rax     # 0x35dea
testb $0x1, (%rax)
je 0xdc01
callq 0x18450
movb $0x1, -0x1(%rbp)
jmp 0xdc84
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x20(%rbp), %rax
movl (%rax), %r8d
movl $0x80000, %edi          # imm = 0x80000
leaq 0x1fccc(%rip), %rsi     # 0x2d8f4
movb $0x0, %al
callq 0x2c0b0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x120e0
leaq 0x281a3(%rip), %rax     # 0x35deb
testb $0x1, (%rax)
je 0xdc6d
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xc7f0
movq %rax, -0x4a(%rbp)
movq -0x4a(%rbp), %rdi
callq 0x18a20
jmp 0xdc80
leaq 0x28176(%rip), %rax     # 0x35dea
testb $0x1, (%rax)
je 0xdc7e
callq 0x18450
jmp 0xdc80
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x60, %rsp
popq %rbp
retq
nop