// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/monitor.c
// Function: update_monitors
bool update_monitors(void)
{
	xcb_randr_get_screen_resources_reply_t *sres = xcb_randr_get_screen_resources_reply(dpy, xcb_randr_get_screen_resources(dpy, root), NULL);
	if (sres == NULL) {
		return false;
	}

	monitor_t *last_wired = NULL;

	int len = xcb_randr_get_screen_resources_outputs_length(sres);
	xcb_randr_output_t *outputs = xcb_randr_get_screen_resources_outputs(sres);

	xcb_randr_get_output_info_cookie_t cookies[len];
	for (int i = 0; i < len; i++) {
		cookies[i] = xcb_randr_get_output_info(dpy, outputs[i], XCB_CURRENT_TIME);
	}

	for (monitor_t *m = mon_head; m != NULL; m = m->next) {
		m->wired = false;
	}

	for (int i = 0; i < len; i++) {
		xcb_randr_get_output_info_reply_t *info = xcb_randr_get_output_info_reply(dpy, cookies[i], NULL);
		if (info != NULL) {
			if (info->crtc != XCB_NONE) {
				xcb_randr_get_crtc_info_reply_t *cir = xcb_randr_get_crtc_info_reply(dpy, xcb_randr_get_crtc_info(dpy, info->crtc, XCB_CURRENT_TIME), NULL);
				if (cir != NULL) {
					xcb_rectangle_t rect = (xcb_rectangle_t) {cir->x, cir->y, cir->width, cir->height};
					last_wired = get_monitor_by_randr_id(outputs[i]);
					if (last_wired != NULL) {
						update_root(last_wired, &rect);
						last_wired->wired = true;
					} else {
						char *name = (char *) xcb_randr_get_output_info_name(info);
						size_t len = (size_t) xcb_randr_get_output_info_name_length(info);
						char *name_copy = copy_string(name, len);
						last_wired = make_monitor(name_copy, &rect, XCB_NONE);
						free(name_copy);
						last_wired->randr_id = outputs[i];
						add_monitor(last_wired);
					}
				}
				free(cir);
			} else if (!remove_disabled_monitors && info->connection != XCB_RANDR_CONNECTION_DISCONNECTED) {
				monitor_t *m = get_monitor_by_randr_id(outputs[i]);
				if (m != NULL) {
					m->wired = true;
				}
			}
		}
		free(info);
	}

	xcb_randr_get_output_primary_reply_t *gpo = xcb_randr_get_output_primary_reply(dpy, xcb_randr_get_output_primary(dpy, root), NULL);
	if (gpo != NULL) {
		pri_mon = get_monitor_by_randr_id(gpo->output);
	}
	free(gpo);

	/* handle overlapping monitors */
	if (merge_overlapping_monitors) {
		monitor_t *m = mon_head;
		while (m != NULL) {
			monitor_t *next = m->next;
			if (m->wired) {
				monitor_t *mb = mon_head;
				while (mb != NULL) {
					monitor_t *mb_next = mb->next;
					if (m != mb && mb->wired && contains(m->rectangle, mb->rectangle)) {
						if (last_wired == mb) {
							last_wired = m;
						}
						if (next == mb) {
							next = mb_next;
						}
						merge_monitors(mb, m);
						remove_monitor(mb);
					}
					mb = mb_next;
				}
			}
			m = next;
		}
	}

	/* merge and remove disconnected monitors */
	if (remove_unplugged_monitors) {
		monitor_t *m = mon_head;
		while (m != NULL) {
			monitor_t *next = m->next;
			if (!m->wired) {
				merge_monitors(m, last_wired);
				remove_monitor(m);
			}
			m = next;
		}
	}

	/* add one desktop to each new monitor */
	for (monitor_t *m = mon_head; m != NULL; m = m->next) {
		if (m->desk == NULL) {
			add_desktop(m, make_desktop(NULL, XCB_NONE));
		}
	}

	if (!running && mon != NULL) {
		if (pri_mon != NULL) {
			mon = pri_mon;
		}
		center_pointer(mon->rectangle);
		ewmh_update_current_desktop();
	}

	free(sres);

	return (mon != NULL);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
leaq 0x2c2f6(%rip), %rax     # 0x356b8
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
leaq 0x2c2e5(%rip), %rax     # 0x356b8
movq (%rax), %rdi
leaq 0x2c38b(%rip), %rax     # 0x35768
movl (%rax), %esi
callq 0x4300
movq -0xe8(%rbp), %rdi
movl %eax, -0x14(%rbp)
movl -0x14(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4340
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x940e
movb $0x0, -0x1(%rbp)
jmp 0x99d6
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rdi
callq 0x45c0
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rdi
callq 0x4180
movq %rax, -0x30(%rbp)
movl -0x24(%rbp), %eax
movq %rsp, %rcx
movq %rcx, -0x38(%rbp)
leaq 0xf(,%rax,4), %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xf0(%rbp)
movq %rcx, %rsp
movq %rax, -0x40(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x94b3
movslq -0x44(%rbp), %rax
movq %rax, -0xf8(%rbp)
leaq 0x2c23e(%rip), %rax     # 0x356b8
movq (%rax), %rdi
movq -0x30(%rbp), %rax
movslq -0x44(%rbp), %rcx
movl (%rax,%rcx,4), %esi
xorl %edx, %edx
callq 0x46c0
movq -0xf8(%rbp), %rcx
movl %eax, %edx
movq -0xf0(%rbp), %rax
movl %edx, -0x48(%rbp)
movl -0x48(%rbp), %edx
movl %edx, (%rax,%rcx,4)
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x9460
leaq 0x2c23e(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x94de
movq -0x50(%rbp), %rax
movb $0x0, 0x2c(%rax)
movq -0x50(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x94c1
movl $0x0, -0x54(%rbp)
movl -0x54(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x96c4
movq -0xf0(%rbp), %rax
leaq 0x2c1b9(%rip), %rcx     # 0x356b8
movq (%rcx), %rdi
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4350
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x96ad
movq -0x60(%rbp), %rax
movl 0xc(%rax), %eax
cmpq $0x0, %rax
je 0x9662
leaq 0x2c17f(%rip), %rax     # 0x356b8
movq (%rax), %rax
movq %rax, -0x100(%rbp)
leaq 0x2c16e(%rip), %rax     # 0x356b8
movq (%rax), %rdi
movq -0x60(%rbp), %rax
movl 0xc(%rax), %esi
xorl %edx, %edx
callq 0x4420
movq -0x100(%rbp), %rdi
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x45d0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
je 0x9657
movq -0x68(%rbp), %rax
movw 0xc(%rax), %ax
movw %ax, -0x74(%rbp)
movq -0x68(%rbp), %rax
movw 0xe(%rax), %ax
movw %ax, -0x72(%rbp)
movq -0x68(%rbp), %rax
movw 0x10(%rax), %ax
movw %ax, -0x70(%rbp)
movq -0x68(%rbp), %rax
movw 0x12(%rax), %ax
movw %ax, -0x6e(%rbp)
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x8a50
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x95e2
movq -0x20(%rbp), %rdi
leaq -0x74(%rbp), %rsi
callq 0x8040
movq -0x20(%rbp), %rax
movb $0x1, 0x2c(%rax)
jmp 0x9655
movq -0x60(%rbp), %rdi
callq 0x4620
movq %rax, -0x80(%rbp)
movq -0x60(%rbp), %rdi
callq 0x44f0
cltq
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rsi
callq 0x6750
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
leaq -0x74(%rbp), %rsi
xorl %edx, %edx
callq 0x7ec0
movq %rax, -0x20(%rbp)
movq -0x90(%rbp), %rdi
callq 0x4450
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x24(%rax)
movq -0x20(%rbp), %rdi
callq 0x8bc0
jmp 0x9657
movq -0x68(%rbp), %rdi
callq 0x4450
jmp 0x96ab
leaq 0x2c793(%rip), %rax     # 0x35dfc
testb $0x1, (%rax)
jne 0x96a9
movq -0x60(%rbp), %rax
movzbl 0x18(%rax), %eax
cmpl $0x1, %eax
je 0x96a9
movq -0x30(%rbp), %rax
movslq -0x54(%rbp), %rcx
movl (%rax,%rcx,4), %edi
callq 0x8a50
movq %rax, -0x98(%rbp)
cmpq $0x0, -0x98(%rbp)
je 0x96a7
movq -0x98(%rbp), %rax
movb $0x1, 0x2c(%rax)
jmp 0x96a9
jmp 0x96ab
jmp 0x96ad
movq -0x60(%rbp), %rdi
callq 0x4450
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x94e5
leaq 0x2bfed(%rip), %rax     # 0x356b8
movq (%rax), %rax
movq %rax, -0x108(%rbp)
leaq 0x2bfdc(%rip), %rax     # 0x356b8
movq (%rax), %rdi
leaq 0x2c082(%rip), %rax     # 0x35768
movl (%rax), %esi
callq 0x4640
movq -0x108(%rbp), %rdi
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x4220
movq %rax, -0xa0(%rbp)
cmpq $0x0, -0xa0(%rbp)
je 0x9736
movq -0xa0(%rbp), %rax
movl 0x8(%rax), %edi
callq 0x8a50
movq %rax, %rcx
leaq 0x2bfb5(%rip), %rax     # 0x356e8
movq %rcx, (%rax)
movq -0xa0(%rbp), %rdi
callq 0x4450
leaq 0x2c6b5(%rip), %rax     # 0x35dfe
testb $0x1, (%rax)
je 0x9886
leaq 0x2bf9f(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x9884
movq -0xb0(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xb8(%rbp)
movq -0xb0(%rbp), %rax
testb $0x1, 0x2c(%rax)
je 0x9871
leaq 0x2bf5d(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0xc0(%rbp)
cmpq $0x0, -0xc0(%rbp)
je 0x986f
movq -0xc0(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0xb0(%rbp), %rax
cmpq -0xc0(%rbp), %rax
je 0x985c
movq -0xc0(%rbp), %rax
testb $0x1, 0x2c(%rax)
je 0x985c
movq -0xb0(%rbp), %rcx
movq -0xc0(%rbp), %rax
movq 0x4c(%rcx), %rdi
movq 0x4c(%rax), %rsi
callq 0x6c60
testb $0x1, %al
jne 0x9807
jmp 0x985c
movq -0x20(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x981f
movq -0xb0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0xb8(%rbp), %rax
cmpq -0xc0(%rbp), %rax
jne 0x983d
movq -0xc8(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xc0(%rbp), %rdi
movq -0xb0(%rbp), %rsi
callq 0x8eb0
movq -0xc0(%rbp), %rdi
callq 0x8e00
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
jmp 0x97a5
jmp 0x9871
movq -0xb8(%rbp), %rax
movq %rax, -0xb0(%rbp)
jmp 0x9763
jmp 0x9886
leaq 0x2c570(%rip), %rax     # 0x35dfd
testb $0x1, (%rax)
je 0x98fa
leaq 0x2be5f(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
je 0x98f8
movq -0xd0(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
testb $0x1, 0x2c(%rax)
jne 0x98e8
movq -0xd0(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x8eb0
movq -0xd0(%rbp), %rdi
callq 0x8e00
movq -0xd8(%rbp), %rax
movq %rax, -0xd0(%rbp)
jmp 0x98a3
jmp 0x98fa
leaq 0x2bdf7(%rip), %rax     # 0x356f8
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
cmpq $0x0, -0xe0(%rbp)
je 0x9961
movq -0xe0(%rbp), %rax
cmpq $0x0, 0x58(%rax)
jne 0x994b
movq -0xe0(%rbp), %rax
movq %rax, -0x110(%rbp)
xorl %eax, %eax
movl %eax, %edi
xorl %esi, %esi
callq 0xa460
movq -0x110(%rbp), %rdi
movq %rax, %rsi
callq 0xa610
jmp 0x994d
movq -0xe0(%rbp), %rax
movq 0x78(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x990b
leaq 0x2bd58(%rip), %rax     # 0x356c0
testb $0x1, (%rax)
jne 0x99b3
leaq 0x2bd8c(%rip), %rax     # 0x35700
cmpq $0x0, (%rax)
je 0x99b3
leaq 0x2bd67(%rip), %rax     # 0x356e8
cmpq $0x0, (%rax)
je 0x999b
leaq 0x2bd5a(%rip), %rax     # 0x356e8
movq (%rax), %rcx
leaq 0x2bd68(%rip), %rax     # 0x35700
movq %rcx, (%rax)
leaq 0x2bd5e(%rip), %rax     # 0x35700
movq (%rax), %rax
movq 0x4c(%rax), %rdi
callq 0x18a20
callq 0x2ae60
movq -0x10(%rbp), %rdi
callq 0x4450
leaq 0x2bd3d(%rip), %rax     # 0x35700
cmpq $0x0, (%rax)
setne %al
andb $0x1, %al
movb %al, -0x1(%rbp)
movq -0x38(%rbp), %rax
movq %rax, %rsp
movb -0x1(%rbp), %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq