// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/history.c
// Function: history_add
void history_add(monitor_t *m, desktop_t *d, node_t *n, bool focused)
{
	if (!record_history) {
		return;
	}

	if (focused) {
		history_needle = NULL;
	}

	history_t *h = make_history(m, d, n);

	if (history_head == NULL) {
		history_head = history_tail = h;
	} else if ((n != NULL && history_tail->loc.node != n) || (n == NULL && d != history_tail->loc.desktop)) {
		history_t *ip = focused ? history_tail : NULL;

		for (history_t *hh = history_tail; hh != NULL; hh = hh->prev) {
			if ((n != NULL && hh->loc.node == n) || (n == NULL && d == hh->loc.desktop)) {
				hh->latest = false;
			}
			if (ip == NULL && ((n != NULL && hh->loc.desktop == d) || (n == NULL && hh->loc.monitor == m))) {
				ip = hh;
			}
		}

		if (ip != NULL) {
			history_insert_after(h, ip);
		} else {
			ip = history_head;
			if (n != NULL) {
				for (history_t *hh = history_head; hh != NULL; hh = hh->next) {
					if (hh->latest && hh->loc.monitor == m) {
						ip = hh;
						break;
					}
				}
			}
			history_insert_before(h, ip);
		}
	} else {
		free(h);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movb %cl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
leaq 0x23316(%rip), %rax     # 0x35758
testb $0x1, (%rax)
jne 0x1244c
jmp 0x12622
testb $0x1, -0x19(%rbp)
je 0x12460
leaq 0x232af(%rip), %rax     # 0x35708
movq $0x0, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x12390
movq %rax, -0x28(%rbp)
leaq 0x2329c(%rip), %rax     # 0x35718
cmpq $0x0, (%rax)
jne 0x1249f
movq -0x28(%rbp), %rcx
leaq 0x23283(%rip), %rax     # 0x35710
movq %rcx, (%rax)
leaq 0x23281(%rip), %rax     # 0x35718
movq %rcx, (%rax)
jmp 0x12622
cmpq $0x0, -0x18(%rbp)
je 0x124ba
leaq 0x23263(%rip), %rax     # 0x35710
movq (%rax), %rax
movq 0x10(%rax), %rax
cmpq -0x18(%rbp), %rax
jne 0x124dd
cmpq $0x0, -0x18(%rbp)
jne 0x12617
movq -0x10(%rbp), %rax
leaq 0x23240(%rip), %rcx     # 0x35710
movq (%rcx), %rcx
cmpq 0x8(%rcx), %rax
je 0x12617
testb $0x1, -0x19(%rbp)
je 0x124f3
leaq 0x23226(%rip), %rax     # 0x35710
movq (%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x124fb
xorl %eax, %eax
movq %rax, -0x48(%rbp)
jmp 0x124fb
movq -0x48(%rbp), %rax
movq %rax, -0x30(%rbp)
leaq 0x23206(%rip), %rax     # 0x35710
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x12595
cmpq $0x0, -0x18(%rbp)
je 0x1252d
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
cmpq -0x18(%rbp), %rax
je 0x12542
cmpq $0x0, -0x18(%rbp)
jne 0x1254a
movq -0x10(%rbp), %rax
movq -0x38(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1254a
movq -0x38(%rbp), %rax
movb $0x0, 0x18(%rax)
cmpq $0x0, -0x30(%rbp)
jne 0x12582
cmpq $0x0, -0x18(%rbp)
je 0x12566
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
cmpq -0x10(%rbp), %rax
je 0x1257a
cmpq $0x0, -0x18(%rbp)
jne 0x12582
movq -0x38(%rbp), %rax
movq (%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x12582
movq -0x38(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x12584
movq -0x38(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x12511
cmpq $0x0, -0x30(%rbp)
je 0x125ab
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x12630
jmp 0x12615
leaq 0x23166(%rip), %rax     # 0x35718
movq (%rax), %rax
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x12608
leaq 0x23151(%rip), %rax     # 0x35718
movq (%rax), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x12606
movq -0x40(%rbp), %rax
testb $0x1, 0x18(%rax)
je 0x125f6
movq -0x40(%rbp), %rax
movq (%rax), %rax
cmpq -0x8(%rbp), %rax
jne 0x125f6
movq -0x40(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x12606
jmp 0x125f8
movq -0x40(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x40(%rbp)
jmp 0x125ce
jmp 0x12608
movq -0x28(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x126a0
jmp 0x12620
movq -0x28(%rbp), %rdi
callq 0x4450
jmp 0x12622
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)