// File: /workspace/github_c_makefile_star2_O2/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 $0x48, %rsp
movq %rcx, %r15
movq %rdx, 0x10(%rsp)
movq %rsi, %rbx
movq %rdi, %rbp
movl (%rsi), %r14d
leaq (%rdi,%r14), %r12
movq %r12, %rdi
callq 0x20b0
movq %rax, %r13
movq %rbp, %rdi
callq 0x20b0
cmpq %r14, %rax
jb 0x8072
movq %r14, 0x38(%rsp)
xorl %eax, %eax
callq 0x7e26
testq %rax, %rax
je 0x8072
movq %rax, %r14
cmpb $0x3b, (%r12)
jne 0x8087
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
movq %r14, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rbp, 0x30(%rsp)
movq %r15, 0x40(%rsp)
movq %rbx, (%rsp)
movq %r13, 0x28(%rsp)
movl %r13d, %eax
movq %rax, 0x18(%rsp)
xorl %ebx, %ebx
movsbl (%r12,%rbx), %edi
callq 0x7ace
leaq 0x1(%rbx), %rbp
testb %al, %al
je 0x80c0
cmpq 0x18(%rsp), %rbx
movq %rbp, %rbx
jb 0x80a4
leal -0x1(%rbp), %eax
movq %r14, 0x8(%rsp)
movl %eax, (%r14)
movq 0x30(%rsp), %rax
movq 0x38(%rsp), %rcx
leaq (%rcx,%rax), %r15
decq %r15
movsbl (%r15,%rbp), %r13d
cmpl $0x2a, %r13d
setne %r14b
movl %r13d, %edi
callq 0x7dfb
testb %al, %al
sete %al
leaq 0x1(%rbp), %rbx
testb %al, %r14b
jne 0x810c
decq %rbp
cmpq 0x18(%rsp), %rbp
movq %rbx, %rbp
jb 0x80dc
movzbl %r13b, %eax
leaq -0x2(%rbx), %rbp
movq 0x8(%rsp), %r14
movl %ebp, 0x4(%r14)
cmpl $0x2c, %eax
je 0x8190
cmpl $0x3b, %eax
je 0x8194
addq $-0x3, %rbx
movsbl (%r12,%rbp), %edi
callq 0x7ace
incl %ebx
testb %al, %al
je 0x8149
leaq 0x1(%rbp), %rax
cmpq 0x18(%rsp), %rbp
movq %rax, %rbp
jb 0x812b
movl 0x28(%rsp), %ebp
xorl %r13d, %r13d
movl %ebx, %eax
cmpl %ebx, %ebp
jbe 0x819d
cmpb $0x5b, (%r12,%rax)
jne 0x819d
incq %rax
movq %rax, %rbx
cmpb $0x5d, (%r12,%rax)
je 0x8173
leaq 0x1(%rbx), %rax
cmpq %rbx, %rbp
ja 0x8160
incl %ebx
movsbl (%r12,%rbx), %edi
callq 0x7ace
cmpl %ebx, %ebp
jbe 0x8187
testb %al, %al
jne 0x8173
incl %r13d
cmpl %ebx, %ebp
ja 0x8150
jmp 0x81a0
decl %ebx
movl %ebx, %ebp
movq (%rsp), %rax
jmp 0x8228
movq %rax, %rbx
movq 0x10(%rsp), %rax
addl %r13d, (%rax)
leal -0x1(%rbx), %eax
movl %eax, 0x24(%rsp)
leaq (%r12,%rbx), %rax
movq %rax, 0x10(%rsp)
xorl %r15d, %r15d
leaq (%rbx,%r15), %r13
movq 0x10(%rsp), %rax
movsbl (%rax,%r15), %edi
callq 0x7ace
incq %r15
testb %al, %al
je 0x81dc
cmpq 0x18(%rsp), %r13
jb 0x81bb
movl 0x24(%rsp), %eax
addq %r15, %rax
movq %rax, 0x10(%rsp)
cmpq 0x18(%rsp), %r13
jae 0x821f
movq 0x38(%rsp), %rcx
addq %rbx, %rcx
movq 0x30(%rsp), %rax
addq %rcx, %rax
movzbl -0x1(%r15,%rax), %eax
cmpl $0x2c, %eax
je 0x821f
cmpl $0x3d, %eax
je 0x822f
cmpl $0x3b, %eax
je 0x821f
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
movq (%rsp), %rax
movq 0x10(%rsp), %rbp
addl %ebp, (%rax)
jmp 0x8075
leal -0x2(%rbx), %r14d
addq %r15, %r14
incl %r14d
movsbl (%r12,%r14), %edi
callq 0x7ace
cmpl %r14d, %ebp
jbe 0x824c
testb %al, %al
jne 0x8236
movq %rbx, %rsi
addq %r15, %rsi
xorl %edx, %edx
pushq $0x1
popq %rcx
movl %r14d, %ebp
xorl %edi, %edi
xorl %eax, %eax
movq 0x28(%rsp), %r13
movl %ebp, %r8d
movb (%r12,%r8), %r8b
movzbl %r8b, %r9d
movl %edi, %r10d
orb %dl, %r10b
je 0x82aa
testb %dil, %dil
jne 0x82dc
testb %dl, %dl
je 0x82dc
movl %edx, %edi
xorb $0x7b, %dil
movl %r8d, %r9d
xorb $0x7b, %r9b
orb %dil, %r9b
je 0x82a4
movl %edx, %r9d
xorb $0x28, %r9b
movl %r8d, %r10d
xorb $0x28, %r10b
orb %r9b, %r10b
jne 0x8309
incl %eax
xorl %edi, %edi
jmp 0x82fc
xorl %edx, %edx
cmpl $0x22, %r9d
je 0x82d3
cmpl $0x28, %r9d
je 0x82d3
cmpl $0x7b, %r9d
je 0x82d3
cmpl $0x29, %r9d
je 0x83b1
cmpl $0x2c, %r9d
jne 0x82f0
jmp 0x835a
movl %r8d, %edx
xorl %edi, %edi
movl %ecx, %eax
jmp 0x82fc
cmpb $0x2c, %r8b
je 0x835a
testb %dl, %dl
jne 0x82fc
cmpl $0x29, %r9d
je 0x83b1
cmpl $0x7d, %r9d
je 0x83b1
xorl %edx, %edx
incl %ebp
cmpl %r13d, %ebp
jb 0x8263
jmp 0x835c
movl %r8d, %r10d
xorb $0x7d, %r10b
movl %r8d, %r11d
xorb $0x29, %r11b
orb %r11b, %r9b
sete %r9b
orb %r10b, %dil
je 0x834b
testb %r9b, %r9b
jne 0x834b
movl %edx, %edi
xorb $0x22, %dil
xorb $0x22, %r8b
orb %dil, %r8b
jne 0x82a6
leal -0x1(%rbp), %edx
xorl %edi, %edi
cmpb $0x5c, (%r12,%rdx)
jne 0x8351
movb $0x22, %dl
jmp 0x82fc
xorl %edi, %edi
decl %eax
jne 0x82fc
movb $0x1, %dil
xorl %edx, %edx
xorl %eax, %eax
jmp 0x82fc
incl %ebp
leal -0x1(%rbp), %ecx
movzbl %r14b, %edi
cmpl %edi, %ecx
je 0x83b1
testb %dl, %dl
movq 0x8(%rsp), %r14
jne 0x83b6
testl %eax, %eax
jne 0x83b6
movq 0x40(%rsp), %r13
testq %r13, %r13
je 0x8194
movl %ecx, %eax
movb (%r12,%rax), %al
cmpb $0x3b, %al
sete %cl
cmpb $0x2c, %al
sete %al
orb %cl, %al
movzbl %al, %eax
movl %ebp, %edx
subl %eax, %edx
subl %ebx, %edx
subl %r15d, %edx
movq %r12, %rdi
callq 0x79a6
movq %rax, (%r13)
jmp 0x8194
movq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x2030
xorl %r14d, %r14d
jmp 0x8194