// File: /workspace/github_c_makefile_star2_O3/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 0x7f3a
incl %r12d
cmpq %r14, %r13
jae 0x87c1
testb %al, %al
jne 0x87a8
leal -0x1(%r12), %eax
xorl %ecx, %ecx
xorl %edi, %edi
xorl %esi, %esi
movl %esi, %edx
leal -0x1(%r12), %r10d
movb (%r15,%r10), %r9b
movzbl %r9b, %r11d
movl %edi, %esi
orb %cl, %sil
je 0x8819
testb %dil, %dil
jne 0x8843
testb %cl, %cl
je 0x8843
movl %ecx, %esi
xorb $0x7b, %sil
movl %r9d, %edi
xorb $0x7b, %dil
orb %sil, %dil
je 0x880f
movl %ecx, %edi
xorb $0x28, %dil
movl %r9d, %r8d
xorb $0x28, %r8b
orb %dil, %r8b
jne 0x8876
incl %edx
xorl %r8d, %r8d
jmp 0x88ce
movl $0x1, %esi
xorl %r8d, %r8d
cmpl $0x28, %r11d
jg 0x885c
movl %r9d, %ecx
cmpl $0x22, %r11d
je 0x88d0
cmpl $0x28, %r11d
je 0x88d0
jmp 0x88c9
cmpb $0x2c, %r9b
je 0x890b
testb %cl, %cl
jne 0x88cb
cmpl $0x29, %r11d
jne 0x886b
jmp 0x8902
cmpl $0x7a, %r11d
jle 0x88bd
movl %r9d, %ecx
cmpl $0x7b, %r11d
je 0x88d0
cmpl $0x7d, %r11d
jne 0x88c9
jmp 0x8902
movl %r9d, %r8d
xorb $0x7d, %r8b
movl %r9d, %r10d
xorb $0x29, %r10b
orb %r10b, %dil
sete %dil
orb %r8b, %sil
je 0x88e4
testb %dil, %dil
jne 0x88e4
movl %ecx, %esi
xorb $0x22, %sil
xorb $0x22, %r9b
orb %sil, %r9b
jne 0x8811
leal -0x2(%r12), %ecx
xorl %esi, %esi
cmpb $0x5c, (%r15,%rcx)
jne 0x88f6
movb $0x22, %cl
jmp 0x8811
cmpl $0x29, %r11d
je 0x8902
cmpl $0x2c, %r11d
je 0x8909
xorl %ecx, %ecx
movl %edi, %r8d
movl %edx, %esi
movl %r12d, %edx
incl %r12d
movl %r8d, %edi
cmpq %r14, %rdx
jb 0x87cc
jmp 0x88fd
xorl %r8d, %r8d
decl %edx
movl %edx, %esi
jne 0x88d0
movb $0x1, %r8b
xorl %ecx, %ecx
xorl %esi, %esi
jmp 0x88d0
movb $0x1, %r8b
xorl %ecx, %ecx
jmp 0x88d0
decl %r12d
jmp 0x890d
movl %r10d, (%rbx)
xorl %eax, %eax
jmp 0x892a
xorl %ecx, %ecx
movl %edx, %esi
movl %r12d, (%rbx)
testb %cl, %cl
sete %cl
testl %esi, %esi
sete %dl
andb %cl, %dl
decl %r12d
movzbl %al, %eax
cmpl %eax, %r12d
setne %al
andb %dl, %al
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq