// File: /workspace/github_c_makefile_star2_O2/baskerville[P]sxhkd/src/parse.c
// Function: parse_chain
bool parse_chain(char *string, chain_t *chain)
{
	char chord[MAXLEN] = {0};
	char name[MAXLEN] = {0};
	char ignored[MAXLEN] = {0};
	xcb_keysym_t keysym = XCB_NO_SYMBOL;
	xcb_button_t button = XCB_NONE;
	uint16_t modfield = 0;
	uint8_t event_type = XCB_KEY_PRESS;
	bool replay_event = false;
	bool lock_chain = false;
	char *outer_advance;
	char *inner_advance;
	for (outer_advance = get_token(chord, ignored, string, LNK_SEP); chord[0] != '\0'; outer_advance = get_token(chord, ignored, outer_advance, LNK_SEP)) {
		for (inner_advance = get_token(name, NULL, chord, SYM_SEP); name[0] != '\0'; inner_advance = get_token(name, NULL, inner_advance, SYM_SEP)) {
			int offset = 0;
			if (name[offset] == REPLAY_PREFIX) {
				replay_event = true;
				offset++;
			}
			if (name[offset] == RELEASE_PREFIX) {
				event_type = XCB_KEY_RELEASE;
				offset++;
			}
			char *nm = name + offset;
			if (!parse_modifier(nm, &modfield) && !parse_keysym(nm, &keysym) && !parse_button(nm, &button)) {
				warn("Unknown keysym name: '%s'.\n", nm);
				return false;
			}
		}
		if (strstr(ignored, GRP_SEP) != NULL)
			lock_chain = true;
		if (button != XCB_NONE)
			event_type = key_to_button(event_type);
		chord_t *c = make_chord(keysym, button, modfield, event_type, replay_event, lock_chain);
		if (c == NULL) {
			return false;
		}
		add_chord(chain, c);
		if (status_fifo != NULL) {
			snprintf(c->repr, sizeof(c->repr), "%s", chord);
		}
		keysym = XCB_NO_SYMBOL;
		button = XCB_NONE;
		modfield = 0;
		event_type = XCB_KEY_PRESS;
		replay_event = false;
		lock_chain = false;
	}
	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x328, %rsp            # imm = 0x328
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
leaq 0x220(%rsp), %r13
movl $0x100, %edx            # imm = 0x100
movq %r13, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x20(%rsp), %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x120(%rsp), %rbx
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x8(%rsp), %rax
andl $0x0, (%rax)
leaq 0x5(%rsp), %rax
movb $0x0, (%rax)
leaq 0x6(%rsp), %rax
andw $0x0, (%rax)
leaq 0x768b(%rip), %rcx      # 0x1735e
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0xfe8b
leaq 0x7679(%rip), %r12      # 0x17361
cmpb $0x0, 0x220(%rsp)
sete %cl
je 0xfe87
movl %ecx, 0xc(%rsp)
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movq %r15, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r12, %rcx
callq 0xfe8b
movq %rax, %r14
movb $0x2, %r13b
movzbl 0x20(%rsp), %eax
movzbl %r13b, %r13d
cmpl $0x7e, %eax
je 0xfd31
testl %eax, %eax
je 0xfd9a
movq %r15, %rcx
jmp 0xfd3c
movb $0x1, %bl
movb 0x21(%rsp), %al
leaq 0x21(%rsp), %rcx
xorl %ebp, %ebp
cmpb $0x40, %al
sete %bpl
pushq $0x3
popq %rax
cmovel %eax, %r13d
addq %rcx, %rbp
movq %rbp, %rdi
leaq 0x6(%rsp), %rsi
callq 0xffde
testb %al, %al
jne 0xfd85
movq %rbp, %rdi
leaq 0x8(%rsp), %rsi
callq 0x10201
testb %al, %al
jne 0xfd85
movq %rbp, %rdi
leaq 0x5(%rsp), %rsi
callq 0x10258
testb %al, %al
je 0xfe60
movq %r15, %rdi
xorl %esi, %esi
movq %r14, %rdx
movq %r12, %rcx
callq 0xfe8b
movq %rax, %r14
jmp 0xfd1a
leaq 0x120(%rsp), %rdi
pushq $0x3a
popq %rsi
callq 0xe160
xorl %r9d, %r9d
testq %rax, %rax
setne %r9b
movzbl 0x5(%rsp), %esi
cmpb $0x2, %r13b
sete %al
xorb $0x5, %al
testl %esi, %esi
movzbl %al, %eax
cmovel %r13d, %eax
movl 0x8(%rsp), %edi
movzwl 0x6(%rsp), %edx
movzbl %al, %ecx
movzbl %bl, %r8d
andl $0x1, %r8d
callq 0x109d8
testq %rax, %rax
movl 0xc(%rsp), %ebx
je 0xfe73
movq %rax, %r14
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x10bba
leaq 0x12538(%rip), %rax     # 0x22340
cmpq $0x0, (%rax)
leaq 0x220(%rsp), %r13
je 0xfe2f
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
leaq 0x1302(%rip), %rdx      # 0x11127
movq %r13, %rcx
xorl %eax, %eax
callq 0xe170
andl $0x0, 0x8(%rsp)
movb $0x0, 0x5(%rsp)
andw $0x0, 0x6(%rsp)
movq %r13, %rdi
leaq 0x120(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x7508(%rip), %rcx      # 0x1735e
callq 0xfe8b
jmp 0xfce8
leaq 0x74fd(%rip), %rdi      # 0x17364
xorl %ebx, %ebx
movq %rbp, %rsi
xorl %eax, %eax
callq 0xf160
movl %ebx, %eax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, %bl
jmp 0xfe73