// File: /workspace/github_c_makefile_star2_O3/System-Glitch[P]ESGILinter-C/src/parsing_variables.c
// Function: parse_variable_name
match_t *parse_variable_name(char *names, unsigned int *start_index, unsigned int *array_count, char **value) {
	unsigned int index              = 0;
	unsigned int value_start_index  = 0;
	char *line                      = names + *start_index;
	unsigned int length             = strlen(line);
	match_t *match                  = NULL;
	unsigned char c;

	if(*start_index > strlen(names)) return NULL;

	match = match_init();

	if(match == NULL) return NULL;
	else if(line[index] == ';') {
		free(match);
		return NULL;
	}

	SKIP_WHITESPACES

	match->index_start = index;

	//Until not alphanumeric
	while((is_alphanumeric(c = line[index]) || c == '*') && index < length) {
		index++;
	}

	match->index_end = index;

	if(c != ';') {

		if(c != ',') {

			SKIP_WHITESPACES

			*array_count += parse_variable_array(line, length, &index);

			SKIP_WHITESPACES

			if(index < length) {
				//Equal symbol?
				if(line[index] == '=') {
					value_start_index = index + 1;
					if(!parse_variable_value(line, length, &index)) { //Invalid syntax or missing value before comma
						free(match);
						match = NULL;
					} else if(value != NULL) {
						*value = strsubstr(line, value_start_index, index - value_start_index - (line[index-1] == ';' || line[index-1] == ',' ? 1 : 0));
					}
				} else if(line[index] != ',' && line[index] != ';') { //Syntax error
					free(match);
					match = NULL;
				}
			}
		} else {
			index++;
		}
	}

	*start_index += index;

	return match;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %rbp
movl (%rsi), %r13d
leaq (%rdi,%r13), %r12
movq %r12, %rdi
callq 0x20b0
movq %rax, 0x20(%rsp)
movq %rbp, %rdi
callq 0x20b0
cmpq %r13, %rax
jb 0x8592
xorl %eax, %eax
callq 0x82d2
testq %rax, %rax
je 0x8592
cmpb $0x3b, (%r12)
jne 0x85a7
movq %rax, %rdi
callq 0x2030
xorl %r14d, %r14d
movq %r14, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, 0x30(%rsp)
movq %r14, 0x28(%rsp)
movq %rax, (%rsp)
movq %rbx, 0x18(%rsp)
movl 0x20(%rsp), %eax
movq %rax, 0x10(%rsp)
xorl %r14d, %r14d
movsbl (%r12,%r14), %edi
callq 0x7f3a
leaq 0x1(%r14), %r15
testb %al, %al
je 0x85e2
cmpq 0x10(%rsp), %r14
movq %r15, %r14
jb 0x85c6
leal -0x1(%r15), %eax
movq (%rsp), %rcx
movl %eax, (%rcx)
leaq -0x1(,%rbp), %r14
addq %r13, %r14
movsbl (%r14,%r15), %r13d
cmpl $0x2a, %r13d
setne %bl
movl %r13d, %edi
callq 0x82a7
testb %al, %al
sete %al
leaq 0x1(%r15), %rbp
testb %al, %bl
jne 0x8625
decq %r15
cmpq 0x10(%rsp), %r15
movq %rbp, %r15
jb 0x85f7
movzbl %r13b, %eax
leaq -0x2(%rbp), %r13
movq (%rsp), %r14
movl %r13d, 0x4(%r14)
cmpl $0x2c, %eax
je 0x86b8
cmpl $0x3b, %eax
movq 0x18(%rsp), %rbx
je 0x876a
addq $-0x3, %rbp
movl %r13d, %r14d
movsbl (%r12,%r14), %edi
callq 0x7f3a
incl %ebp
testb %al, %al
je 0x866d
leaq 0x1(%r14), %rax
cmpq 0x10(%rsp), %r14
movq %rax, %r14
jb 0x864f
movl 0x20(%rsp), %r15d
xorl %r13d, %r13d
movl %ebp, %eax
cmpl %ebp, %r15d
jbe 0x86c7
cmpb $0x5b, (%r12,%rax)
jne 0x86c7
incq %rax
movq %rax, %rbp
cmpb $0x5d, (%r12,%rax)
je 0x8699
leaq 0x1(%rbp), %rax
cmpq %rbp, %r15
ja 0x8686
incl %ebp
movsbl (%r12,%rbp), %edi
callq 0x7f3a
cmpl %ebp, %r15d
jbe 0x86ae
testb %al, %al
jne 0x8699
incl %r13d
cmpl %ebp, %r15d
ja 0x8675
jmp 0x86ca
decl %ebp
movl %ebp, %r13d
movq 0x18(%rsp), %rbx
jmp 0x876a
movq %rax, %rbp
movq 0x30(%rsp), %rax
addl %r13d, (%rax)
movq %rbp, %r14
movsbl (%r12,%rbp), %edi
callq 0x7f3a
incq %rbp
testb %al, %al
je 0x86ed
cmpq 0x10(%rsp), %r14
jb 0x86d2
leal -0x1(%rbp), %r13d
movl %r13d, 0xc(%rsp)
cmpq 0x10(%rsp), %r14
jae 0x8766
movzbl -0x1(%r12,%rbp), %eax
cmpl $0x2c, %eax
je 0x8766
cmpl $0x3b, %eax
je 0x8766
cmpl $0x3d, %eax
jne 0x8772
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x8793
testb %al, %al
je 0x8780
movl 0xc(%rsp), %r13d
movq 0x28(%rsp), %r15
testq %r15, %r15
movq (%rsp), %r14
je 0x876a
leal -0x1(%r13), %eax
movb (%r12,%rax), %al
cmpb $0x3b, %al
sete %cl
cmpb $0x2c, %al
sete %al
orb %cl, %al
movzbl %al, %eax
movl %r13d, %edx
subl %eax, %edx
subl %ebp, %edx
movq %r12, %rdi
movl %ebp, %esi
callq 0x7e1a
movq %rax, (%r15)
jmp 0x876a
movq (%rsp), %r14
addl %r13d, (%rbx)
jmp 0x8595
movq (%rsp), %rdi
callq 0x2030
xorl %r14d, %r14d
jmp 0x876a
movq (%rsp), %rdi
callq 0x2030
xorl %r14d, %r14d
movl 0xc(%rsp), %r13d
jmp 0x876a