// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/tree.c
// Function: swap_nodes
bool swap_nodes(monitor_t *m1, desktop_t *d1, node_t *n1, monitor_t *m2, desktop_t *d2, node_t *n2, bool follow)
{
	if (n1 == NULL || n2 == NULL || n1 == n2 || is_descendant(n1, n2) || is_descendant(n2, n1) ||
	    (d1 != d2 && ((m1->sticky_count > 0 && sticky_count(n1) > 0) ||
	                  (m2->sticky_count > 0 && sticky_count(n2) > 0)))) {
		return false;
	}

	put_status(SBSC_MASK_NODE_SWAP, "node_swap 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X 0x%08X\n", m1->id, d1->id, n1->id, m2->id, d2->id, n2->id);

	node_t *pn1 = n1->parent;
	node_t *pn2 = n2->parent;
	bool n1_first_child = is_first_child(n1);
	bool n2_first_child = is_first_child(n2);
	bool n1_held_focus = is_descendant(d1->focus, n1);
	bool n2_held_focus = is_descendant(d2->focus, n2);
	node_t *last_d1_focus = d1->focus;
	node_t *last_d2_focus = d2->focus;

	if (pn1 != NULL) {
		if (n1_first_child) {
			pn1->first_child = n2;
		} else {
			pn1->second_child = n2;
		}
	}

	if (pn2 != NULL) {
		if (n2_first_child) {
			pn2->first_child = n1;
		} else {
			pn2->second_child = n1;
		}
	}

	n1->parent = pn2;
	n2->parent = pn1;

	propagate_flags_upward(m2, d2, n1);
	propagate_flags_upward(m1, d1, n2);

	if (d1 != d2) {
		if (d1->root == n1) {
			d1->root = n2;
		}

		if (d2->root == n2) {
			d2->root = n1;
		}

		if (n1_held_focus) {
			d1->focus = n2_held_focus ? last_d2_focus : n2;
		}

		if (n2_held_focus) {
			d2->focus = n1_held_focus ? last_d1_focus : n1;
		}

		if (m1 != m2) {
			adapt_geometry(&m2->rectangle, &m1->rectangle, n2);
			adapt_geometry(&m1->rectangle, &m2->rectangle, n1);
		}

		ewmh_set_wm_desktop(n1, d2);
		ewmh_set_wm_desktop(n2, d1);

		history_remove(d1, n1, true);
		history_remove(d2, n2, true);

		bool d1_was_focused = (d1 == mon->desk);
		bool d2_was_focused = (d2 == mon->desk);

		if (m1->desk != d1 && m2->desk == d2) {
			show_node(d2, n1);
			if (!follow || !d2_was_focused || !n2_held_focus) {
				hide_node(d2, n2);
			}
		} else if (m1->desk == d1 && m2->desk != d2) {
			if (!follow || !d1_was_focused || !n1_held_focus) {
				hide_node(d1, n1);
			}
			show_node(d1, n2);
		}

		if (single_monocle) {
			layout_t l1 = tiled_count(d1->root, true) <= 1 ? LAYOUT_MONOCLE : d1->user_layout;
			layout_t l2 = tiled_count(d2->root, true) <= 1 ? LAYOUT_MONOCLE : d2->user_layout;
			set_layout(m1, d1, l1, false);
			set_layout(m2, d2, l2, false);
		}

		if (n1_held_focus) {
			if (d1_was_focused) {
				if (follow) {
					focus_node(m2, d2, last_d1_focus);
				} else {
					focus_node(m1, d1, d1->focus);
				}
			} else {
				activate_node(m1, d1, d1->focus);
			}
		} else {
			draw_border(n2, is_descendant(n2, d1->focus), (m1 == mon));
		}

		if (n2_held_focus) {
			if (d2_was_focused) {
				if (follow) {
					focus_node(m1, d1, last_d2_focus);
				} else {
					focus_node(m2, d2, d2->focus);
				}
			} else {
				activate_node(m2, d2, d2->focus);
			}
		} else {
			draw_border(n1, is_descendant(n1, d2->focus), (m2 == mon));
		}
	} else {
		if (!n1_held_focus) {
			draw_border(n1, is_descendant(n1, d2->focus), (m2 == mon));
		}
		if (!n2_held_focus) {
			draw_border(n2, is_descendant(n2, d1->focus), (m1 == mon));
		}
	}

	arrange(m1, d1);

	if (d1 != d2) {
		arrange(m2, d2);
	} else {
		if (pointer_follows_focus && (n1_held_focus || n2_held_focus)) {
			center_pointer(get_rectangle(m1, d1, d1->focus));
		}
	}

	return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb 0x10(%rbp), %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
andb $0x1, %al
movb %al, -0x39(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0xfdef
cmpq $0x0, -0x38(%rbp)
je 0xfdef
movq -0x20(%rbp), %rax
cmpq -0x38(%rbp), %rax
je 0xfdef
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xd040
testb $0x1, %al
jne 0xfdef
movq -0x38(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xd040
testb $0x1, %al
jne 0xfdef
movq -0x18(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0xfdf8
movq -0x10(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jbe 0xfdd7
movq -0x20(%rbp), %rdi
callq 0xfc80
cmpl $0x0, %eax
ja 0xfdef
movq -0x28(%rbp), %rax
cmpl $0x0, 0x40(%rax)
jbe 0xfdf8
movq -0x38(%rbp), %rdi
callq 0xfc80
cmpl $0x0, %eax
jbe 0xfdf8
movb $0x0, -0x1(%rbp)
jmp 0x1040f
movq -0x10(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x18(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x20(%rbp), %rax
movl (%rax), %r8d
movq -0x28(%rbp), %rax
movl 0x20(%rax), %r9d
movq -0x30(%rbp), %rax
movl 0x20(%rax), %r10d
movq -0x38(%rbp), %rax
movl (%rax), %eax
movl $0x20000, %edi          # imm = 0x20000
leaq 0x1db0c(%rip), %rsi     # 0x2d93b
movl %r10d, (%rsp)
movl %eax, 0x8(%rsp)
movb $0x0, %al
callq 0x2c0b0
movq -0x20(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x38(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x20(%rbp), %rdi
callq 0xc6b0
andb $0x1, %al
movb %al, -0x51(%rbp)
movq -0x38(%rbp), %rdi
callq 0xc6b0
andb $0x1, %al
movb %al, -0x52(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x20(%rbp), %rsi
callq 0xd040
andb $0x1, %al
movb %al, -0x53(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0xd040
andb $0x1, %al
movb %al, -0x54(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x60(%rbp)
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0xfedf
testb $0x1, -0x51(%rbp)
je 0xfed1
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xfedd
movq -0x38(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0xfedf
cmpq $0x0, -0x50(%rbp)
je 0xff08
testb $0x1, -0x52(%rbp)
je 0xfefa
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0xff06
movq -0x20(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, 0x38(%rax)
jmp 0xff08
movq -0x50(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x48(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x40(%rax)
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xca80
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xca80
movq -0x18(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x1030d
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0xff6a
movq -0x38(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x30(%rax)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rax
cmpq -0x38(%rbp), %rax
jne 0xff84
movq -0x20(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x30(%rax)
testb $0x1, -0x53(%rbp)
je 0xffb7
testb $0x1, -0x54(%rbp)
je 0xff9d
movq -0x68(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0xffa8
movq -0x38(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
testb $0x1, -0x54(%rbp)
je 0xffea
testb $0x1, -0x53(%rbp)
je 0xffd0
movq -0x60(%rbp), %rax
movq %rax, -0x90(%rbp)
jmp 0xffdb
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0x10026
movq -0x28(%rbp), %rdi
addq $0x4c, %rdi
movq -0x10(%rbp), %rsi
addq $0x4c, %rsi
movq -0x38(%rbp), %rdx
callq 0x82c0
movq -0x10(%rbp), %rdi
addq $0x4c, %rdi
movq -0x28(%rbp), %rsi
addq $0x4c, %rsi
movq -0x20(%rbp), %rdx
callq 0x82c0
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x2aeb0
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x2aeb0
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl $0x1, %edx
callq 0x12710
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movl $0x1, %edx
callq 0x12710
movq -0x18(%rbp), %rax
leaq 0x25691(%rip), %rcx     # 0x35700
movq (%rcx), %rcx
cmpq 0x58(%rcx), %rax
sete %al
andb $0x1, %al
movb %al, -0x69(%rbp)
movq -0x30(%rbp), %rax
leaq 0x25677(%rip), %rcx     # 0x35700
movq (%rcx), %rcx
cmpq 0x58(%rcx), %rax
sete %al
andb $0x1, %al
movb %al, -0x6a(%rbp)
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0x100e2
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0x100e2
movq -0x30(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xde40
testb $0x1, -0x39(%rbp)
je 0x100d3
testb $0x1, -0x6a(%rbp)
je 0x100d3
testb $0x1, -0x54(%rbp)
jne 0x100e0
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xdd80
jmp 0x1012c
movq -0x10(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x1012a
movq -0x28(%rbp), %rax
movq 0x58(%rax), %rax
cmpq -0x30(%rbp), %rax
je 0x1012a
testb $0x1, -0x39(%rbp)
je 0x10110
testb $0x1, -0x69(%rbp)
je 0x10110
testb $0x1, -0x53(%rbp)
jne 0x1011d
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xdd80
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0xde40
jmp 0x1012c
leaq 0x25cb5(%rip), %rax     # 0x35de8
testb $0x1, (%rax)
je 0x101d4
movq -0x18(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0xc8d0
cmpl $0x1, %eax
jg 0x10160
movl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x1016d
movq -0x18(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %eax
movl %eax, -0x70(%rbp)
movq -0x30(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0xc8d0
cmpl $0x1, %eax
jg 0x1019a
movl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x101a7
movq -0x30(%rbp), %rax
movl 0x28(%rax), %eax
movl %eax, -0x98(%rbp)
movl -0x98(%rbp), %eax
movl %eax, -0x74(%rbp)
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movl -0x70(%rbp), %edx
xorl %ecx, %ecx
callq 0x9e80
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x74(%rbp), %edx
xorl %ecx, %ecx
callq 0x9e80
testb $0x1, -0x53(%rbp)
je 0x10227
testb $0x1, -0x69(%rbp)
je 0x10210
testb $0x1, -0x39(%rbp)
je 0x101f9
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0xd720
jmp 0x1020e
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdx
callq 0xd720
jmp 0x10225
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdx
callq 0xccb0
jmp 0x1026e
movq -0x38(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xd040
movq -0xa0(%rbp), %rdi
movb %al, %cl
movq -0x10(%rbp), %rax
leaq 0x254a9(%rip), %rdx     # 0x35700
cmpq (%rdx), %rax
sete %al
movzbl %cl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
callq 0x167c0
testb $0x1, -0x54(%rbp)
je 0x102c1
testb $0x1, -0x6a(%rbp)
je 0x102aa
testb $0x1, -0x39(%rbp)
je 0x10293
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0xd720
jmp 0x102a8
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdx
callq 0xd720
jmp 0x102bf
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rdx
callq 0xccb0
jmp 0x10308
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xd040
movq -0xa8(%rbp), %rdi
movb %al, %cl
movq -0x28(%rbp), %rax
leaq 0x2540f(%rip), %rdx     # 0x35700
cmpq (%rdx), %rax
sete %al
movzbl %cl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
callq 0x167c0
jmp 0x103a9
testb $0x1, -0x53(%rbp)
jne 0x1035a
movq -0x20(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xd040
movq -0xb0(%rbp), %rdi
movb %al, %cl
movq -0x28(%rbp), %rax
leaq 0x253bd(%rip), %rdx     # 0x35700
cmpq (%rdx), %rax
sete %al
movzbl %cl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
callq 0x167c0
testb $0x1, -0x54(%rbp)
jne 0x103a7
movq -0x38(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0xd040
movq -0xb8(%rbp), %rdi
movb %al, %cl
movq -0x10(%rbp), %rax
leaq 0x25370(%rip), %rdx     # 0x35700
cmpq (%rdx), %rax
sete %al
movzbl %cl, %esi
andl $0x1, %esi
movzbl %al, %edx
andl $0x1, %edx
callq 0x167c0
jmp 0x103a9
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xafd0
movq -0x18(%rbp), %rax
cmpq -0x30(%rbp), %rax
je 0x103cf
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0xafd0
jmp 0x1040b
leaq 0x25a15(%rip), %rax     # 0x35deb
testb $0x1, (%rax)
je 0x10409
testb $0x1, -0x53(%rbp)
jne 0x103e7
testb $0x1, -0x54(%rbp)
je 0x10409
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdx
callq 0xc7f0
movq %rax, -0x7c(%rbp)
movq -0x7c(%rbp), %rdi
callq 0x18a20
jmp 0x1040b
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xd0, %rsp
popq %rbp
retq
nopl (%rax)