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

	while (num > 0) {
		if (streq("-d", *args) || streq("--dump-state", *args)) {
			query_state(rsp);
			fprintf(rsp, "\n");
		} else if (streq("-l", *args) || streq("--load-state", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
				break;
			}
			if (!restore_state(*args)) {
				fail(rsp, "");
				break;
			}
		} else if (streq("-a", *args) || streq("--add-monitor", *args)) {
			num--, args++;
			if (num < 2) {
				fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
				break;
			}
			char *name = *args;
			num--, args++;
			xcb_rectangle_t r;
			if (parse_rectangle(*args, &r)) {
				monitor_t *m = make_monitor(name, &r, XCB_NONE);
				add_monitor(m);
				add_desktop(m, make_desktop(NULL, XCB_NONE));
			} else {
				fail(rsp, "wm %s: Invalid argument: '%s'.\n", *(args - 1), *args);
				break;
			}
		} else if (streq("-O", *args) || streq("--reorder-monitors", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			monitor_t *m = mon_head;
			while (m != NULL && num > 0) {
				monitor_t *next = m->next;
				coordinates_t dst;
				if (locate_monitor(*args, &dst)) {
					swap_monitors(m, dst.monitor);
					if (next == dst.monitor) {
						next = m;
					}
				}
				m = next;
				num--, args++;
			}
		} else if (streq("-o", *args) || streq("--adopt-orphans", *args)) {
			adopt_orphans();
		} else if (streq("-g", *args) || streq("--get-status", *args)) {
			print_report(rsp);
		} else if (streq("-h", *args) || streq("--record-history", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "wm %s: Not enough arguments.\n", *(args - 1));
				break;
			}
			bool b;
			if (parse_bool(*args, &b)) {
				record_history = b;
			} else {
				fail(rsp, "wm %s: Invalid argument: '%s'.\n", *(args - 1), *args);
				break;
			}
		} else if (streq("-r", *args) || streq("--restart", *args)) {
			running = false;
			restart = true;
			break;
		} else {
			fail(rsp, "wm: Unknown command: '%s'.\n", *args);
			break;
		}
		num--, args++;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdx, %rbx
testl %esi, %esi
jle 0x14b5d
movl %esi, %r12d
movq %rdi, %r13
leaq 0x10(%rsp), %rsi
movq %rbx, 0x8(%rsp)
movq %rsi, %r14
movq (%r13), %r15
leaq 0xb4dd(%rip), %rdi      # 0x1fd31
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x149c2
leaq 0xbb5b(%rip), %rdi      # 0x203c6
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x149c2
leaq 0xb4e8(%rip), %rdi      # 0x1fd6a
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x149d9
leaq 0xbb3a(%rip), %rdi      # 0x203d3
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x149d9
leaq 0xb443(%rip), %rdi      # 0x1fcf3
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14a19
leaq 0xbb37(%rip), %rdi      # 0x203fe
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14a19
leaq 0xbb4e(%rip), %rdi      # 0x2042c
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14aa7
leaq 0xbb3a(%rip), %rdi      # 0x2042f
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14aa7
leaq 0xa830(%rip), %rdi      # 0x1f13c
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14b1a
leaq 0xbb1f(%rip), %rdi      # 0x20442
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14b1a
leaq 0xb468(%rip), %rdi      # 0x1fda2
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14b24
leaq 0xbb01(%rip), %rdi      # 0x20452
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14b24
leaq 0xbaf7(%rip), %rdi      # 0x2045f
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x1498b
leaq 0xbae7(%rip), %rdi      # 0x20462
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
jne 0x14bb2
cmpl $0x1, %r12d
je 0x14b7c
leaq 0x8(%r13), %rbp
movq (%rbp), %rdi
movq %r14, %rsi
callq 0x169bc
movl %eax, %r15d
testb %al, %al
je 0x14b31
movb 0x10(%rsp), %al
leaq 0x14dad(%rip), %rcx     # 0x29768
movb %al, (%rcx)
jmp 0x14b4a
movq %rbx, %rdi
callq 0x182c0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x4420
jmp 0x149fb
cmpl $0x1, %r12d
je 0x14b7c
movq 0x8(%r13), %rdi
callq 0x1b140
testb %al, %al
je 0x14b92
addq $0x8, %r13
decl %r12d
movq %r14, %rsi
leal -0x1(%r12), %eax
addq $0x8, %r13
cmpl $0x1, %r12d
movl %eax, %r12d
jg 0x14846
jmp 0x14ba3
cmpl $0x2, %r12d
jbe 0x14b7c
movq 0x8(%r13), %rbp
movq 0x10(%r13), %rdi
movq %r14, %rbx
movq %r14, %rsi
callq 0x1740e
movl %eax, %r15d
testb %al, %al
je 0x14a70
movq %rbp, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x6b68
movq %rax, %rbp
movq %rax, %rdi
callq 0x7261
xorl %edi, %edi
xorl %esi, %esi
callq 0x8297
movq %rbp, %rdi
movq %rax, %rsi
callq 0x8389
movq 0x8(%rsp), %rbx
jmp 0x14a8e
movq 0x8(%r13), %rdx
movq 0x10(%r13), %rcx
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0xb985(%rip), %rsi      # 0x2040c
xorl %eax, %eax
callq 0x11852
testb %r15b, %r15b
je 0x14ba3
movq %r14, %rsi
addl $-0x2, %r12d
addq $0x10, %r13
jmp 0x149fe
cmpl $0x1, %r12d
je 0x14b7c
leaq 0x14c50(%rip), %rax     # 0x29708
movq (%rax), %r15
addq $0x8, %r13
decl %r12d
testq %r15, %r15
je 0x149fb
movl %r12d, %ebp
movq %r14, %rsi
movq 0x78(%r15), %r12
movq (%r13), %rdi
callq 0x1aff9
testb %al, %al
je 0x14af6
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x7009
cmpq 0x10(%rsp), %r12
je 0x14af9
movq %r12, %r15
movq %r14, %rsi
addq $0x8, %r13
leal -0x1(%rbp), %r12d
testq %r15, %r15
je 0x149fe
cmpl $0x1, %ebp
movl %r12d, %ebp
jg 0x14ad1
jmp 0x149fe
callq 0x105b7
jmp 0x149fb
movq %rbx, %rdi
callq 0x1e8f9
jmp 0x149fb
movq (%r13), %rdx
movq 0x8(%r13), %rcx
movq %rbx, %rdi
leaq 0xb8c9(%rip), %rsi      # 0x2040c
xorl %eax, %eax
callq 0x11852
testb %r15b, %r15b
je 0x14ba3
movq %r14, %rsi
decl %r12d
movq %rbp, %r13
jmp 0x149fe
leaq 0xb84b(%rip), %rsi      # 0x203af
movq %rbx, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x11852
leaq 0xb85d(%rip), %rsi      # 0x203e0
movq %rbx, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x11852
jmp 0x14ba3
leaq 0xca0b(%rip), %rsi      # 0x215a4
movq %rbx, %rdi
xorl %eax, %eax
callq 0x11852
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xb322(%rip), %rdi      # 0x1fedb
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14be1
leaq 0xb8a7(%rip), %rdi      # 0x20473
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x14be1
leaq 0xb89e(%rip), %rsi      # 0x2047d
jmp 0x14b83
leaq 0x14ae8(%rip), %rax     # 0x296d0
movb $0x0, (%rax)
leaq 0x14aee(%rip), %rax     # 0x296e0
movb $0x1, (%rax)
jmp 0x14ba3