// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/tree.c
// Function: unlink_node
void unlink_node(monitor_t *m, desktop_t *d, node_t *n)
{
	if (d == NULL || n == NULL) {
		return;
	}

	node_t *p = n->parent;

	if (p == NULL) {
		d->root = NULL;
		d->focus = NULL;
		put_status(SBSC_MASK_REPORT);
	} else {
		if (d->focus == p || is_descendant(d->focus, n)) {
			d->focus = NULL;
		}

		history_remove(d, p, false);
		cancel_presel(m, d, p);

		if (p->sticky) {
			m->sticky_count--;
		}

		node_t *b = brother_tree(n);
		node_t *g = p->parent;

		b->parent = g;

		if (g != NULL) {
			if (is_first_child(p)) {
				g->first_child = b;
			} else {
				g->second_child = b;
			}
		} else {
			d->root = b;
		}

		if (!n->vacant && removal_adjustment) {
			if (automatic_scheme == SCHEME_SPIRAL) {
				if (is_first_child(n)) {
					rotate_tree(b, 270);
				} else {
					rotate_tree(b, 90);
				}
			} else if (automatic_scheme == SCHEME_LONGEST_SIDE || g == NULL) {
				if (p != NULL) {
					if (p->rectangle.width > p->rectangle.height) {
						b->split_type = TYPE_VERTICAL;
					} else {
						b->split_type = TYPE_HORIZONTAL;
					}
				}
			} else if (automatic_scheme == SCHEME_ALTERNATE) {
				if (g->split_type == TYPE_HORIZONTAL) {
					b->split_type = TYPE_VERTICAL;
				} else {
					b->split_type = TYPE_HORIZONTAL;
				}
			}
		}

		free(p);
		n->parent = NULL;

		propagate_flags_upward(m, d, b);
	}
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
testq %rsi, %rsi
sete %al
testq %rdx, %rdx
sete %cl
orb %al, %cl
je 0xb668
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rdx, %r14
movq %rsi, %rbx
movq 0x40(%rdx), %r12
testq %r12, %r12
je 0xb6e7
movq %rdi, %r15
movq 0x38(%rbx), %rax
cmpq %r12, %rax
je 0xb6a0
testq %rax, %rax
je 0xb6a8
cmpq %r14, %rax
je 0xb69b
movq 0x40(%rax), %rax
cmpq %r14, %rax
je 0xb69b
testq %rax, %rax
jne 0xb68d
cmpq %r14, %rax
jne 0xb6a8
movq $0x0, 0x38(%rbx)
movq %rbx, %rdi
movq %r12, %rsi
xorl %edx, %edx
callq 0xd60c
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x9188
cmpb $0x1, 0x26(%r12)
jne 0xb6cf
decl 0x40(%r15)
movq 0x40(%r14), %rax
testq %rax, %rax
je 0xb703
movq 0x30(%rax), %r13
cmpq %r14, %r13
jne 0xb706
movq 0x38(%rax), %r13
jmp 0xb706
xorps %xmm0, %xmm0
movups %xmm0, 0x30(%rbx)
movl $0x1, %edi
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x1eb0b
xorl %r13d, %r13d
movq 0x40(%r12), %rax
movq %rax, 0x40(%r13)
testq %rax, %rax
je 0xb72a
movq 0x40(%r12), %rcx
testq %rcx, %rcx
je 0xb724
cmpq %r12, 0x30(%rcx)
je 0xb730
leaq 0x38(%rax), %rcx
jmp 0xb734
leaq 0x30(%rbx), %rcx
jmp 0xb734
leaq 0x30(%rax), %rcx
movq %r13, (%rcx)
cmpb $0x0, 0x24(%r14)
jne 0xb7bc
leaq 0x1e693(%rip), %rcx     # 0x29dd8
cmpb $0x1, (%rcx)
jne 0xb7bc
leaq 0x1e683(%rip), %rcx     # 0x29dd4
movl (%rcx), %ecx
cmpl $0x2, %ecx
jne 0xb771
movq 0x40(%r14), %rax
testq %rax, %rax
je 0xb767
cmpq %r14, 0x30(%rax)
je 0xb7af
movq %r13, %rdi
movl $0x5a, %esi
jmp 0xb7b7
testq %rax, %rax
setne %dl
testl %ecx, %ecx
setne %sil
testb %sil, %dl
jne 0xb79a
movzwl 0x1c(%r12), %eax
cmpw 0x1e(%r12), %ax
jbe 0xb7a5
movl $0x1, 0x4(%r13)
jmp 0xb7bc
cmpl $0x1, %ecx
jne 0xb7bc
cmpl $0x0, 0x4(%rax)
je 0xb790
movl $0x0, 0x4(%r13)
jmp 0xb7bc
movq %r13, %rdi
movl $0x10e, %esi            # imm = 0x10E
callq 0x991d
movq %r12, %rdi
callq 0x4460
movq $0x0, 0x40(%r14)
movq %r15, %rdi
movq %rbx, %rsi
movq %r13, %rdx
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x99a5