// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/parsing_variables.c
// Function: parse_variable_value
static char parse_variable_value(char *line, size_t length, unsigned int *i) {
	unsigned int index              = *i;
	unsigned char in_content        = 0;
	unsigned char error             = 0;
	unsigned char expect_comma      = 0;
	unsigned int nested             = 0;
	unsigned char value_start_index = 0;
	char c;

	SKIP_WHITESPACES

	//Expect value
	//Until comma (if outside quotes and braces)
	value_start_index = index;
	do {
		c = line[index];
		if(!expect_comma && !in_content && (c == '"' || c == '{' || c == '(')) {
			in_content = c;
			nested = 1;
		} else if(!expect_comma && in_content) {

			if((in_content == '{' && c == '{') || (in_content == '(' && c == '(')) {
				nested++;
			} else if((in_content == '{' && c == '}') || (in_content == '(' && c == ')')) {
				nested--;
				if(nested <= 0) {
					in_content = 0;
					expect_comma = 1;
				}
			} else if(in_content == '"' && c == '"' && line[index - 1] != '\\') {
				in_content = 0;
				nested = 0;
				expect_comma = 1;
			}

		} else if(c == ',') {
			index++;
			break;
		} else if(!in_content && (c == ')' || c == '}')) {
			error = 1;
			break;
		}
		index++;
	} while(index < length);

	*i = index;
	return !error && !(in_content > 0 || nested > 0 || index - 1 == value_start_index); //Check for invalid syntax or missing value before comma
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movl (%rdx), %r12d
movl %r12d, %r13d
movsbl (%r15,%r13), %edi
callq 0x7ed1
incl %r12d
cmpq %r14, %r13
jae 0x8759
testb %al, %al
jne 0x8740
leal -0x1(%r12), %eax
xorl %ecx, %ecx
xorl %esi, %esi
xorl %edx, %edx
leal -0x1(%r12), %edi
movb (%r15,%rdi), %r8b
movzbl %r8b, %r9d
movl %esi, %r10d
orb %cl, %r10b
je 0x87ac
testb %sil, %sil
jne 0x87ca
testb %cl, %cl
je 0x87ca
movl %ecx, %esi
xorb $0x7b, %sil
movl %r8d, %edi
xorb $0x7b, %dil
orb %sil, %dil
je 0x87a6
movl %ecx, %edi
xorb $0x28, %dil
movl %r8d, %r9d
xorb $0x28, %r9b
orb %dil, %r9b
jne 0x87fb
incl %edx
xorl %esi, %esi
jmp 0x87ea
cmpl $0x22, %r9d
je 0x87be
cmpl $0x28, %r9d
je 0x87be
cmpl $0x7b, %r9d
jne 0x8779
movl %r8d, %ecx
xorl %esi, %esi
movl $0x1, %edx
jmp 0x87ea
cmpb $0x2c, %r8b
je 0x884f
testb %cl, %cl
jne 0x87ea
cmpl $0x29, %r9d
je 0x8882
cmpl $0x7d, %r9d
je 0x8882
xorl %ecx, %ecx
movl %r12d, %edi
incl %r12d
cmpq %r14, %rdi
jb 0x8764
jmp 0x884c
movl %r8d, %r9d
xorb $0x7d, %r9b
movl %r8d, %r10d
xorb $0x29, %r10b
orb %r10b, %dil
sete %dil
orb %r9b, %sil
je 0x883d
testb %dil, %dil
jne 0x883d
movl %ecx, %esi
xorb $0x22, %sil
xorb $0x22, %r8b
orb %sil, %r8b
jne 0x87a8
leal -0x2(%r12), %edi
xorl %esi, %esi
cmpb $0x5c, (%r15,%rdi)
je 0x87ea
jmp 0x8843
xorl %esi, %esi
decl %edx
jne 0x87ea
movb $0x1, %sil
xorl %ecx, %ecx
xorl %edx, %edx
jmp 0x87ea
decl %r12d
movb $0x1, %sil
movl %r12d, %edi
movl %edi, (%rbx)
testb %sil, %sil
je 0x8876
testb %cl, %cl
sete %cl
testl %edx, %edx
sete %dl
andb %cl, %dl
decl %edi
movzbl %al, %eax
cmpl %eax, %edi
setne %al
andb %dl, %al
jmp 0x8878
xorl %eax, %eax
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
xorl %ecx, %ecx
xorl %esi, %esi
jmp 0x8855