// File: /workspace/github_c_makefile_star2_O3/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 0x80a9
movq %rdi, %r12
movl %ecx, 0x14(%rsp)
movb %al, 0xf(%rsp)
movq 0x58(%rdi), %r13
cmpq %r15, %r13
setne %dl
leaq 0x2185f(%rip), %rcx     # 0x29710
cmpl $0x0, 0x40(%rdi)
movq (%rcx), %rbx
sete %cl
xorl %eax, %eax
orb %dl, %cl
jne 0x7eca
movq 0x30(%r15), %rdi
callq 0xba68
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 0x80cc
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 0x7f30
cmpq $0x0, 0x58(%r14)
je 0x7f30
leaq 0x2184f(%rip), %r13     # 0x29769
movb $0x0, (%r13)
movq 0x30(%r15), %rsi
movq %r15, %rdi
callq 0xa781
movb $0x1, (%r13)
cmpq $0x0, 0x58(%r14)
je 0x7f45
movq 0x68(%r14), %rax
movq %r15, 0x48(%rax)
movq %rax, 0x40(%r15)
jmp 0x7f4d
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 0xd6b9
cmpq %r15, 0x20(%rsp)
je 0x7f8b
testl %r13d, %r13d
je 0x7fe4
movq 0x58(%r12), %rcx
testq %rcx, %rcx
je 0x7fc9
movq 0x30(%r15), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
jmp 0x7fdf
testb %bl, %bl
je 0x8029
movq %r12, %rdi
xorl %esi, %esi
callq 0x7ab4
testb %al, %al
movq 0x18(%rsp), %rbx
je 0x7fb5
movq 0x58(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x9a3d
cmpq %r12, %rbx
jne 0x7f6d
movq 0x38(%r15), %rdx
movq %r14, %rdi
movq %r15, %rsi
jmp 0x80c2
movq 0x58(%r14), %rcx
cmpq %r15, %rcx
je 0x7fe4
movq 0x30(%r15), %r8
movq %r14, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x9de8
leaq 0x4c(%r12), %rdi
leaq 0x4c(%r14), %rsi
movq 0x30(%r15), %rdx
callq 0x6d15
movq %r14, %rdi
movq %r15, %rsi
callq 0x8958
testb %bpl, %bpl
je 0x8065
cmpq %r15, 0x58(%r14)
jne 0x8065
movq 0x38(%r15), %rdx
leaq 0x216f9(%rip), %rax     # 0x29710
cmpq %r14, (%rax)
je 0x805a
movq %r14, %rdi
movq %r15, %rsi
callq 0x9a3d
jmp 0x8065
cmpq %r12, 0x18(%rsp)
je 0x80b8
movq %r12, %rdi
xorl %esi, %esi
callq 0x7ab4
testb %al, %al
je 0x7f6d
movq 0x58(%r12), %rsi
movq %r12, %rdi
xorl %edx, %edx
callq 0x9a3d
jmp 0x7f6d
movq %r14, %rdi
movq %r15, %rsi
callq 0xa308
callq 0x1dc3b
callq 0x1dcd6
callq 0x1dd9c
callq 0x1db67
movl 0x20(%r12), %edx
movl 0x20(%r15), %ecx
movl 0x20(%r14), %r8d
leaq 0x1749f(%rip), %rsi     # 0x1f52c
movl $0x800, %edi            # imm = 0x800
xorl %eax, %eax
callq 0x1e6b8
movl $0x1, %edi
xorl %eax, %eax
callq 0x1e6b8
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 0xa308
jmp 0x7f6d