// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/desktop.c
// Function: transfer_desktop
bool transfer_desktop(monitor_t *ms, monitor_t *md, desktop_t *d, bool follow)
{
	if (ms == NULL || md == NULL || d == NULL || ms == md) {
		return false;
	}

	bool d_was_active = (d == ms->desk);
	bool ms_was_focused = (ms == mon);
	unsigned int sc = (ms->sticky_count > 0 && d_was_active) ? sticky_count(d->root) : 0;

	unlink_desktop(ms, d);
	ms->sticky_count -= sc;

	if ((!follow || !d_was_active || !ms_was_focused) && md->desk != NULL) {
		hide_sticky = false;
		hide_desktop(d);
		hide_sticky = true;
	}

	insert_desktop(md, d);
	md->sticky_count += sc;
	history_remove(d, NULL, false);

	if (d_was_active) {
		if (follow) {
			if (activate_desktop(ms, NULL)) {
				activate_node(ms, ms->desk, NULL);
			}
			if (ms_was_focused) {
				focus_node(md, d, d->focus);
			}
		} else {
			if (ms_was_focused) {
				focus_node(ms, ms->desk, NULL);
			} else if (activate_desktop(ms, NULL)) {
				activate_node(ms, ms->desk, NULL);
			}
		}
	}

	if (sc > 0) {
		if (ms->desk != NULL) {
			transfer_sticky_nodes(md, d, ms, ms->desk, d->root);
		} else if (d != md->desk) {
			transfer_sticky_nodes(md, d, md, md->desk, d->root);
		}
	}

	adapt_geometry(&ms->rectangle, &md->rectangle, d->root);
	arrange(md, d);

	if ((!follow || !d_was_active || !ms_was_focused) && md->desk == d) {
		if (md == mon) {
			focus_node(md, d, d->focus);
		} else {
			activate_node(md, d, d->focus);
		}
	}

	ewmh_update_wm_desktops();
	ewmh_update_desktop_names();
	ewmh_update_desktop_viewport();
	ewmh_update_current_desktop();

	put_status(SBSC_MASK_DESKTOP_TRANSFER, "desktop_transfer 0x%08X 0x%08X 0x%08X\n", ms->id, d->id, md->id);
	put_status(SBSC_MASK_REPORT);

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %r15
movq %rsi, %r14
testq %rdi, %rdi
setne %al
testq %rsi, %rsi
setne %sil
andb %al, %sil
testq %rdx, %rdx
setne %dl
cmpq %r14, %rdi
setne %al
andb %dl, %al
andb %sil, %al
cmpb $0x1, %al
jne 0x8204
movq %rdi, %r12
movl %ecx, 0x14(%rsp)
movb %al, 0xf(%rsp)
movq 0x58(%rdi), %r13
cmpq %r15, %r13
setne %dl
leaq 0x21704(%rip), %rcx     # 0x29710
cmpl $0x0, 0x40(%rdi)
movq (%rcx), %rbx
sete %cl
xorl %eax, %eax
orb %dl, %cl
jne 0x8025
movq 0x30(%r15), %rdi
callq 0xba1f
movq %rbx, 0x18(%rsp)
cmpq %r12, %rbx
setne %bpl
movq %r13, 0x20(%rsp)
cmpq %r15, %r13
movl %eax, %ebx
setne %r13b
movq %r12, %rdi
movq %r15, %rsi
callq 0x8227
movl %ebx, 0x10(%rsp)
subl %ebx, 0x40(%r12)
movl 0x14(%rsp), %ebx
movl %ebx, %eax
xorb $0x1, %al
orb %r13b, %al
orb %bpl, %al
movl %eax, %ebp
cmpb $0x1, %al
jne 0x808b
cmpq $0x0, 0x58(%r14)
je 0x808b
leaq 0x216f4(%rip), %r13     # 0x29769
movb $0x0, (%r13)
movq 0x30(%r15), %rsi
movq %r15, %rdi
callq 0xa721
movb $0x1, (%r13)
cmpq $0x0, 0x58(%r14)
je 0x80a0
movq 0x68(%r14), %rax
movq %r15, 0x48(%rax)
movq %rax, 0x40(%r15)
jmp 0x80a8
movq %r15, 0x58(%r14)
movq %r15, 0x60(%r14)
movl 0x10(%rsp), %r13d
movq %r15, 0x68(%r14)
addl %r13d, 0x40(%r14)
movq %r15, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xd60c
cmpq %r15, 0x20(%rsp)
je 0x80e6
testl %r13d, %r13d
je 0x813f
movq 0x58(%r12), %rcx
testq %rcx, %rcx
je 0x8124
movq 0x30(%r15), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
jmp 0x813a
testb %bl, %bl
je 0x8184
movq %r12, %rdi
xorl %esi, %esi
callq 0x7be8
testb %al, %al
movq 0x18(%rsp), %rbx
je 0x8110
movq 0x58(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x9af5
cmpq %r12, %rbx
jne 0x80c8
movq 0x38(%r15), %rdx
movq %r14, %rdi
movq %r15, %rsi
jmp 0x821d
movq 0x58(%r14), %rcx
cmpq %r15, %rcx
je 0x813f
movq 0x30(%r15), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9dd4
leaq 0x4c(%r12), %rdi
leaq 0x4c(%r14), %rsi
movq 0x30(%r15), %rdx
callq 0x6df4
movq %r14, %rdi
movq %r15, %rsi
callq 0x8a5c
testb %bpl, %bpl
je 0x81c0
cmpq %r15, 0x58(%r14)
jne 0x81c0
movq 0x38(%r15), %rdx
leaq 0x2159e(%rip), %rax     # 0x29710
cmpq %r14, (%rax)
je 0x81b5
movq %r14, %rdi
movq %r15, %rsi
callq 0x9af5
jmp 0x81c0
cmpq %r12, 0x18(%rsp)
je 0x8213
movq %r12, %rdi
xorl %esi, %esi
callq 0x7be8
testb %al, %al
je 0x80c8
movq 0x58(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x9af5
jmp 0x80c8
movq %r14, %rdi
movq %r15, %rsi
callq 0xa2cd
callq 0x1e003
callq 0x1e0b4
callq 0x1e17a
callq 0x1df11
movl 0x20(%r12), %edx
movl 0x20(%r15), %ecx
movl 0x20(%r14), %r8d
leaq 0x17354(%rip), %rsi     # 0x1f53c
movl $0x800, %edi            # imm = 0x800
xorl %eax, %eax
callq 0x1eb0b
movl $0x1, %edi
xorl %eax, %eax
callq 0x1eb0b
movb 0xf(%rsp), %al
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x58(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0xa2cd
jmp 0x80c8