// File: /workspace/github_c_makefile_star2_O1/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 $0x28, %rsp
movq %rcx, %r13
movq %rdx, 0x20(%rsp)
movq %rsi, %r15
movq %rdi, %r14
movl $0x0, 0xc(%rsp)
movl (%rsi), %ebx
leaq (%rdi,%rbx), %r12
movq %r12, %rdi
callq 0x20b0
movq %rax, %rbp
movq %r14, %rdi
callq 0x20b0
cmpq %rbx, %rax
jb 0x8568
xorl %eax, %eax
callq 0x8287
testq %rax, %rax
je 0x8568
movq %rax, %r14
cmpb $0x3b, (%r12)
jne 0x857d
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r13, 0x18(%rsp)
movq %r15, 0x10(%rsp)
movl 0xc(%rsp), %r15d
movl %ebp, %r13d
leal -0x2(%r15), %ebx
movsbl (%r12,%r15), %edi
callq 0x7ed1
incl %ebx
testb %al, %al
je 0x85af
leaq 0x1(%r15), %rax
cmpq %r13, %r15
movq %rax, %r15
jb 0x8593
leal 0x1(%rbx), %eax
movl %eax, 0xc(%rsp)
movl %eax, (%r14)
incl %ebx
movsbl (%r12,%rbx), %r15d
cmpl $0x2a, %r15d
setne %r13b
movl %r15d, %edi
callq 0x825c
testb %al, %al
sete %al
testb %al, %r13b
jne 0x85de
cmpl %ebp, %ebx
jb 0x85b9
movzbl %r15b, %eax
movl %ebx, 0xc(%rsp)
movl %ebx, 0x4(%r14)
cmpl $0x2c, %eax
je 0x8708
cmpl $0x3b, %eax
je 0x870e
movl 0xc(%rsp), %ebx
movl %ebp, %r13d
leal -0x1(%rbx), %r15d
movsbl (%r12,%rbx), %edi
callq 0x7ed1
incl %r15d
testb %al, %al
je 0x8624
leaq 0x1(%rbx), %rax
cmpq %r13, %rbx
movq %rax, %rbx
jb 0x8607
movl %r15d, 0xc(%rsp)
movl %ebp, %r13d
xorl %ebx, %ebx
cmpl %r15d, %r13d
jbe 0x8670
movl %r15d, %eax
cmpb $0x5b, (%r12,%rax)
jne 0x8670
incq %rax
movq %rax, %r15
cmpb $0x5d, (%r12,%rax)
je 0x8653
leaq 0x1(%r15), %rax
cmpq %r15, %r13
ja 0x8640
incl %r15d
movsbl (%r12,%r15), %edi
callq 0x7ed1
cmpl %r15d, %r13d
jbe 0x8669
testb %al, %al
jne 0x8653
incl %ebx
cmpl %r15d, %r13d
ja 0x862e
movl %r15d, 0xc(%rsp)
movq 0x20(%rsp), %rax
addl %ebx, (%rax)
movl %r15d, %ebx
movl %ebp, %ebp
decq %rbx
movsbl 0x1(%r12,%rbx), %edi
incq %rbx
callq 0x7ed1
incl %r15d
testb %al, %al
je 0x869e
cmpq %rbp, %rbx
jb 0x8684
movl %ebx, 0xc(%rsp)
cmpq %rbp, %rbx
jae 0x870e
movzbl (%r12,%rbx), %eax
cmpl $0x2c, %eax
je 0x870e
cmpl $0x3b, %eax
je 0x870e
cmpl $0x3d, %eax
jne 0x871e
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x872b
testb %al, %al
je 0x871e
movq 0x18(%rsp), %rbx
testq %rbx, %rbx
je 0x870e
movl 0xc(%rsp), %edx
leal -0x1(%rdx), %eax
movb (%r12,%rax), %al
cmpb $0x3b, %al
sete %cl
cmpb $0x2c, %al
sete %al
orb %cl, %al
movzbl %al, %eax
subl %eax, %edx
subl %r15d, %edx
movq %r12, %rdi
movl %r15d, %esi
callq 0x7db1
movq %rax, (%rbx)
jmp 0x870e
incl %ebx
movl %ebx, 0xc(%rsp)
movq 0x10(%rsp), %rcx
movl 0xc(%rsp), %eax
addl %eax, (%rcx)
jmp 0x856b
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
jmp 0x870e