// File: /workspace/github_c_makefile_star2_O1/System-Glitch[P]ESGILinter-C/src/parsing_type.c
// Function: parse_type
match_t *parse_type(char *line) {
	unsigned int index = 0;
	int type_start = -1;
	int type_end = -1;

	size_t length = strlen(line);
	unsigned char c;
	match_t *match = NULL;

	if(length < 3) return NULL; //3 is the minimum size for a declaration

	SKIP_WHITESPACES

	if(strstr(line + index, "extern") == line + index) //Skip extern keyword
		index += 6;

	SKIP_WHITESPACES

	if(strstr(line + index, "static") == line + index) //Skip static keyword
		index += 6;

	SKIP_WHITESPACES

	if(strstr(line + index, "volatile") == line + index) //Skip volatile keyword
		index += 8;

	SKIP_WHITESPACES

	if(strstr(line + index, "const") == line + index) //Skip const keyword
		index += 5;

	SKIP_WHITESPACES

	if(strstr(line + index, "signed") == line + index) //Skip signed keyword
		index += 6;

	SKIP_WHITESPACES

	type_start = index;

	if(!parse_type_word(line, length, &index)) //No type word found, it's not a variable declaration
		return NULL;

	if(line[index] == ';') //If found semi-colon, it's not a variable declaration
		return NULL;

	//Find star	
	while(index < length) {
		SKIP_WHITESPACES

		//If found something else than star, end
		if(c != '*') {
			index--;
			break;
		} else if(c == ';') //If found semi-colon, it's not a variable declaration
			return NULL;
		else
			index++;
	}

	type_end = index;

	if(type_end != -1) {
		match = match_init();
		if(match != NULL) {
			match->index_start = type_start;
			match->index_end = type_end;
		}
	}

	return match;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0x20b0
cmpq $0x3, %rax
jb 0x700c
movq %rax, %r14
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %r12d
movsbl (%rbx,%r12), %edi
callq 0x7ed1
cmpq %r12, %r14
jbe 0x6d8f
testb %al, %al
jne 0x6d79
movq %r14, 0x8(%rsp)
leaq (%rbx,%r12), %rdi
leaq 0x7a39(%rip), %rsi      # 0xe7d8
movl $0x6, %edx
callq 0x2070
leal 0x6(%r12), %r15d
testl %eax, %eax
cmovnel %r12d, %r15d
decl %r15d
incl %r15d
movsbl (%rbx,%r15), %edi
callq 0x7ed1
cmpq %r15, 0x8(%rsp)
jbe 0x6dcf
testb %al, %al
jne 0x6db7
leaq (%rbx,%r15), %rdi
leaq 0x7a2d(%rip), %rsi      # 0xe807
movl $0x6, %edx
callq 0x2070
leal 0x6(%r15), %r12d
testl %eax, %eax
cmovnel %r15d, %r12d
decl %r12d
movq 0x8(%rsp), %r14
incl %r12d
movsbl (%rbx,%r12), %edi
callq 0x7ed1
cmpq %r12, %r14
jbe 0x6e0c
testb %al, %al
jne 0x6df6
leaq (%rbx,%r12), %rdi
leaq 0x7a13(%rip), %rsi      # 0xe82a
movl $0x8, %edx
callq 0x2070
leal 0x8(%r12), %r15d
testl %eax, %eax
cmovnel %r12d, %r15d
decl %r15d
incl %r15d
movsbl (%rbx,%r15), %edi
callq 0x7ed1
cmpq %r15, 0x8(%rsp)
jbe 0x6e47
testb %al, %al
jne 0x6e2f
leaq (%rbx,%r15), %rdi
leaq 0x7962(%rip), %rsi      # 0xe7b4
movl $0x5, %edx
callq 0x2070
leal 0x5(%r15), %r12d
testl %eax, %eax
cmovnel %r15d, %r12d
decl %r12d
movq 0x8(%rsp), %r15
incl %r12d
movsbl (%rbx,%r12), %edi
callq 0x7ed1
cmpq %r12, %r15
jbe 0x6e84
testb %al, %al
jne 0x6e6e
leaq (%rbx,%r12), %rdi
leaq 0x7902(%rip), %rsi      # 0xe791
movl $0x6, %edx
callq 0x2070
leal 0x6(%r12), %ebp
testl %eax, %eax
cmovnel %r12d, %ebp
movl %ebp, %r14d
movsbl (%rbx,%r14), %edi
callq 0x7ed1
incl %ebp
cmpq %r14, %r15
jbe 0x6ebc
testb %al, %al
jne 0x6ea4
decl %ebp
movb $0x1, %al
movl %ebp, 0x10(%rsp)
movl %ebp, %r13d
movl %eax, 0x14(%rsp)
leal -0x1(%r13), %ecx
movl %r13d, %ebp
movl %ecx, %r13d
movl %ebp, %r14d
movsbl (%rbx,%r14), %edi
callq 0x7ed1
incl %ebp
cmpq %r14, %r15
jbe 0x6ef1
leal 0x1(%r13), %ecx
testb %al, %al
jne 0x6ed2
decl %ebp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %r13d
movsbl (%rbx,%r13), %r15d
cmpl $0x2a, %r15d
sete %r14b
movl %r15d, %edi
callq 0x825c
testb %al, %al
setne %al
incl %r12d
cmpq %r13, 0x8(%rsp)
jbe 0x6f25
orb %al, %r14b
jne 0x6ef9
movq %rbx, %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x7db1
movq %rax, %r12
movq %rax, %rdi
callq 0x20b0
movq %rax, %r14
movq %r12, %rdi
movl $0x2a, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7e3f
movl %eax, %eax
subq %rax, %r14
movb $0x0, (%r12,%r14)
movq %r12, %rdi
callq 0x681a
movl %eax, %r14d
movq %r12, %rdi
callq 0x2030
testb %r14b, %r14b
je 0x6f8c
xorl %eax, %eax
cmpb $0x3b, %r15b
movq 0x8(%rsp), %r15
jne 0x6ec7
jmp 0x6f98
movl %ebp, %r13d
movq 0x8(%rsp), %r15
movl 0x14(%rsp), %eax
testb $0x1, %al
jne 0x700c
movl %r13d, %eax
cmpb $0x3b, (%rbx,%rax)
je 0x700c
cmpq %rax, %r15
jbe 0x6fe1
movl %r13d, %r15d
movl %r13d, %r14d
movb (%rbx,%r14), %bpl
movsbl %bpl, %edi
callq 0x7ed1
cmpq %r14, 0x8(%rsp)
jbe 0x6fcc
leal 0x1(%r15), %r13d
testb %al, %al
jne 0x6faa
cmpb $0x2a, %bpl
jne 0x6fe6
incl %r15d
movl %r15d, %r13d
cmpq %r15, 0x8(%rsp)
ja 0x6faa
jmp 0x6fe9
movl %r13d, %r15d
jmp 0x6fe9
decl %r15d
cmpl $-0x1, %r15d
je 0x700c
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x8287
testq %rax, %rax
je 0x700e
movl 0x10(%rsp), %ecx
movl %ecx, (%rax)
movl %r15d, 0x4(%rax)
movq %rax, %rbx
jmp 0x700e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq