// File: /workspace/github_c_makefile_star2_O3/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, %r15
leaq 0x120(%rsp), %rbx
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x20(%rsp), %rbp
movl $0x100, %edx            # imm = 0x100
movq %rbp, %rdi
xorl %esi, %esi
callq 0xe190
leaq 0x220(%rsp), %r12
movl $0x100, %edx            # imm = 0x100
movq %r12, %rdi
xorl %esi, %esi
callq 0xe190
movb $0x0, 0x1(%rsp)
movw $0x0, 0x2(%rsp)
leaq 0x755a(%rip), %rcx      # 0x1735e
movq %rbx, %rdi
movq %r12, %rsi
movq %r15, %rdx
callq 0x10049
cmpb $0x0, (%rbx)
je 0x10033
leaq 0x753f(%rip), %r12      # 0x17361
leaq 0x120(%rsp), %rdx
movq %rax, 0x18(%rsp)
movq %rbp, %rdi
xorl %esi, %esi
movq %r12, %rcx
callq 0x10049
movq %rax, %rbx
movb $0x2, %r15b
movl $0x0, 0x4(%rsp)
movq $0x0, 0x8(%rsp)
movzbl 0x20(%rsp), %eax
cmpl $0x7e, %eax
je 0xfe6a
testl %eax, %eax
je 0xff48
movq %rbp, %rcx
jmp 0xfe7a
movb $0x1, %al
movq %rax, 0x8(%rsp)
movb 0x21(%rsp), %al
leaq 0x21(%rsp), %rcx
xorl %r13d, %r13d
cmpb $0x40, %al
sete %r13b
movzbl %r15b, %r15d
movl $0x3, %eax
cmovel %eax, %r15d
addq %rcx, %r13
movq %r13, %rdi
leaq 0x2(%rsp), %rsi
callq 0x101a7
testb %al, %al
jne 0xff30
movq %r12, %r14
movq %rbp, %r12
movq 0xa35b(%rip), %rsi      # 0x1a210
movq %r13, %rdi
callq 0xe220
leaq 0xa34c(%rip), %rbp      # 0x1a210
testl %eax, %eax
je 0xfefc
xorl %ecx, %ecx
leaq 0x10(%rcx), %rbp
cmpq $0x8120, %rbp           # imm = 0x8120
je 0xff0b
leaq 0xa332(%rip), %rax      # 0x1a210
movq 0x10(%rcx,%rax), %rsi
movq %r13, %rdi
callq 0xe220
movq %rbp, %rcx
testl %eax, %eax
jne 0xfeca
leaq 0xa317(%rip), %rax      # 0x1a210
addq %rax, %rbp
movl 0x8(%rbp), %eax
movl %eax, 0x4(%rsp)
movq %r12, %rbp
movq %r14, %r12
jmp 0xff30
movq %r13, %rdi
leaq 0x746b(%rip), %rsi      # 0x17380
leaq 0x1(%rsp), %rdx
xorl %eax, %eax
callq 0xe290
cmpl $0x1, %eax
movq %r12, %rbp
movq %r14, %r12
jne 0x1001e
movq %rbp, %rdi
xorl %esi, %esi
movq %rbx, %rdx
movq %r12, %rcx
callq 0x10049
movq %rax, %rbx
jmp 0xfe53
leaq 0x220(%rsp), %rdi
movl $0x3a, %esi
callq 0xe160
xorl %r9d, %r9d
testq %rax, %rax
setne %r9b
movzbl 0x1(%rsp), %esi
cmpb $0x2, %r15b
sete %al
xorb $0x5, %al
testl %esi, %esi
movzbl %r15b, %ecx
movzbl %al, %eax
cmovel %ecx, %eax
movzwl 0x2(%rsp), %edx
movzbl %al, %ecx
movzbl 0x8(%rsp), %r8d
andl $0x1, %r8d
movl 0x4(%rsp), %edi
callq 0x10c64
testq %rax, %rax
setne %bl
je 0x10035
movq %rax, %r15
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x10e5a
leaq 0x12384(%rip), %rax     # 0x22340
cmpq $0x0, (%rax)
leaq 0x120(%rsp), %r14
je 0xffe3
movl $0x100, %esi            # imm = 0x100
movq %r15, %rdi
leaq 0x114e(%rip), %rdx      # 0x11127
movq %r14, %rcx
xorl %eax, %eax
callq 0xe170
movb $0x0, 0x1(%rsp)
movw $0x0, 0x2(%rsp)
movq %r14, %rdi
leaq 0x220(%rsp), %rsi
movq 0x18(%rsp), %rdx
leaq 0x7358(%rip), %rcx      # 0x1735e
callq 0x10049
cmpb $0x0, 0x120(%rsp)
movq %r14, %rdx
jne 0xfe2a
jmp 0x10035
leaq 0x733f(%rip), %rdi      # 0x17364
xorl %ebx, %ebx
movq %r13, %rsi
xorl %eax, %eax
callq 0xe410
jmp 0x10035
movb $0x1, %bl
movl %ebx, %eax
addq $0x328, %rsp            # imm = 0x328
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq