// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/messages.c
// Function: cmd_monitor
void cmd_monitor(char **args, int num, FILE *rsp)
{
	if (num < 1) {
		fail(rsp, "monitor: Missing arguments.\n");
		return;
	}

	coordinates_t ref = {mon, NULL, NULL};
	coordinates_t trg = ref;

	if ((*args)[0] != OPT_CHR) {
		int ret;
		if ((ret = monitor_from_desc(*args, &ref, &trg)) == SELECTOR_OK) {
			num--, args++;
		} else {
			handle_failure(ret, "monitor", *args, rsp);
			return;
		}
	}

	if (num < 1) {
		fail(rsp, "monitor: Missing commands.\n");
		return;
	}

	while (num > 0) {
		if (streq("-f", *args) || streq("--focus", *args)) {
			coordinates_t dst = trg;
			if (num > 1 && *(args + 1)[0] != OPT_CHR) {
				num--, args++;
				int ret;
				if ((ret = monitor_from_desc(*args, &ref, &dst)) != SELECTOR_OK) {
					handle_failure(ret, "monitor -f", *args, rsp);
					fail(rsp, "");
					return;
				}
			}
			focus_node(dst.monitor, NULL, NULL);
		} else if (streq("-s", *args) || streq("--swap", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			coordinates_t dst;
			int ret;
			if ((ret = monitor_from_desc(*args, &ref, &dst)) == SELECTOR_OK) {
				if (!swap_monitors(trg.monitor, dst.monitor)) {
					fail(rsp, "");
					return;
				}
			} else {
				handle_failure(ret, "monitor -s", *args, rsp);
				return;
			}
		} else if (streq("-d", *args) || streq("--reset-desktops", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			desktop_t *d = trg.monitor->desk_head;
			while (num > 0 && d != NULL) {
				rename_desktop(trg.monitor, d, *args);
				d = d->next;
				num--, args++;
			}
			put_status(SBSC_MASK_REPORT);
			while (num > 0) {
				add_desktop(trg.monitor, make_desktop(*args, XCB_NONE));
				num--, args++;
			}
			while (d != NULL) {
				desktop_t *next = d->next;
				if (d == mon->desk) {
					focus_node(trg.monitor, d->prev, d->prev->focus);
				}
				merge_desktops(trg.monitor, d, mon, mon->desk);
				remove_desktop(trg.monitor, d);
				d = next;
			}
		} else if (streq("-a", *args) || streq("--add-desktops", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			while (num > 0) {
				add_desktop(trg.monitor, make_desktop(*args, XCB_NONE));
				num--, args++;
			}
		} else if (streq("-r", *args) || streq("--remove", *args)) {
			if (num > 1) {
				fail(rsp, "monitor %s: Trailing commands.\n", *args);
				return;
			}
			if (mon_head == mon_tail) {
				fail(rsp, "");
				return;
			}
			remove_monitor(trg.monitor);
			return;
		} else if (streq("-o", *args) || streq("--reorder-desktops", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			desktop_t *d = trg.monitor->desk_head;
			while (d != NULL && num > 0) {
				desktop_t *next = d->next;
				coordinates_t dst;
				if (locate_desktop(*args, &dst) && dst.monitor == trg.monitor) {
					swap_desktops(trg.monitor, d, dst.monitor, dst.desktop, false);
					if (next == dst.desktop) {
						next = d;
					}
				}
				d = next;
				num--, args++;
			}
		} else if (streq("-g", *args) || streq("--rectangle", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			xcb_rectangle_t r;
			if (parse_rectangle(*args, &r)) {
				update_root(trg.monitor, &r);
			} else {
				fail(rsp, "monitor %s: Invalid argument: '%s'.\n", *(args - 1), *args);
				return;
			}
		} else if (streq("-n", *args) || streq("--rename", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "monitor %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			rename_monitor(trg.monitor, *args);
		} else {
			fail(rsp, "monitor: Unknown command: '%s'.\n", *args);
			return;
		}
		num--, args++;
	}
}

// Assembly:
testl %esi, %esi
jle 0x13787
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %r12d
movq %rdi, %r14
movq %rdx, 0x8(%rsp)
leaq 0x15fec(%rip), %r15     # 0x29710
movq (%r15), %rax
movq %rax, 0x50(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x58(%rsp)
movq 0x60(%rsp), %rax
movq %rax, 0x20(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
movq (%rdi), %rdi
cmpb $0x2d, (%rdi)
je 0x137a7
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x19c02
movl %eax, %ebp
testl %eax, %eax
je 0x13798
movq (%r14), %rdx
leaq 0xcaa3(%rip), %rsi      # 0x2021c
movl %ebp, %edi
movq 0x8(%rsp), %rcx
callq 0x1528e
jmp 0x1379f
leaq 0xc917(%rip), %rsi      # 0x200a5
movq %rdx, %rdi
xorl %eax, %eax
jmp 0x11852
decl %r12d
addq $0x8, %r14
testl %ebp, %ebp
jne 0x13c53
testl %r12d, %r12d
jle 0x13c40
movq (%r14), %r13
leaq 0xc526(%rip), %rdi      # 0x1fce0
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13943
leaq 0xc502(%rip), %rdi      # 0x1fcd3
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13943
leaq 0xc57f(%rip), %rdi      # 0x1fd67
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x139d6
leaq 0xc55c(%rip), %rdi      # 0x1fd5b
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x139d6
leaq 0xc51b(%rip), %rdi      # 0x1fd31
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13a20
leaq 0xc8ea(%rip), %rdi      # 0x20117
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13a20
leaq 0xc4af(%rip), %rdi      # 0x1fcf3
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13b08
leaq 0xc8cd(%rip), %rdi      # 0x20128
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13b08
leaq 0xc669(%rip), %rdi      # 0x1fedb
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13c92
leaq 0xc7d2(%rip), %rdi      # 0x2005b
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13c92
leaq 0xb89c(%rip), %rdi      # 0x1f13c
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13b53
leaq 0xc8a0(%rip), %rdi      # 0x20157
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13b53
leaq 0xc4d4(%rip), %rdi      # 0x1fda2
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13bd1
leaq 0xc885(%rip), %rdi      # 0x2016a
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x13bd1
leaq 0xc45c(%rip), %rdi      # 0x1fd58
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
je 0x1391f
leaq 0xc743(%rip), %rdi      # 0x20052
movq %r13, %rsi
callq 0x4820
testl %eax, %eax
jne 0x13ccc
cmpl $0x1, %r12d
je 0x13c62
decl %r12d
movq 0x10(%rsp), %rdi
movq 0x8(%r14), %rsi
addq $0x8, %r14
callq 0x7146
jmp 0x13a18
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
cmpl $0x1, %r12d
jne 0x13965
movl $0x1, %r12d
jmp 0x139b6
movq 0x8(%r14), %rdi
cmpb $0x2d, (%rdi)
je 0x139b6
addq $0x8, %r14
decl %r12d
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x19c02
testl %eax, %eax
je 0x139b6
movq (%r14), %rdx
movl %eax, %edi
leaq 0xc74a(%rip), %rsi      # 0x200de
movq 0x8(%rsp), %r13
movq %r13, %rcx
callq 0x1528e
xorl %ebx, %ebx
movq %r13, %rdi
leaq 0xdbf7(%rip), %rsi      # 0x215a4
xorl %eax, %eax
callq 0x11852
jmp 0x139c6
movq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0xa2cd
movb $0x1, %bl
movl %r12d, %ebp
testb %bl, %bl
jne 0x13c2d
jmp 0x13c53
cmpl $0x1, %r12d
je 0x13c62
addq $0x8, %r14
movq (%r14), %rdi
leaq 0x50(%rsp), %rsi
leaq 0x30(%rsp), %rdx
callq 0x19c02
testl %eax, %eax
jne 0x13c7a
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x7009
testb %al, %al
je 0x13cba
decl %r12d
movl %r12d, %ebp
jmp 0x13c2d
cmpl $0x1, %r12d
je 0x13c62
movq 0x10(%rsp), %rax
addq $0x8, %r14
movq 0x60(%rax), %r13
leal -0x1(%r12), %ebp
cmpl $0x2, %r12d
setge %al
testq %r13, %r13
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x13a77
movl %ebp, %ebx
movq 0x10(%rsp), %rdi
movq (%r14), %rdx
movq %r13, %rsi
callq 0x832f
addq $0x8, %r14
movq 0x48(%r13), %r13
leal -0x1(%rbx), %ebp
cmpl $0x2, %ebx
jl 0x13a77
testq %r13, %r13
jne 0x13a50
movl $0x1, %edi
xorl %eax, %eax
callq 0x1eb0b
testl %ebp, %ebp
jle 0x13ab2
incl %ebp
movl %ebp, %ebx
movq 0x10(%rsp), %r12
movq (%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x8297
movq %r12, %rdi
movq %rax, %rsi
callq 0x8389
addq $0x8, %r14
decl %ebx
cmpl $0x1, %ebx
jg 0x13a8b
testq %r13, %r13
je 0x13c2d
movq 0x48(%r13), %rbx
movq (%r15), %rax
cmpq 0x58(%rax), %r13
jne 0x13ada
movq 0x10(%rsp), %rdi
movq 0x40(%r13), %rsi
movq 0x38(%rsi), %rdx
callq 0xa2cd
movq 0x10(%rsp), %rdi
movq (%r15), %rdx
movq 0x58(%rdx), %rcx
movq %r13, %rsi
callq 0x84ef
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x842d
movq %rbx, %r13
testq %rbx, %rbx
jne 0x13abb
jmp 0x13c2d
cmpl $0x1, %r12d
je 0x13c62
addq $0x8, %r14
xorl %ebp, %ebp
cmpl $0x2, %r12d
jl 0x13c2d
incl %r12d
movq 0x10(%rsp), %r13
movq (%r14), %rdi
xorl %ebp, %ebp
xorl %esi, %esi
callq 0x8297
movq %r13, %rdi
movq %rax, %rsi
callq 0x8389
addq $0x8, %r14
decl %r12d
cmpl $0x2, %r12d
jg 0x13b25
jmp 0x13c2d
cmpl $0x1, %r12d
je 0x13c62
movq 0x10(%rsp), %rax
movq 0x60(%rax), %r13
addq $0x8, %r14
leal -0x1(%r12), %ebx
testq %r13, %r13
je 0x13bcd
cmpl $0x2, %r12d
jl 0x13bcd
movq 0x48(%r13), %r12
movq (%r14), %rdi
leaq 0x30(%rsp), %rsi
callq 0x1adff
testb %al, %al
je 0x13bb5
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rdi
cmpq %rdi, %rdx
jne 0x13bb5
movq 0x38(%rsp), %rcx
movq %r13, %rsi
xorl %r8d, %r8d
callq 0x851b
cmpq 0x38(%rsp), %r12
je 0x13bb8
movq %r12, %r13
addq $0x8, %r14
leal -0x1(%rbx), %ebp
testq %r13, %r13
je 0x13c2d
cmpl $0x1, %ebx
movl %ebp, %ebx
jg 0x13b7a
jmp 0x13c2d
movl %ebx, %ebp
jmp 0x13c2d
cmpl $0x1, %r12d
je 0x13c62
leaq 0x8(%r14), %rbx
movq (%rbx), %rdi
leaq 0x30(%rsp), %rbp
movq %rbp, %rsi
callq 0x1740e
movl %eax, %r13d
testb %al, %al
je 0x13c05
movq 0x10(%rsp), %rdi
movq %rbp, %rsi
callq 0x6c4e
jmp 0x13c1f
movq (%r14), %rdx
movq 0x8(%r14), %rcx
movq 0x8(%rsp), %rdi
leaq 0xc55e(%rip), %rsi      # 0x20176
xorl %eax, %eax
callq 0x11852
testb %r13b, %r13b
je 0x13c53
decl %r12d
movl %r12d, %ebp
movq %rbx, %r14
leal -0x1(%rbp), %r12d
addq $0x8, %r14
cmpl $0x1, %ebp
jg 0x137b0
jmp 0x13c53
leaq 0xc47b(%rip), %rsi      # 0x200c2
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x11852
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xc480(%rip), %rsi      # 0x200e9
movq 0x8(%rsp), %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x11852
jmp 0x13c53
movq (%r14), %rdx
leaq 0xc488(%rip), %rsi      # 0x2010c
movl %eax, %edi
movq 0x8(%rsp), %rcx
callq 0x1528e
jmp 0x13c53
cmpl $0x1, %r12d
jne 0x13cc3
leaq 0x15a69(%rip), %rax     # 0x29708
movq (%rax), %rax
leaq 0x15a57(%rip), %rcx     # 0x29700
cmpq (%rcx), %rax
je 0x13cba
movq 0x10(%rsp), %rdi
callq 0x73ad
jmp 0x13c53
leaq 0xd8e3(%rip), %rsi      # 0x215a4
jmp 0x13c47
leaq 0xc46d(%rip), %rsi      # 0x20137
jmp 0x13c69
leaq 0xc4c8(%rip), %rsi      # 0x2019b
jmp 0x13c69