// File: /workspace/github_c_makefile_star2_O2/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
testl %esi, %esi
jle 0x13967
movl %esi, %ebp
movq %rdi, %r14
movq %rdx, 0x8(%rsp)
leaq 0x10(%rsp), %rbx
testl %ebp, %ebp
jle 0x139ce
movq (%r14), %r15
movzbl (%r15), %r13d
leal -0x2d(%r13), %r12d
negl %r12d
movl %r12d, %eax
cmpl $0x2d, %r13d
jne 0x136c2
movzbl 0x1(%r15), %eax
subl $0x64, %eax
jne 0x136c0
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x1386a
leaq 0xbcaf(%rip), %rdi      # 0x1f380
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x1386a
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x136fb
movzbl 0x1(%r15), %eax
subl $0x6c, %eax
jne 0x136f9
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x13884
leaq 0xbc83(%rip), %rdi      # 0x1f38d
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x13884
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x13734
movzbl 0x1(%r15), %eax
subl $0x61, %eax
jne 0x13732
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x138a6
leaq 0xbc75(%rip), %rdi      # 0x1f3b8
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x138a6
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x1376d
movzbl 0x1(%r15), %eax
subl $0x4f, %eax
jne 0x1376b
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x13905
leaq 0xbc6a(%rip), %rdi      # 0x1f3e6
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x13905
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x137a6
movzbl 0x1(%r15), %eax
subl $0x6f, %eax
jne 0x137a4
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x13954
leaq 0xbc44(%rip), %rdi      # 0x1f3f9
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x13954
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x137df
movzbl 0x1(%r15), %eax
subl $0x67, %eax
jne 0x137dd
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x1395b
leaq 0xbc1b(%rip), %rdi      # 0x1f409
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x1395b
movl %r12d, %eax
cmpb $0x2d, %r13b
jne 0x13818
movzbl 0x1(%r15), %eax
subl $0x68, %eax
jne 0x13816
movzbl 0x2(%r15), %eax
negl %eax
testl %eax, %eax
je 0x13833
leaq 0xbbf3(%rip), %rdi      # 0x1f416
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
jne 0x139e6
cmpl $0x1, %ebp
je 0x13986
leaq 0x8(%r14), %r15
movq (%r15), %rdi
movq %rbx, %rsi
callq 0x15728
testb %al, %al
je 0x139dd
decl %ebp
movb 0x10(%rsp), %al
leaq 0x14f08(%rip), %rcx     # 0x28768
movb %al, (%rcx)
movq %r15, %r14
jmp 0x138fa
movq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x16fa4
pushq $0xa
popq %rdi
movq %r15, %rsi
callq 0x4420
jmp 0x138fa
cmpl $0x1, %ebp
je 0x13986
movq 0x8(%r14), %rdi
callq 0x19a44
testb %al, %al
je 0x1399e
addq $0x8, %r14
decl %ebp
jmp 0x138fa
cmpl $0x2, %ebp
jbe 0x13986
movq 0x8(%r14), %r15
movq 0x10(%r14), %rdi
movq %rbx, %rsi
callq 0x1610b
testb %al, %al
je 0x139b3
addq $0x10, %r14
addl $-0x2, %ebp
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
callq 0x6984
movq %rax, %r15
movq %rax, %rdi
callq 0x7056
xorl %edi, %edi
xorl %esi, %esi
callq 0x7efd
movq %r15, %rdi
movq %rax, %rsi
callq 0x7fe2
decl %ebp
addq $0x8, %r14
jmp 0x13692
cmpl $0x1, %ebp
je 0x13986
leaq 0x14df7(%rip), %rax     # 0x28708
movq (%rax), %r15
addq $0x8, %r14
testq %r15, %r15
je 0x138a2
cmpl $0x2, %ebp
jb 0x138a2
movq 0x78(%r15), %r12
movq (%r14), %rdi
movq %rbx, %rsi
callq 0x19936
testb %al, %al
je 0x13949
movq 0x10(%rsp), %rsi
movq %r15, %rdi
callq 0x6e0c
cmpq 0x10(%rsp), %r12
je 0x1394c
movq %r12, %r15
addq $0x8, %r14
decl %ebp
jmp 0x13918
callq 0xf85d
jmp 0x138fa
movq 0x8(%rsp), %rdi
callq 0x1ce7e
jmp 0x138fa
leaq 0xb9fb(%rip), %rsi      # 0x1f369
movq %rdx, %rdi
xorl %eax, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x10897
leaq 0xba0d(%rip), %rsi      # 0x1f39a
movq 0x8(%rsp), %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x10897
jmp 0x139ce
leaq 0xcbb3(%rip), %rsi      # 0x20558
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x10897
jmp 0x139ce
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
leaq 0xba04(%rip), %rsi      # 0x1f3c6
movq 0x8(%rsp), %rdi
xorl %eax, %eax
callq 0x10897
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdx
movq 0x8(%r14), %rcx
jmp 0x139bb
cmpb $0x2d, %r13b
movq 0x8(%rsp), %rbx
jne 0x13a04
movzbl 0x1(%r15), %r12d
subl $0x72, %r12d
jne 0x13a01
movzbl 0x2(%r15), %r12d
negl %r12d
testl %r12d, %r12d
je 0x13a2b
leaq 0xba17(%rip), %rdi      # 0x1f427
movq %r15, %rsi
callq 0x4820
testl %eax, %eax
je 0x13a2b
leaq 0xba0e(%rip), %rsi      # 0x1f431
movq %rbx, %rdi
jmp 0x13992
leaq 0x14c9e(%rip), %rax     # 0x286d0
movb $0x0, (%rax)
leaq 0x14ca4(%rip), %rax     # 0x286e0
movb $0x1, (%rax)
jmp 0x139ce