// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/parsing_expressions.c
// Function: parse_expression
type_t parse_expression(char *line, int line_index, scope_t *scope, messages_t *messages) {
	type_t type;
	type_t return_type;
	function_t *function     = NULL;
	char       *expr         = NULL;
	char       *following    = NULL; //Used in parse_control "case"
	char       *tmp          = NULL;
	unsigned int start_index = 0;
	unsigned int end_index   = 0;
	unsigned int close_index = 0;
	int last_index           = -1; //Last index or quote for char and string literal
	unsigned char is_return  = 0;
	unsigned char is_for     = 0;
	int index                = 0;
	unsigned int sub_index   = 0;
	int length               = 0;
	int type_length;
	char c;

	type.name = strduplicate("NULL");
	type.is_pointer = 0;
	type.is_literal = 0;

	line   = str_remove_comments(line);
	length = strlen(line);
	tmp    = remove_parenthesis(line, length);
	if(tmp != NULL) {
		free(line);
		line   = tmp;
		length = strlen(tmp);
	}


	SKIP_WHITESPACES

	if(c == '(') {
		//Parenthesis -> cast

		index++;

		SKIP_WHITESPACES

		start_index = index;

		while((c = line[index]) != ')' && index < length) index++;

		if(c != ')') { //No closing parenthesis, syntax error
			if(tmp != NULL) free(tmp);
			else free(line);
			return type;
		}

		close_index = index;

		index++;

		//Check if something follows
		SKIP_WHITESPACES
		
		if(index >= length || is_whitespace(c) || c == ')') {
			if(tmp != NULL) free(tmp);
			else free(line);
			return type;
		}

		index = close_index;

		//Skip whitespaces backwards to find end of type
		while(is_whitespace(c = line[index]) && index > 0) { index--; }

		end_index = index;

		free(type.name);
		type_length     = end_index - start_index;
		type.name       = strsubstr(line, start_index, type_length);
		type.is_pointer = strcount(type.name, '*');
		sub_index       = strcountuntil(type.name, '*', 1, 1);

		//Remove stars
		type.name[type_length - sub_index] = '\0';

		//Check expression without cast
		expr = strsubstr(line, close_index + 1, length - close_index);
		parse_expression(expr, line_index, scope, messages);
		free(expr);


	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x18(%rbp)
movl %esi, -0x1c(%rbp)
movq %rdx, -0x28(%rbp)
movq %rcx, -0x30(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x0, -0x68(%rbp)
movl $0x0, -0x6c(%rbp)
movl $0xffffffff, -0x70(%rbp) # imm = 0xFFFFFFFF
movb $0x0, -0x71(%rbp)
movb $0x0, -0x72(%rbp)
movl $0x0, -0x78(%rbp)
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
leaq 0x4706(%rip), %rdi      # 0x148a0
callq 0xa550
movq %rax, -0x10(%rbp)
movb $0x0, -0x8(%rbp)
movb $0x0, -0x7(%rbp)
movq -0x18(%rbp), %rdi
callq 0xa2b0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2090
movl %eax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
movl -0x80(%rbp), %esi
callq 0xb090
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x101f8
movq -0x18(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x60(%rbp), %rdi
callq 0x2090
movl %eax, -0x80(%rbp)
jmp 0x101fa
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xd9(%rbp)
je 0x10232
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
testb $0x1, %al
jne 0x1023e
jmp 0x10249
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x101fa
movsbl -0x85(%rbp), %eax
cmpl $0x28, %eax
jne 0x104d9
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xda(%rbp)
je 0x1029a
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xda(%rbp)
movb -0xda(%rbp), %al
testb $0x1, %al
jne 0x102a6
jmp 0x102b1
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x10262
movl -0x78(%rbp), %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x29, %ecx
movb %al, -0xdb(%rbp)
je 0x102e7
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xdb(%rbp)
movb -0xdb(%rbp), %al
testb $0x1, %al
jne 0x102f3
jmp 0x102fe
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x102b7
movsbl -0x85(%rbp), %eax
cmpl $0x29, %eax
je 0x1032a
cmpq $0x0, -0x60(%rbp)
je 0x1031c
movq -0x60(%rbp), %rdi
callq 0x2030
jmp 0x10325
movq -0x18(%rbp), %rdi
callq 0x2030
jmp 0x108b4
movl -0x78(%rbp), %eax
movl %eax, -0x6c(%rbp)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xdc(%rbp)
je 0x10371
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xdc(%rbp)
movb -0xdc(%rbp), %al
testb $0x1, %al
jne 0x1037d
jmp 0x10388
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x10339
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
jge 0x103b0
movsbl -0x85(%rbp), %edi
callq 0xa7d0
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x103b0
movsbl -0x85(%rbp), %eax
cmpl $0x29, %eax
jne 0x103d0
cmpq $0x0, -0x60(%rbp)
je 0x103c2
movq -0x60(%rbp), %rdi
callq 0x2030
jmp 0x103cb
movq -0x18(%rbp), %rdi
callq 0x2030
jmp 0x108b4
movl -0x6c(%rbp), %eax
movl %eax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xdd(%rbp)
je 0x1040c
cmpl $0x0, -0x78(%rbp)
setg %al
movb %al, -0xdd(%rbp)
movb -0xdd(%rbp), %al
testb $0x1, %al
jne 0x10418
jmp 0x10423
movl -0x78(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x103d6
movl -0x78(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2030
movl -0x68(%rbp), %eax
subl -0x64(%rbp), %eax
movl %eax, -0x84(%rbp)
movq -0x18(%rbp), %rdi
movl -0x64(%rbp), %esi
movl -0x84(%rbp), %edx
callq 0xa5e0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2a, %esi
callq 0xa660
movb %al, -0x8(%rbp)
movq -0x10(%rbp), %rdi
movl $0x2a, %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xa6d0
movl %eax, -0x7c(%rbp)
movq -0x10(%rbp), %rax
movl -0x84(%rbp), %ecx
subl -0x7c(%rbp), %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x18(%rbp), %rdi
movl -0x6c(%rbp), %esi
addl $0x1, %esi
movl -0x80(%rbp), %edx
subl -0x6c(%rbp), %edx
callq 0xa5e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x10120
movq %rax, -0x98(%rbp)
movq %rdx, -0x90(%rbp)
movq -0x50(%rbp), %rdi
callq 0x2030
jmp 0x10897
movsbl -0x85(%rbp), %eax
cmpl $0x27, %eax
jne 0x105a9
movq -0x18(%rbp), %rdi
movl $0x27, %esi
callq 0xa940
movl %eax, -0x70(%rbp)
cmpl -0x78(%rbp), %eax
je 0x105a9
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xde(%rbp)
je 0x10544
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xde(%rbp)
movb -0xde(%rbp), %al
testb $0x1, %al
jne 0x10550
jmp 0x1055b
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x1050c
movsbl -0x85(%rbp), %eax
cmpl $0x3b, %eax
je 0x10583
movsbl -0x85(%rbp), %edi
callq 0xa7d0
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x10583
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
jl 0x105a4
movq -0x10(%rbp), %rdi
callq 0x2030
leaq 0x4355(%rip), %rdi      # 0x148e8
callq 0xa550
movq %rax, -0x10(%rbp)
movb $0x0, -0x8(%rbp)
movb $0x1, -0x7(%rbp)
jmp 0x10895
movsbl -0x85(%rbp), %eax
cmpl $0x22, %eax
jne 0x10679
movq -0x18(%rbp), %rdi
movl $0x22, %esi
callq 0xa940
movl %eax, -0x70(%rbp)
cmpl -0x78(%rbp), %eax
je 0x10679
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
movq -0x18(%rbp), %rax
movslq -0x78(%rbp), %rcx
movb (%rax,%rcx), %al
movb %al, -0x85(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0xdf(%rbp)
je 0x10614
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
setl %al
movb %al, -0xdf(%rbp)
movb -0xdf(%rbp), %al
testb $0x1, %al
jne 0x10620
jmp 0x1062b
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x105dc
movsbl -0x85(%rbp), %eax
cmpl $0x3b, %eax
je 0x10653
movsbl -0x85(%rbp), %edi
callq 0xa7d0
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x10653
movl -0x78(%rbp), %eax
cmpl -0x80(%rbp), %eax
jl 0x10674
movq -0x10(%rbp), %rdi
callq 0x2030
leaq 0x4285(%rip), %rdi      # 0x148e8
callq 0xa550
movq %rax, -0x10(%rbp)
movb $0x1, -0x8(%rbp)
movb $0x1, -0x7(%rbp)
jmp 0x10893
movq -0x18(%rbp), %rdi
movl -0x78(%rbp), %esi
movl -0x80(%rbp), %edx
leaq -0x58(%rbp), %rcx
leaq -0x71(%rbp), %r8
leaq -0x72(%rbp), %r9
callq 0x108d0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x107f9
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x10120
movq %rax, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x41ba(%rip), %rsi      # 0x148a0
callq 0x20f0
cmpl $0x0, %eax
jne 0x10728
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x8fe0
movq %rax, -0xb8(%rbp)
movq %rdx, -0xb0(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x38(%rbp)
movzbl -0x71(%rbp), %eax
cmpl $0x0, %eax
je 0x1075d
movq -0x40(%rbp), %rdi
leaq 0x4164(%rip), %rsi      # 0x148a0
callq 0x20f0
cmpl $0x0, %eax
je 0x1075d
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x10f10
jmp 0x10779
cmpb $0x0, -0x72(%rbp)
je 0x10777
movq -0x50(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x10fe0
jmp 0x10779
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x50(%rbp), %rdi
callq 0x2030
cmpq $0x0, -0x58(%rbp)
je 0x107f4
movq -0x58(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x10120
movq %rax, -0xc8(%rbp)
movq %rdx, -0xc0(%rbp)
movq -0x10(%rbp), %rdi
leaq 0x40e1(%rip), %rsi      # 0x148a0
callq 0x20f0
cmpl $0x0, %eax
jne 0x107eb
movq -0x58(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %rcx
callq 0x8fe0
movq %rax, -0xd8(%rbp)
movq %rdx, -0xd0(%rbp)
movq -0x58(%rbp), %rdi
callq 0x2030
jmp 0x10891
movsbl -0x85(%rbp), %edi
callq 0xae10
movsbl %al, %eax
cmpl $0x0, %eax
jne 0x10819
movsbl -0x85(%rbp), %eax
cmpl $0x2e, %eax
jne 0x1082e
movq -0x18(%rbp), %rdi
movl -0x80(%rbp), %esi
movl -0x78(%rbp), %edx
leaq -0x10(%rbp), %rcx
callq 0x11250
jmp 0x1088f
movq -0x30(%rbp), %rax
cmpq $0x0, (%rax)
je 0x1088d
movl -0x1c(%rbp), %edi
movq -0x18(%rbp), %rsi
movslq -0x78(%rbp), %rax
addq %rax, %rsi
callq 0xf860
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
je 0x10870
movq -0x48(%rbp), %rdi
movl -0x1c(%rbp), %esi
movq -0x28(%rbp), %rdx
movq -0x30(%rbp), %r8
leaq -0x10(%rbp), %rcx
callq 0x11320
jmp 0x1088b
movq -0x18(%rbp), %rdi
movl -0x78(%rbp), %esi
movl -0x1c(%rbp), %edx
movq -0x28(%rbp), %rcx
movq -0x30(%rbp), %r9
leaq -0x10(%rbp), %r8
callq 0x114f0
jmp 0x1088d
jmp 0x1088f
jmp 0x10891
jmp 0x10893
jmp 0x10895
jmp 0x10897
cmpq $0x0, -0x60(%rbp)
je 0x108a9
movq -0x60(%rbp), %rdi
callq 0x2030
jmp 0x108b2
movq -0x18(%rbp), %rdi
callq 0x2030
jmp 0x108b4
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rdx
addq $0xe0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)