// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/tree.c
// Function: transfer_node
bool transfer_node(monitor_t *ms, desktop_t *ds, node_t *ns, monitor_t *md, desktop_t *dd, node_t *nd, bool follow)
{
	if (ns == NULL || ns == nd || is_child(ns, nd) || is_descendant(nd, ns)) {
		return false;
	}

	unsigned int sc = (ms->sticky_count > 0 && ds == ms->desk) ? sticky_count(ns) : 0;
	if (sticky_still && sc > 0 && dd != md->desk) {
		return false;
	}

	put_status(SBSC_MASK_NODE_TRANSFER, "node_transfer 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", ms->id, ds->id, ns->id, md->id, dd->id, nd!=NULL?nd->id:0);

	bool held_focus = is_descendant(ds->focus, ns);
	/* avoid ending up with a dangling pointer (because of unlink_node) */
	node_t *last_ds_focus = is_child(ns, ds->focus) ? NULL : ds->focus;
	bool ds_was_focused = (ds == mon->desk);

	if (held_focus && ds_was_focused) {
		clear_input_focus();
	}

	unlink_node(ms, ds, ns);
	insert_node(md, dd, ns, nd);

	if (md != ms) {
		if (ns->client == NULL || monitor_from_client(ns->client) != md) {
			adapt_geometry(&ms->rectangle, &md->rectangle, ns);
		}
		ms->sticky_count -= sc;
		md->sticky_count += sc;
	}

	if (ds != dd) {
		ewmh_set_wm_desktop(ns, dd);
		if (sticky_still) {
			if (ds == ms->desk && dd != md->desk) {
				hide_node(ds, ns);
			} else if (ds != ms->desk && dd == md->desk) {
				show_node(dd, ns);
			}
		}
	}

	history_remove(ds, ns, true);
	stack(dd, ns, false);

	if (ds == dd) {
		if (held_focus) {
			if (ds_was_focused) {
				focus_node(ms, ds, last_ds_focus);
			} else {
				activate_node(ms, ds, last_ds_focus);
			}
		} else {
			draw_border(ns, is_descendant(ns, ds->focus), (ms == mon));
		}
	} else {
		if (single_monocle) {
			if (ds->layout != LAYOUT_MONOCLE && tiled_count(ds->root, true) <= 1) {
				set_layout(ms, ds, LAYOUT_MONOCLE, false);
			}
			if (dd->layout == LAYOUT_MONOCLE && tiled_count(dd->root, true) > 1) {
				set_layout(md, dd, dd->user_layout, false);
			}
		}
		if (held_focus) {
			if (follow) {
				if (ds_was_focused) {
					focus_node(md, dd, last_ds_focus);
				}
				activate_node(ms, ds, ds->focus);
			} else {
				if (ds_was_focused) {
					focus_node(ms, ds, ds->focus);
				} else {
					activate_node(ms, ds, ds->focus);
				}
			}
		}
		if (!held_focus || !follow || !ds_was_focused) {
			if (dd->focus == ns) {
				if (dd == mon->desk) {
					focus_node(md, dd, held_focus ? last_ds_focus : ns);
				} else {
					activate_node(md, dd, held_focus ? last_ds_focus : ns);
				}
			} else {
				draw_border(ns, is_descendant(ns, dd->focus), (md == mon));
			}
		}
	}

	arrange(ms, ds);

	if (ds != dd) {
		arrange(md, dd);
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %r9, %r14
movq %rcx, %r9
testq %rdx, %rdx
sete %al
cmpq %r14, %rdx
sete %cl
orb %al, %cl
je 0x9e89
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r8, %rbx
movq %rdx, %r13
movq %rsi, %r15
movq %rdi, %rbp
testq %r14, %r14
je 0x9ebb
cmpq %r14, 0x40(%r13)
je 0x9e76
testq %r14, %r14
je 0x9ebb
movq %r14, %rax
movq 0x40(%rax), %rax
cmpq %r13, %rax
je 0x9eb6
testq %rax, %rax
jne 0x9ea8
cmpq %r13, %rax
je 0x9e76
xorl %eax, %eax
cmpl $0x0, 0x40(%rbp)
movq %r9, 0x10(%rsp)
je 0x9edb
cmpq %r15, 0x58(%rbp)
jne 0x9edb
movq %r13, %rdi
callq 0xba1f
movq 0x10(%rsp), %r9
leaq 0x1f888(%rip), %rdx     # 0x2976a
testl %eax, %eax
setne %cl
andb (%rdx), %cl
cmpb $0x1, %cl
jne 0x9ef4
cmpq %rbx, 0x58(%r9)
jne 0x9e76
movl 0x20(%rbp), %edx
movl 0x20(%r15), %ecx
movl (%r13), %r8d
movl 0x20(%r9), %r9d
movl 0x20(%rbx), %r10d
testq %r14, %r14
movl %eax, 0x34(%rsp)
je 0x9f15
movl (%r14), %r11d
jmp 0x9f18
xorl %r11d, %r11d
leaq 0x158b5(%rip), %rsi     # 0x1f7d4
movl $0x0, 0x1c(%rsp)
movl $0x40000, %edi          # imm = 0x40000
xorl %eax, %eax
pushq %r11
pushq %r10
callq 0x1eb0b
addq $0x10, %rsp
movq 0x38(%r15), %rcx
testq %rcx, %rcx
je 0x9f67
movq %rcx, %rax
cmpq %r13, %rcx
je 0x9f5d
movq %rcx, %rax
movq 0x40(%rax), %rax
cmpq %r13, %rax
je 0x9f5d
testq %rax, %rax
jne 0x9f4f
cmpq %r13, %rax
sete %al
movl %eax, 0x1c(%rsp)
testq %rcx, %rcx
je 0x9f76
xorl %eax, %eax
cmpq %rcx, 0x40(%r13)
cmoveq %rax, %rcx
movq %rcx, 0x20(%rsp)
movq %rbx, %r12
leaq 0x1f78b(%rip), %rax     # 0x29710
movq (%rax), %rax
movq 0x58(%rax), %rax
movq %rax, 0x28(%rsp)
cmpq %r15, %rax
setne %al
movl 0x1c(%rsp), %ecx
xorb $0x1, %cl
movb %cl, 0xf(%rsp)
orb %cl, %al
jne 0x9fab
callq 0x11504
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0xb645
movq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
movq %r13, %rdx
movq %r14, %rcx
callq 0x93a5
movq %rbp, %r14
cmpq %rbp, %rbx
je 0xa00f
movq 0x48(%r13), %rdi
testq %rdi, %rdi
je 0x9fef
callq 0x7565
movq 0x10(%rsp), %rbx
cmpq %rbx, %rax
je 0xa004
leaq 0x4c(%r14), %rdi
leaq 0x4c(%rbx), %rsi
movq %r13, %rdx
callq 0x6df4
movq 0x10(%rsp), %rbx
movl 0x34(%rsp), %eax
subl %eax, 0x40(%r14)
addl %eax, 0x40(%rbx)
cmpq %r12, %r15
je 0xa04c
movq %r13, %rdi
movq %r12, %rsi
callq 0x1df7b
leaq 0x1f744(%rip), %rax     # 0x2976a
cmpb $0x1, (%rax)
jne 0xa088
movq 0x58(%r14), %rax
cmpq %r15, %rax
je 0xa06e
movq 0x10(%rsp), %rax
cmpq %r12, 0x58(%rax)
jne 0xa088
movq %r12, %rdi
movq %r13, %rsi
callq 0xa798
jmp 0xa088
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xd60c
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd20e
jmp 0xa167
movq 0x10(%rsp), %rcx
cmpq %r12, 0x58(%rcx)
je 0xa2af
movq %r15, %rdi
movq %r13, %rsi
callq 0xa721
movq %r15, %rdi
movq %r13, %rsi
movl $0x1, %edx
callq 0xd60c
movq %r12, %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0xd20e
cmpq %r12, %r15
je 0xa167
leaq 0x1fd43(%rip), %rax     # 0x29df8
cmpb $0x1, (%rax)
movq 0x20(%rsp), %rcx
jne 0xa12f
cmpl $0x1, 0x24(%r15)
je 0xa0f5
movq 0x30(%r15), %rdi
movl $0x1, %esi
callq 0x98c5
movq 0x20(%rsp), %rcx
cmpl $0x1, %eax
jg 0xa0f5
movq %r14, %rdi
movq %r15, %rsi
movl $0x1, %edx
xorl %ecx, %ecx
callq 0x7ec3
movq 0x20(%rsp), %rcx
cmpl $0x1, 0x24(%r12)
jne 0xa12f
movq 0x30(%r12), %rdi
movl $0x1, %esi
callq 0x98c5
movq 0x20(%rsp), %rcx
cmpl $0x2, %eax
jl 0xa12f
movl 0x28(%r12), %edx
movq 0x10(%rsp), %rdi
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x7ec3
movq 0x20(%rsp), %rcx
cmpb $0x0, 0x1c(%rsp)
je 0xa20b
movb 0x70(%rsp), %bpl
testb %bpl, %bpl
je 0xa1d2
cmpq %r15, 0x28(%rsp)
jne 0xa161
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq 0x20(%rsp), %rdx
callq 0xa2cd
movq 0x38(%r15), %rdx
jmp 0xa1e1
cmpb $0x0, 0x1c(%rsp)
je 0xa185
cmpq %r15, 0x28(%rsp)
je 0xa1af
movq %r14, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
jmp 0xa25c
movq 0x38(%r15), %rax
testq %rax, %rax
je 0xa1bf
movq %r13, %rcx
cmpq %r13, %rax
je 0xa1a7
movq %r13, %rcx
movq 0x40(%rcx), %rcx
cmpq %rax, %rcx
je 0xa1a7
testq %rcx, %rcx
jne 0xa199
cmpq %rax, %rcx
sete %al
jmp 0xa1c1
movq %r14, %rdi
movq %r15, %rsi
movq 0x20(%rsp), %rdx
jmp 0xa263
xorl %eax, %eax
xorl %edx, %edx
leaq 0x1f546(%rip), %rcx     # 0x29710
cmpq %r14, (%rcx)
jmp 0xa278
movq 0x38(%r15), %rdx
cmpq %r15, 0x28(%rsp)
je 0xa2bd
movq %r14, %rdi
movq %r15, %rsi
callq 0x9af5
cmpq %r15, 0x28(%rsp)
setne %al
xorb $0x1, %bpl
orb 0xf(%rsp), %bpl
orb %al, %bpl
cmpb $0x1, %bpl
movq 0x20(%rsp), %rcx
jne 0xa286
movq 0x38(%r12), %rax
cmpq %r13, %rax
je 0xa238
testq %rax, %rax
movq 0x10(%rsp), %rsi
je 0xa26a
movq %r13, %rcx
movq 0x40(%rcx), %rcx
cmpq %rax, %rcx
je 0xa230
testq %rcx, %rcx
jne 0xa222
cmpq %rax, %rcx
sete %al
jmp 0xa26c
leaq 0x1f4d1(%rip), %rax     # 0x29710
movq (%rax), %rax
cmpb $0x0, 0x1c(%rsp)
cmovneq %rcx, %r13
cmpq %r12, 0x58(%rax)
movq 0x10(%rsp), %rdi
movq %r12, %rsi
movq %r13, %rdx
je 0xa263
callq 0x9af5
jmp 0xa286
callq 0xa2cd
jmp 0xa286
xorl %eax, %eax
xorl %edx, %edx
leaq 0x1f49b(%rip), %rcx     # 0x29710
cmpq %rsi, (%rcx)
sete %dl
movzbl %al, %esi
movq %r13, %rdi
callq 0xff0c
movq %r14, %rdi
movq %r15, %rsi
callq 0x8a5c
movb $0x1, %bpl
cmpq %r12, %r15
je 0x9e78
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x8a5c
jmp 0x9e78
cmpq %r15, %rax
jne 0xa034
jmp 0xa088
movq %r14, %rdi
movq %r15, %rsi
callq 0xa2cd
jmp 0xa1ec