// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/parsing_expressions.c
// Function: check_variable_expression
static void check_variable_expression(char *line, int index, int line_index, scope_t *scope, type_t *type, messages_t *messages) {
	field_t *variable_dec = NULL;
	char *variable_name   = NULL;
	char is_pointer       = 0;
	int negate_operator   = 0;
	int list_index        = -1;

	parse_variable_expression(line + index, &variable_name, &is_pointer, &negate_operator);
	if(variable_name != NULL && !is_keyword(variable_name)) {
		variable_dec = find_variable(scope, variable_name);
		if(scope == NULL || variable_dec == NULL || variable_dec->line > line_index)
			arraylist_add(messages->undeclared_variables, variable_name);
		else {
			if(messages->variables_list) {
				list_index = arraylist_index_of(messages->variables_list, variable_dec);
				if(list_index != -1)
					arraylist_remove(messages->variables_list, list_index);
			}

			if(negate_operator > 0) {
				free(type->name);
				type->name       = strduplicate("int");
				type->is_pointer = 0;
			} else {
				type->is_pointer = variable_dec->type.is_pointer + is_pointer;
				if(type->is_pointer < 0) { //More dereferencing than allowed
					type->is_pointer = 0;
					type->is_literal = 0;
				} else {
					free(type->name);
					type->name       = strduplicate(variable_dec->type.name);
					type->is_literal = 0;
				}
			}
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %r8, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movb $0x0, -0x39(%rbp)
movl $0x0, -0x40(%rbp)
movl $0xffffffff, -0x44(%rbp) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rdi
movslq -0xc(%rbp), %rax
addq %rax, %rdi
leaq -0x38(%rbp), %rsi
leaq -0x39(%rbp), %rdx
leaq -0x40(%rbp), %rcx
callq 0x11c60
cmpq $0x0, -0x38(%rbp)
je 0x11679
movq -0x38(%rbp), %rdi
callq 0x8510
cmpb $0x0, %al
jne 0x11679
movq -0x18(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x83d0
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x11593
cmpq $0x0, -0x30(%rbp)
je 0x11593
movq -0x30(%rbp), %rax
movl 0x20(%rax), %eax
cmpl -0x10(%rbp), %eax
jle 0x115a8
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0x8730
jmp 0x11677
movq -0x28(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x115e0
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0x89a0
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
je 0x115de
movq -0x28(%rbp), %rax
movq 0x40(%rax), %rdi
movslq -0x44(%rbp), %rsi
callq 0x88d0
jmp 0x115e0
cmpl $0x0, -0x40(%rbp)
jle 0x11612
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x2030
leaq 0x330c(%rip), %rdi      # 0x14905
callq 0xa550
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x8(%rax)
jmp 0x11675
movq -0x30(%rbp), %rax
movsbl 0x18(%rax), %eax
movsbl -0x39(%rbp), %ecx
addl %ecx, %eax
movb %al, %cl
movq -0x20(%rbp), %rax
movb %cl, 0x8(%rax)
movq -0x20(%rbp), %rax
movsbl 0x8(%rax), %eax
cmpl $0x0, %eax
jge 0x11648
movq -0x20(%rbp), %rax
movb $0x0, 0x8(%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x9(%rax)
jmp 0x11673
movq -0x20(%rbp), %rax
movq (%rax), %rdi
callq 0x2030
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xa550
movq %rax, %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movb $0x0, 0x9(%rax)
jmp 0x11675
jmp 0x11677
jmp 0x11679
addq $0x50, %rsp
popq %rbp
retq
nop