// File: /workspace/github_c_makefile_star2_O2/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 0x12a01
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %esi, %r15d
movq %rdi, %r14
movq %rdx, 0x8(%rsp)
leaq 0x16189(%rip), %rax     # 0x28710
movq (%rax), %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)
jne 0x12a12
leaq 0x30(%rsp), %r12
testl %r15d, %r15d
jle 0x12ab0
movq (%r14), %rbx
movzbl (%rbx), %r13d
leal -0x2d(%r13), %ebp
negl %ebp
movl %ebp, %eax
cmpl $0x2d, %r13d
jne 0x125f3
movzbl 0x1(%rbx), %eax
subl $0x66, %eax
jne 0x125f1
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x127aa
leaq 0xc6c1(%rip), %rdi      # 0x1ecc3
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x127aa
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x12629
movzbl 0x1(%rbx), %eax
subl $0x73, %eax
jne 0x12627
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x12802
leaq 0xc713(%rip), %rdi      # 0x1ed4b
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x12802
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x1265f
movzbl 0x1(%rbx), %eax
subl $0x64, %eax
jne 0x1265d
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x12847
leaq 0xca66(%rip), %rdi      # 0x1f0d4
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x12847
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x12695
movzbl 0x1(%rbx), %eax
subl $0x61, %eax
jne 0x12693
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x12915
leaq 0xca41(%rip), %rdi      # 0x1f0e5
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x12915
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x126cb
movzbl 0x1(%rbx), %eax
subl $0x72, %eax
jne 0x126c9
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x12abf
leaq 0xc93e(%rip), %rdi      # 0x1f018
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x12abf
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x12701
movzbl 0x1(%rbx), %eax
subl $0x6f, %eax
jne 0x126ff
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x12957
leaq 0xca04(%rip), %rdi      # 0x1f114
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x12957
movl %ebp, %eax
cmpb $0x2d, %r13b
jne 0x12737
movzbl 0x1(%rbx), %eax
subl $0x67, %eax
jne 0x12735
movzbl 0x2(%rbx), %eax
negl %eax
testl %eax, %eax
je 0x129cc
leaq 0xc9e1(%rip), %rdi      # 0x1f127
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
je 0x129cc
cmpb $0x2d, %r13b
jne 0x1276b
movzbl 0x1(%rbx), %ebp
subl $0x6e, %ebp
jne 0x12769
movzbl 0x2(%rbx), %ebp
negl %ebp
testl %ebp, %ebp
je 0x12786
leaq 0xc899(%rip), %rdi      # 0x1f00f
movq %rbx, %rsi
callq 0x4820
testl %eax, %eax
jne 0x12b1d
cmpl $0x1, %r15d
je 0x12a4b
decl %r15d
movq 0x10(%rsp), %rdi
movq 0x8(%r14), %rsi
addq $0x8, %r14
callq 0x6f45
jmp 0x1294b
movq 0x20(%rsp), %rax
movq %rax, 0x40(%rsp)
movaps 0x10(%rsp), %xmm0
movaps %xmm0, 0x30(%rsp)
cmpl $0x1, %r15d
jne 0x127ca
pushq $0x1
popq %r15
jmp 0x127ef
movq 0x8(%r14), %rdi
cmpb $0x2d, (%rdi)
je 0x127ef
addq $0x8, %r14
leaq 0x50(%rsp), %rsi
movq %r12, %rdx
callq 0x1876b
testl %eax, %eax
jne 0x12a86
decl %r15d
movq 0x30(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x9cf6
jmp 0x1294b
cmpl $0x1, %r15d
je 0x12a4b
addq $0x8, %r14
movq (%r14), %rdi
leaq 0x50(%rsp), %rsi
movq %r12, %rdx
callq 0x1876b
testl %eax, %eax
jne 0x12a6c
movq 0x10(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x6e0c
testb %al, %al
je 0x12a78
decl %r15d
jmp 0x1294b
cmpl $0x1, %r15d
je 0x12a4b
movq 0x10(%rsp), %rbx
addq $0x60, %rbx
addq $0x8, %r14
movq (%rbx), %rbx
cmpl $0x2, %r15d
jb 0x12889
testq %rbx, %rbx
je 0x12889
movq 0x10(%rsp), %rdi
movq (%r14), %rdx
movq %rbx, %rsi
callq 0x7f8c
addq $0x48, %rbx
addq $0x8, %r14
decl %r15d
jmp 0x1285e
pushq $0x1
popq %r13
movl %r13d, %edi
xorl %eax, %eax
callq 0x1d07d
cmpl %r13d, %r15d
je 0x128bf
movq 0x10(%rsp), %rbp
movq (%r14), %rdi
xorl %esi, %esi
callq 0x7efd
movq %rbp, %rdi
movq %rax, %rsi
callq 0x7fe2
addq $0x8, %r14
incl %r13d
jmp 0x12897
leaq 0x15e4a(%rip), %r13     # 0x28710
testq %rbx, %rbx
je 0x12948
movq 0x48(%rbx), %r15
movq (%r13), %rdx
movq 0x58(%rdx), %rcx
cmpq %rcx, %rbx
jne 0x128f6
movq 0x10(%rsp), %rdi
movq 0x40(%rbx), %rsi
movq 0x38(%rsi), %rdx
callq 0x9cf6
movq (%r13), %rdx
movq 0x58(%rdx), %rcx
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x8127
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
callq 0x8067
movq %r15, %rbx
jmp 0x128c6
cmpl $0x1, %r15d
je 0x12a4b
addq $0x8, %r14
cmpl $0x2, %r15d
jl 0x12948
decl %r15d
movq 0x10(%rsp), %rbx
movq (%r14), %rdi
xorl %esi, %esi
callq 0x7efd
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7fe2
jmp 0x1291f
xorl %r15d, %r15d
decl %r15d
addq $0x8, %r14
jmp 0x125c6
cmpl $0x1, %r15d
je 0x12a4b
movq 0x10(%rsp), %rax
movq 0x60(%rax), %rbx
addq $0x8, %r14
testq %rbx, %rbx
je 0x1283f
cmpl $0x2, %r15d
jb 0x1283f
movq 0x48(%rbx), %r13
movq (%r14), %rdi
movq %r12, %rsi
callq 0x1978f
testb %al, %al
je 0x129c0
movq 0x30(%rsp), %rdx
movq 0x10(%rsp), %rdi
cmpq %rdi, %rdx
jne 0x129c0
movq 0x38(%rsp), %rcx
movq %rbx, %rsi
xorl %r8d, %r8d
callq 0x8150
cmpq 0x38(%rsp), %r13
je 0x129bd
movq %r13, %rbx
movq %rbx, %r13
addq $0x8, %r14
decl %r15d
movq %r13, %rbx
jmp 0x1296e
cmpl $0x1, %r15d
je 0x12a4b
leaq 0x8(%r14), %rbx
movq (%rbx), %rdi
movq %r12, %rsi
callq 0x1610b
testb %al, %al
je 0x12b01
decl %r15d
movq 0x10(%rsp), %rdi
movq %r12, %rsi
callq 0x6a5d
movq %rbx, %r14
jmp 0x1294b
leaq 0xc65a(%rip), %rsi      # 0x1f062
movq %rdx, %rdi
xorl %eax, %eax
jmp 0x10897
leaq 0x50(%rsp), %rsi
leaq 0x10(%rsp), %rdx
callq 0x1876b
testl %eax, %eax
je 0x12a3d
movq (%r14), %rdx
leaq 0xc7a7(%rip), %rsi      # 0x1f1d6
movl %eax, %edi
movq 0x8(%rsp), %rcx
callq 0x14064
jmp 0x12ab0
decl %r15d
je 0x12a63
addq $0x8, %r14
jmp 0x125c1
leaq 0xc654(%rip), %rsi      # 0x1f0a6
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x10897
jmp 0x12ab0
leaq 0xc615(%rip), %rsi      # 0x1f07f
jmp 0x12a7f
movq (%r14), %rdx
leaq 0xc653(%rip), %rsi      # 0x1f0c9
jmp 0x12a2f
leaq 0xdad9(%rip), %rsi      # 0x20558
movq 0x8(%rsp), %rdi
jmp 0x12aa9
movq (%r14), %rdx
leaq 0xc60b(%rip), %rsi      # 0x1f09b
movl %eax, %edi
movq 0x8(%rsp), %rbx
movq %rbx, %rcx
callq 0x14064
leaq 0xdab2(%rip), %rsi      # 0x20558
movq %rbx, %rdi
xorl %eax, %eax
callq 0x10897
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %r15d
jne 0x12aec
leaq 0x15c3c(%rip), %rax     # 0x28708
movq (%rax), %rax
leaq 0x15c2a(%rip), %rcx     # 0x28700
cmpq (%rcx), %rax
movq 0x8(%rsp), %rdi
je 0x12af8
movq 0x10(%rsp), %rdi
callq 0x7194
jmp 0x12ab0
leaq 0xc601(%rip), %rsi      # 0x1f0f4
jmp 0x12a52
leaq 0xda59(%rip), %rsi      # 0x20558
jmp 0x12aa9
movq (%r14), %rdx
movq 0x8(%r14), %rcx
leaq 0xc624(%rip), %rsi      # 0x1f133
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x10897
jmp 0x12ab0
leaq 0xc634(%rip), %rsi      # 0x1f158
jmp 0x12a52