// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/tree.c
// Function: circulate_leaves
void circulate_leaves(monitor_t *m, desktop_t *d, node_t *n, circulate_dir_t dir)
{
	if (tiled_count(n, false) < 2) {
		return;
	}
	node_t *p = d->focus->parent;
	bool focus_first_child = is_first_child(d->focus);
	if (dir == CIRCULATE_FORWARD) {
		node_t *e = second_extrema(n);
		while (e != NULL && (e->client == NULL || !IS_TILED(e->client))) {
			e = prev_leaf(e, n);
		}
		for (node_t *s = e, *f = prev_tiled_leaf(s, n); f != NULL; s = prev_tiled_leaf(f, n), f = prev_tiled_leaf(s, n)) {
			swap_nodes(m, d, f, m, d, s, false);
		}
	} else {
		node_t *e = first_extrema(n);
		while (e != NULL && (e->client == NULL || !IS_TILED(e->client))) {
			e = next_leaf(e, n);
		}
		for (node_t *f = e, *s = next_tiled_leaf(f, n); s != NULL; f = next_tiled_leaf(s, n), s = next_tiled_leaf(f, n)) {
			swap_nodes(m, d, f, m, d, s, false);
		}
	}
	if (p != NULL) {
		node_t *f = focus_first_child ? p->first_child : p->second_child;
		if (is_leaf(f)) {
			if (d == mon->desk) {
				focus_node(m, d, f);
			} else {
				activate_node(m, d, f);
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0xc8d0
cmpl $0x2, %eax
jge 0x107df
jmp 0x10a5c
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0xc6b0
andb $0x1, %al
movb %al, -0x29(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x108f8
movq -0x18(%rbp), %rdi
callq 0xe5f0
movq %rax, -0x38(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x38(%rbp)
movb %al, -0x69(%rbp)
je 0x1086d
movq -0x38(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x48(%rcx)
movb %al, -0x6a(%rbp)
je 0x10867
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rcx
movb $0x1, %al
cmpl $0x0, 0x308(%rcx)
movb %al, -0x6b(%rbp)
je 0x1085f
movq -0x38(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x1, 0x308(%rax)
sete %al
movb %al, -0x6b(%rbp)
movb -0x6b(%rbp), %al
xorb $-0x1, %al
movb %al, -0x6a(%rbp)
movb -0x6a(%rbp), %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x10876
jmp 0x10889
movq -0x38(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe760
movq %rax, -0x38(%rbp)
jmp 0x10818
movq -0x38(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe870
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x108f3
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x40(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0xfd50
movq -0x48(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe870
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe870
movq %rax, -0x48(%rbp)
jmp 0x108a2
jmp 0x109e2
movq -0x18(%rbp), %rdi
callq 0xbe70
movq %rax, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x50(%rbp)
movb %al, -0x6c(%rbp)
je 0x1095a
movq -0x50(%rbp), %rcx
movb $0x1, %al
cmpq $0x0, 0x48(%rcx)
movb %al, -0x6d(%rbp)
je 0x10954
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rcx
movb $0x1, %al
cmpl $0x0, 0x308(%rcx)
movb %al, -0x6e(%rbp)
je 0x1094c
movq -0x50(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x1, 0x308(%rax)
sete %al
movb %al, -0x6e(%rbp)
movb -0x6e(%rbp), %al
xorb $-0x1, %al
movb %al, -0x6d(%rbp)
movb -0x6d(%rbp), %al
movb %al, -0x6c(%rbp)
movb -0x6c(%rbp), %al
testb $0x1, %al
jne 0x10963
jmp 0x10976
movq -0x50(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xbf80
movq %rax, -0x50(%rbp)
jmp 0x10905
movq -0x50(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe800
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x109e0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x58(%rbp), %rdx
movq -0x8(%rbp), %rcx
movq -0x10(%rbp), %r8
movq -0x60(%rbp), %r9
xorl %eax, %eax
movl $0x0, (%rsp)
callq 0xfd50
movq -0x60(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe800
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xe800
movq %rax, -0x60(%rbp)
jmp 0x1098f
jmp 0x109e2
cmpq $0x0, -0x28(%rbp)
je 0x10a5c
testb $0x1, -0x29(%rbp)
je 0x109fd
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x78(%rbp)
jmp 0x10a09
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rdi
callq 0xb870
testb $0x1, %al
jne 0x10a20
jmp 0x10a5a
movq -0x10(%rbp), %rax
leaq 0x24cd5(%rip), %rcx     # 0x35700
movq (%rcx), %rcx
cmpq 0x58(%rcx), %rax
jne 0x10a47
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0xd720
jmp 0x10a58
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x68(%rbp), %rdx
callq 0xccb0
jmp 0x10a5a
jmp 0x10a5c
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)