// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/history.c
// Function: history_remove
void history_remove(desktop_t *d, node_t *n, bool deep)
{
	/* removing from the newest to the oldest is required */
	/* for maintaining the *latest* attribute */
	history_t *b = history_tail;
	while (b != NULL) {
		if ((n != NULL && ((deep && is_descendant(b->loc.node, n)) || (!deep && b->loc.node == n))) ||
		    (n == NULL && d == b->loc.desktop)) {
			history_t *a = b->next;
			history_t *c = b->prev;
			if (a != NULL) {
				/* remove duplicate entries */
				while (c != NULL && ((a->loc.node != NULL && a->loc.node == c->loc.node) ||
				       (a->loc.node == NULL && a->loc.desktop == c->loc.desktop))) {
					history_t *p = c->prev;
					if (history_head == c) {
						history_head = history_tail;
					}
					if (history_needle == c) {
						history_needle = history_tail;
					}
					free(c);
					c = p;
				}
				a->prev = c;
			}
			if (c != NULL) {
				c->next = a;
			}
			if (history_tail == b) {
				history_tail = c;
			}
			if (history_head == b) {
				history_head = a;
			}
			if (history_needle == b) {
				history_needle = c;
			}
			free(b);
			b = c;
		} else {
			b = b->prev;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq 0x22fe2(%rip), %rax     # 0x35710
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x12928
cmpq $0x0, -0x10(%rbp)
je 0x12776
testb $0x1, -0x11(%rbp)
je 0x12762
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xd040
testb $0x1, %al
jne 0x12793
testb $0x1, -0x11(%rbp)
jne 0x12776
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x10(%rbp), %rax
je 0x12793
cmpq $0x0, -0x10(%rbp)
jne 0x12917
movq -0x8(%rbp), %rax
movq -0x20(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x12917
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x12897
jmp 0x127b8
xorl %eax, %eax
cmpq $0x0, -0x30(%rbp)
movb %al, -0x39(%rbp)
je 0x12818
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x127e6
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x30(%rbp), %rdx
movb $0x1, %al
cmpq 0x10(%rdx), %rcx
movb %al, -0x3a(%rbp)
je 0x12812
movq -0x28(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x10(%rcx)
movb %al, -0x3b(%rbp)
jne 0x1280c
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
sete %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x12821
jmp 0x1288b
movq -0x30(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
leaq 0x22ee4(%rip), %rax     # 0x35718
movq (%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0x12851
leaq 0x22ecc(%rip), %rax     # 0x35710
movq (%rax), %rcx
leaq 0x22eca(%rip), %rax     # 0x35718
movq %rcx, (%rax)
leaq 0x22eb0(%rip), %rax     # 0x35708
movq (%rax), %rax
cmpq -0x30(%rbp), %rax
jne 0x12875
leaq 0x22ea8(%rip), %rax     # 0x35710
movq (%rax), %rcx
leaq 0x22e96(%rip), %rax     # 0x35708
movq %rcx, (%rax)
movq -0x30(%rbp), %rdi
callq 0x4450
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x127b8
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, -0x30(%rbp)
je 0x128aa
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, 0x28(%rax)
leaq 0x22e5f(%rip), %rax     # 0x35710
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x128c8
movq -0x30(%rbp), %rcx
leaq 0x22e4b(%rip), %rax     # 0x35710
movq %rcx, (%rax)
leaq 0x22e49(%rip), %rax     # 0x35718
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x128e6
movq -0x28(%rbp), %rcx
leaq 0x22e35(%rip), %rax     # 0x35718
movq %rcx, (%rax)
leaq 0x22e1b(%rip), %rax     # 0x35708
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
jne 0x12904
movq -0x30(%rbp), %rcx
leaq 0x22e07(%rip), %rax     # 0x35708
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x4450
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
jmp 0x12923
movq -0x20(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x20(%rbp)
jmp 0x12735
addq $0x40, %rsp
popq %rbp
retq
nop