// File: /workspace/github_c_makefile_star2_O3/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 $0x18, %rsp
movq %rdx, %rbx
testl %esi, %esi
jle 0x14a61
movl %esi, %ebp
movq %rdi, %r14
movq (%r14), %r12
movzbl (%r12), %r13d
leal -0x2d(%r13), %r15d
negl %r15d
movl %r15d, %eax
cmpl $0x2d, %r13d
jne 0x14791
movzbl 0x1(%r12), %eax
subl $0x64, %eax
jne 0x1478f
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x14944
leaq 0xbbe0(%rip), %rdi      # 0x20380
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x14944
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x147cc
movzbl 0x1(%r12), %eax
subl $0x6c, %eax
jne 0x147ca
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x1495b
leaq 0xbbb2(%rip), %rdi      # 0x2038d
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x1495b
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x14807
movzbl 0x1(%r12), %eax
subl $0x61, %eax
jne 0x14805
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x1497d
leaq 0xbba2(%rip), %rdi      # 0x203b8
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x1497d
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x14842
movzbl 0x1(%r12), %eax
subl $0x4f, %eax
jne 0x14840
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x149eb
leaq 0xbb95(%rip), %rdi      # 0x203e6
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x149eb
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x1487d
movzbl 0x1(%r12), %eax
subl $0x6f, %eax
jne 0x1487b
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x14a4d
leaq 0xbb6d(%rip), %rdi      # 0x203f9
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x14a4d
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x148b8
movzbl 0x1(%r12), %eax
subl $0x67, %eax
jne 0x148b6
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x14a54
leaq 0xbb42(%rip), %rdi      # 0x20409
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x14a54
movl %r15d, %eax
cmpb $0x2d, %r13b
jne 0x148f3
movzbl 0x1(%r12), %eax
subl $0x68, %eax
jne 0x148f1
movzbl 0x2(%r12), %eax
negl %eax
testl %eax, %eax
je 0x1490e
leaq 0xbb18(%rip), %rdi      # 0x20416
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
jne 0x14ada
cmpl $0x1, %ebp
je 0x14a80
leaq 0x8(%r14), %r15
movq (%r15), %rdi
movq %rsp, %rsi
callq 0x16884
testb %al, %al
je 0x14ad1
decl %ebp
movb (%rsp), %al
leaq 0x14e2e(%rip), %rcx     # 0x29768
movb %al, (%rcx)
movq %r15, %r14
jmp 0x149d4
movq %rbx, %rdi
callq 0x181d0
movl $0xa, %edi
movq %rbx, %rsi
callq 0x4420
jmp 0x149d4
cmpl $0x1, %ebp
je 0x14a80
movq 0x8(%r14), %rdi
callq 0x1aeb4
testb %al, %al
je 0x14a96
addq $0x8, %r14
decl %ebp
jmp 0x149d4
cmpl $0x2, %ebp
jbe 0x14a80
movq 0x8(%r14), %r12
movq 0x10(%r14), %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0x172df
testb %al, %al
je 0x14aa9
addq $0x10, %r14
addl $-0x2, %ebp
movq %r12, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x6a8c
movq %rax, %r12
movq %rax, %rdi
callq 0x7186
xorl %edi, %edi
xorl %esi, %esi
callq 0x813c
movq %r12, %rdi
movq %rax, %rsi
callq 0x822e
leal -0x1(%rbp), %eax
addq $0x8, %r14
cmpl $0x1, %ebp
movl %eax, %ebp
jg 0x14766
jmp 0x14ac2
cmpl $0x1, %ebp
je 0x14a80
leaq 0x14d0d(%rip), %rax     # 0x29708
movq (%rax), %r12
addq $0x8, %r14
decl %ebp
testq %r12, %r12
je 0x149d4
movl %ebp, %r15d
movq 0x78(%r12), %r13
movq (%r14), %rdi
movq %rsp, %rsi
callq 0x1adaa
testb %al, %al
je 0x14a32
movq (%rsp), %rsi
movq %r12, %rdi
callq 0x6f2a
cmpq (%rsp), %r13
je 0x14a35
movq %r13, %r12
addq $0x8, %r14
leal -0x1(%r15), %ebp
testq %r12, %r12
je 0x149d4
cmpl $0x1, %r15d
movl %ebp, %r15d
ja 0x14a0c
jmp 0x149d4
callq 0x1063b
jmp 0x149d4
movq %rbx, %rdi
callq 0x1e4a6
jmp 0x149d4
leaq 0xb901(%rip), %rsi      # 0x20369
movq %rbx, %rdi
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x117fd
leaq 0xb913(%rip), %rsi      # 0x2039a
movq %rbx, %rdi
movq %r12, %rdx
xorl %eax, %eax
callq 0x117fd
jmp 0x14ac2
leaq 0xcabb(%rip), %rsi      # 0x21558
movq %rbx, %rdi
xorl %eax, %eax
callq 0x117fd
jmp 0x14ac2
movq 0x8(%r14), %rdx
movq 0x10(%r14), %rcx
leaq 0xb90e(%rip), %rsi      # 0x203c6
movq %rbx, %rdi
xorl %eax, %eax
callq 0x117fd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq (%r14), %rdx
movq 0x8(%r14), %rcx
jmp 0x14ab1
cmpb $0x2d, %r13b
jne 0x14af5
movzbl 0x1(%r12), %r15d
subl $0x72, %r15d
jne 0x14af2
movzbl 0x2(%r12), %r15d
negl %r15d
testl %r15d, %r15d
je 0x14b19
leaq 0xb926(%rip), %rdi      # 0x20427
movq %r12, %rsi
callq 0x4820
testl %eax, %eax
je 0x14b19
leaq 0xb91d(%rip), %rsi      # 0x20431
jmp 0x14a87
leaq 0x14bb0(%rip), %rax     # 0x296d0
movb $0x0, (%rax)
leaq 0x14bb6(%rip), %rax     # 0x296e0
movb $0x1, (%rax)
jmp 0x14ac2