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

	while (num > 0) {
		if (streq("-a", *args) || streq("--add", *args)) {
			num--, args++;
			if (num < 2) {
				fail(rsp, "rule %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			rule_t *rule = make_rule();

			struct tokenize_state state;
			char *class_name = tokenize_with_escape(&state, args[0], COL_TOK[0]);
			char *instance_name = tokenize_with_escape(&state, NULL, COL_TOK[0]);
			char *name = tokenize_with_escape(&state, NULL, COL_TOK[0]);
			if (!class_name || !instance_name || !name) {
				free(class_name);
				free(instance_name);
				free(name);
				return;
			}

			snprintf(rule->class_name, sizeof(rule->class_name), "%s", class_name);
			snprintf(rule->instance_name, sizeof(rule->instance_name), "%s",
					 instance_name[0] == '\0' ? MATCH_ANY : instance_name);
			snprintf(rule->name, sizeof(rule->name), "%s",
					 name[0] == '\0' ? MATCH_ANY : name);
			free(class_name);
			free(instance_name);
			free(name);

			num--, args++;
			size_t i = 0;
			while (num > 0) {
				if (streq("-o", *args) || streq("--one-shot", *args)) {
					rule->one_shot = true;
				} else {
					for (size_t j = 0; i < sizeof(rule->effect) && j < strlen(*args); i++, j++) {
						rule->effect[i] = (*args)[j];
					}
					if (num > 1 && i < sizeof(rule->effect)) {
						rule->effect[i++] = ' ';
					}
				}
				num--, args++;
			}
			rule->effect[MIN(i, sizeof(rule->effect) - 1)] = '\0';
			add_rule(rule);
		} else if (streq("-r", *args) || streq("--remove", *args)) {
			num--, args++;
			if (num < 1) {
				fail(rsp, "rule %s: Not enough arguments.\n", *(args - 1));
				return;
			}
			uint16_t idx;
			while (num > 0) {
				if (parse_index(*args, &idx)) {
					remove_rule_by_index(idx - 1);
				} else if (streq("tail", *args)) {
					remove_rule(rule_tail);
				} else if (streq("head", *args)) {
					remove_rule(rule_head);
				} else {
					remove_rule_by_cause(*args);
				}
				num--, args++;
			}
		} else if (streq("-l", *args) || streq("--list", *args)) {
			list_rules(rsp);
		} else {
			fail(rsp, "rule: Unknown command: '%s'.\n", *args);
			return;
		}
		num--, args++;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
cmpl $0x1, -0xc(%rbp)
jge 0x1d673
movq -0x18(%rbp), %rdi
leaq 0x10e5d(%rip), %rsi     # 0x2e4c4
movb $0x0, %al
callq 0x18d60
jmp 0x1db6a
jmp 0x1d675
cmpl $0x0, -0xc(%rbp)
jle 0x1db6a
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x107f6(%rip), %rdi     # 0x2de83
callq 0x4800
cmpl $0x0, %eax
je 0x1d6b3
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x10e38(%rip), %rdi     # 0x2e4dd
callq 0x4800
cmpl $0x0, %eax
jne 0x1d9da
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
cmpl $0x2, -0xc(%rbp)
jge 0x1d6ed
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq -0x8(%rax), %rdx
leaq 0x10e02(%rip), %rsi     # 0x2e4e3
movb $0x0, %al
callq 0x18d60
jmp 0x1db6a
callq 0x29560
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq -0x38(%rbp), %rdi
movsbl 0x11a48(%rip), %edx     # 0x2f150
callq 0x6ab0
movq %rax, -0x40(%rbp)
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movsbl 0x11a30(%rip), %edx     # 0x2f150
callq 0x6ab0
movq %rax, -0x48(%rbp)
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movsbl 0x11a18(%rip), %edx     # 0x2f150
callq 0x6ab0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x1d756
cmpq $0x0, -0x48(%rbp)
je 0x1d756
cmpq $0x0, -0x50(%rbp)
jne 0x1d776
movq -0x40(%rbp), %rdi
callq 0x4450
movq -0x48(%rbp), %rdi
callq 0x4450
movq -0x50(%rbp), %rdi
callq 0x4450
jmp 0x1db6a
movq -0x20(%rbp), %rdi
movq -0x40(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0xf966(%rip), %rdx      # 0x2d0f0
movb $0x0, %al
callq 0x4120
movq -0x20(%rbp), %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x70(%rbp)
movq -0x48(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1d7b8
leaq 0x10d51(%rip), %rax     # 0x2e503
movq %rax, -0x78(%rbp)
jmp 0x1d7c0
movq -0x48(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x70(%rbp), %rdi
movq -0x78(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0xf91c(%rip), %rdx      # 0x2d0f0
movb $0x0, %al
callq 0x4120
movq -0x20(%rbp), %rax
addq $0x200, %rax            # imm = 0x200
movq %rax, -0x80(%rbp)
movq -0x50(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x1d805
leaq 0x10d07(%rip), %rax     # 0x2e503
movq %rax, -0x88(%rbp)
jmp 0x1d810
movq -0x50(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rcx
movl $0x100, %esi            # imm = 0x100
leaq 0xf8c9(%rip), %rdx      # 0x2d0f0
movb $0x0, %al
callq 0x4120
movq -0x40(%rbp), %rdi
callq 0x4450
movq -0x48(%rbp), %rdi
callq 0x4450
movq -0x50(%rbp), %rdi
callq 0x4450
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
movq $0x0, -0x58(%rbp)
cmpl $0x0, -0xc(%rbp)
jle 0x1d984
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0xf967(%rip), %rdi      # 0x2d1e5
callq 0x4800
cmpl $0x0, %eax
je 0x1d8a0
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x10c6f(%rip), %rdi     # 0x2e505
callq 0x4800
cmpl $0x0, %eax
jne 0x1d8b0
movq -0x20(%rbp), %rax
movb $0x1, 0x400(%rax)
jmp 0x1d96a
movq $0x0, -0x60(%rbp)
xorl %eax, %eax
cmpq $0x100, -0x58(%rbp)     # imm = 0x100
movb %al, -0x89(%rbp)
jae 0x1d8f7
movq -0x60(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x4460
movq %rax, %rcx
movq -0x98(%rbp), %rax
cmpq %rcx, %rax
setb %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
testb $0x1, %al
jne 0x1d903
jmp 0x1d93d
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x60(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movb %dl, 0x300(%rax,%rcx)
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x1d8b8
cmpl $0x1, -0xc(%rbp)
jle 0x1d968
cmpq $0x100, -0x58(%rbp)     # imm = 0x100
jae 0x1d968
movq -0x20(%rbp), %rax
movq -0x58(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x58(%rbp)
movb $0x20, 0x300(%rax,%rcx)
jmp 0x1d96a
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x1d866
movq -0x20(%rbp), %rax
addq $0x300, %rax            # imm = 0x300
movq %rax, -0xa0(%rbp)
cmpq $0xff, -0x58(%rbp)
jae 0x1d9ac
movq -0x58(%rbp), %rax
movq %rax, -0xa8(%rbp)
jmp 0x1d9ba
movl $0xff, %eax
movq %rax, -0xa8(%rbp)
jmp 0x1d9ba
movq -0xa0(%rbp), %rax
movq -0xa8(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x20(%rbp), %rdi
callq 0x295e0
jmp 0x1db50
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x10683(%rip), %rdi     # 0x2e06b
callq 0x4800
cmpl $0x0, %eax
je 0x1da0e
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x107eb(%rip), %rdi     # 0x2e1eb
callq 0x4800
cmpl $0x0, %eax
jne 0x1daf6
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
cmpl $0x1, -0xc(%rbp)
jge 0x1da48
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq -0x8(%rax), %rdx
leaq 0x10aa7(%rip), %rsi     # 0x2e4e3
movb $0x0, %al
callq 0x18d60
jmp 0x1db6a
jmp 0x1da4a
cmpl $0x0, -0xc(%rbp)
jle 0x1daf4
movq -0x8(%rbp), %rax
movq (%rax), %rdi
leaq -0x62(%rbp), %rsi
callq 0x217f0
testb $0x1, %al
jne 0x1da6a
jmp 0x1da78
movzwl -0x62(%rbp), %edi
subl $0x1, %edi
callq 0x29890
jmp 0x1dada
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x10a8a(%rip), %rdi     # 0x2e510
callq 0x4800
cmpl $0x0, %eax
jne 0x1daa1
leaq 0x17c89(%rip), %rax     # 0x35720
movq (%rax), %rdi
callq 0x29650
jmp 0x1dad8
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x10a66(%rip), %rdi     # 0x2e515
callq 0x4800
cmpl $0x0, %eax
jne 0x1daca
leaq 0x17c68(%rip), %rax     # 0x35728
movq (%rax), %rdi
callq 0x29650
jmp 0x1dad6
movq -0x8(%rbp), %rax
movq (%rax), %rdi
callq 0x29700
jmp 0x1dad8
jmp 0x1dada
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x1da4a
jmp 0x1db4e
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x103f6(%rip), %rdi     # 0x2defa
callq 0x4800
cmpl $0x0, %eax
je 0x1db26
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x109fe(%rip), %rdi     # 0x2e51a
callq 0x4800
cmpl $0x0, %eax
jne 0x1db31
movq -0x18(%rbp), %rdi
callq 0x2ab40
jmp 0x1db4c
movq -0x18(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rdx
leaq 0x109de(%rip), %rsi     # 0x2e521
movb $0x0, %al
callq 0x18d60
jmp 0x1db6a
jmp 0x1db4e
jmp 0x1db50
movl -0xc(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
addq $0x8, %rax
movq %rax, -0x8(%rbp)
jmp 0x1d675
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)