// File: /workspace/github_c_makefile_star2_O1/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, 0x18(%rsp)
movq %rdi, %r14
leaq 0x120(%rsp), %rbx
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x20(%rsp), %rdi
movl $0x100, %edx            # imm = 0x100
xorl %esi, %esi
callq 0xe190
leaq 0x220(%rsp), %r15
movl $0x100, %edx            # imm = 0x100
movq %r15, %rdi
xorl %esi, %esi
callq 0xe190
movb $0x0, (%rsp)
movw $0x0, 0x2(%rsp)
leaq 0x84f6(%rip), %rcx      # 0x1835e
movq %rbx, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x10108
cmpb $0x0, (%rbx)
sete 0x1(%rsp)
je 0x100f0
movq %rax, 0x10(%rsp)
movb $0x2, %bpl
leaq 0x84ce(%rip), %r12      # 0x18361
leaq 0x20(%rsp), %rbx
leaq 0x120(%rsp), %r15
movl $0x0, 0x4(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x8(%rsp)
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r12, %rcx
callq 0x10108
movq %rax, %r13
movzbl 0x20(%rsp), %ecx
cmpl $0x7e, %ecx
je 0xfee0
xorl %eax, %eax
testl %ecx, %ecx
jne 0xfeeb
jmp 0xffc5
movl $0x1, %eax
movb $0x1, %cl
movl %ecx, 0xc(%rsp)
movl %eax, %ecx
xorl %edx, %edx
cmpb $0x40, 0x20(%rsp,%rcx)
sete %dl
movzbl %bpl, %ebp
movl $0x3, %ecx
cmovel %ecx, %ebp
addl %eax, %edx
leaq (%rsp,%rdx), %r14
addq $0x20, %r14
movq %r14, %rdi
leaq 0x2(%rsp), %rsi
callq 0x1029b
testb %al, %al
jne 0xffb8
movq 0xb2e7(%rip), %rsi      # 0x1b210
movq %r14, %rdi
callq 0xe220
testl %eax, %eax
je 0xff79
movq %r12, %rbx
leaq 0xb2d1(%rip), %r15      # 0x1b210
xorl %r12d, %r12d
cmpq $0x811, %r12            # imm = 0x811
je 0xff8c
movq 0x10(%r15), %rsi
addq $0x10, %r15
movq %r14, %rdi
callq 0xe220
incq %r12
testl %eax, %eax
jne 0xff42
decq %r12
cmpq $0x811, %r12            # imm = 0x811
setb %al
movq %rbx, %r12
leaq 0x20(%rsp), %rbx
jmp 0xff82
movb $0x1, %al
leaq 0xb28e(%rip), %r15      # 0x1b210
movl 0x8(%r15), %ecx
movl %ecx, 0x8(%rsp)
jmp 0xff97
setb %al
movq %rbx, %r12
leaq 0x20(%rsp), %rbx
testb %al, %al
jne 0xffb8
movq %r14, %rdi
leaq 0x83db(%rip), %rsi      # 0x18380
movq %rsp, %rdx
xorl %eax, %eax
callq 0xe290
cmpl $0x1, %eax
jne 0x100df
movq %rbx, %rdi
xorl %esi, %esi
movq %r13, %rdx
jmp 0xfec0
leaq 0x220(%rsp), %r13
movq %r13, %rdi
movl $0x3a, %esi
callq 0xe160
testq %rax, %rax
movl 0x4(%rsp), %edi
movzbl %dil, %edi
movl $0x1, %eax
cmovnel %eax, %edi
movb (%rsp), %al
testb %al, %al
je 0x10010
cmpb $0x2, %bpl
leaq 0x120(%rsp), %r15
je 0x1001a
movzbl %bpl, %ecx
cmpl $0x3, %ecx
jne 0x1001d
movb $0x5, %bpl
jmp 0x1001d
leaq 0x120(%rsp), %r15
jmp 0x1001d
movb $0x4, %bpl
movzwl 0x2(%rsp), %edx
movzbl %al, %esi
movzbl %bpl, %ecx
movzbl 0xc(%rsp), %r8d
andl $0x1, %r8d
movl %edi, 0x4(%rsp)
movzbl %dil, %r9d
andl $0x1, %r9d
movl 0x8(%rsp), %edi
callq 0x10e11
movq %rax, %r14
testq %rax, %rax
je 0x100a9
movq 0x18(%rsp), %rdi
movq %r14, %rsi
callq 0x1103e
leaq 0x132dc(%rip), %rax     # 0x23340
cmpq $0x0, (%rax)
je 0x10083
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdi
leaq 0x20ae(%rip), %rdx      # 0x12127
movq %r15, %rcx
xorl %eax, %eax
callq 0xe170
movb $0x0, (%rsp)
movw $0x0, 0x2(%rsp)
movb $0x2, %bpl
movl $0x0, 0x8(%rsp)
movl $0x0, 0xc(%rsp)
movl $0x0, 0x4(%rsp)
testq %r14, %r14
je 0x100f0
movq %r15, %rdi
movq %r13, %rsi
movq 0x10(%rsp), %rdx
leaq 0x829e(%rip), %rcx      # 0x1835e
callq 0x10108
movq %rax, 0x10(%rsp)
cmpb $0x0, 0x120(%rsp)
sete 0x1(%rsp)
jne 0xfeb8
jmp 0x100f0
leaq 0x827e(%rip), %rdi      # 0x18364
movq %r14, %rsi
xorl %eax, %eax
callq 0xe410
movb 0x1(%rsp), %al
andb $0x1, %al
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq