// File: /workspace/github_c_makefile_star2_O3/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, %r12
callq 0x20b0
cmpq $0x3, %rax
jb 0x709c
movq %rax, %rbx
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
incl %r15d
movsbl (%r12,%r15), %edi
callq 0x7f3a
cmpq %r15, %rbx
jbe 0x6e23
testb %al, %al
jne 0x6e0d
leaq (%r12,%r15), %rdi
leaq 0x79a7(%rip), %rsi      # 0xe7d5
movl $0x6, %edx
callq 0x2070
leal 0x6(%r15), %r14d
testl %eax, %eax
cmovnel %r15d, %r14d
decl %r14d
incl %r14d
movsbl (%r12,%r14), %edi
callq 0x7f3a
cmpq %r14, %rbx
jbe 0x6e5b
testb %al, %al
jne 0x6e45
leaq (%r12,%r14), %rdi
leaq 0x799e(%rip), %rsi      # 0xe804
movl $0x6, %edx
callq 0x2070
leal 0x6(%r14), %r15d
testl %eax, %eax
cmovnel %r14d, %r15d
decl %r15d
incl %r15d
movsbl (%r12,%r15), %edi
callq 0x7f3a
cmpq %r15, %rbx
jbe 0x6e93
testb %al, %al
jne 0x6e7d
leaq (%r12,%r15), %rdi
leaq 0x7989(%rip), %rsi      # 0xe827
movl $0x8, %edx
callq 0x2070
leal 0x8(%r15), %r14d
testl %eax, %eax
cmovnel %r15d, %r14d
decl %r14d
incl %r14d
movsbl (%r12,%r14), %edi
callq 0x7f3a
cmpq %r14, %rbx
jbe 0x6ecb
testb %al, %al
jne 0x6eb5
leaq (%r12,%r14), %rdi
leaq 0x78db(%rip), %rsi      # 0xe7b1
movl $0x5, %edx
callq 0x2070
leal 0x5(%r14), %r15d
testl %eax, %eax
cmovnel %r14d, %r15d
decl %r15d
incl %r15d
movsbl (%r12,%r15), %edi
callq 0x7f3a
cmpq %r15, %rbx
jbe 0x6f03
testb %al, %al
jne 0x6eed
leaq (%r12,%r15), %rdi
leaq 0x7880(%rip), %rsi      # 0xe78e
movl $0x6, %edx
callq 0x2070
leal 0x6(%r15), %ebp
testl %eax, %eax
cmovnel %r15d, %ebp
movq %rbx, (%rsp)
movl %ebp, %ebx
movsbl (%r12,%rbx), %edi
callq 0x7f3a
incl %ebp
cmpq %rbx, (%rsp)
movq (%rsp), %rbx
jbe 0x6f42
testb %al, %al
jne 0x6f26
decl %ebp
movb $0x1, %al
movl %ebp, 0x10(%rsp)
movl %ebp, %r13d
movq %r12, 0x8(%rsp)
movl %eax, 0x14(%rsp)
leal -0x1(%r13), %ecx
movl %r13d, %ebp
movl %ecx, %r13d
movl %ebp, %r14d
movsbl (%r12,%r14), %edi
callq 0x7f3a
incl %ebp
cmpq %r14, %rbx
jbe 0x6f7c
leal 0x1(%r13), %ecx
testb %al, %al
jne 0x6f5d
decl %ebp
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
incl %r13d
movq 0x8(%rsp), %rax
movsbl (%rax,%r13), %r15d
cmpl $0x2a, %r15d
sete %bl
movl %r15d, %edi
callq 0x82a7
testb %al, %al
setne %al
incl %r12d
cmpq %r13, (%rsp)
jbe 0x6fb2
orb %al, %bl
jne 0x6f84
movq 0x8(%rsp), %rdi
movl %ebp, %esi
movl %r12d, %edx
callq 0x7e1a
movq %rax, %r12
movq %rax, %rdi
callq 0x20b0
movq %rax, %rbx
movq %r12, %rdi
movl $0x2a, %esi
movl $0x1, %edx
movl $0x1, %ecx
callq 0x7ea8
movl %eax, %eax
subq %rax, %rbx
movb $0x0, (%r12,%rbx)
movq %r12, %rdi
callq 0x68d4
movl %eax, %ebx
movq %r12, %rdi
callq 0x2030
testb %bl, %bl
je 0x7020
xorl %eax, %eax
movl %r13d, %ebp
cmpb $0x3b, %r15b
movq 0x8(%rsp), %r12
movq (%rsp), %rbx
jne 0x6f52
jmp 0x7033
movq %r14, %r13
testb $0x1, 0x14(%rsp)
movq 0x8(%rsp), %r12
movq (%rsp), %rbx
jne 0x709c
cmpb $0x3b, (%r12,%r13)
je 0x709c
cmpq %r13, %rbx
jbe 0x707b
movl %ebp, %r14d
movl %ebp, %ebx
movb (%r12,%rbx), %r15b
movsbl %r15b, %edi
callq 0x7f3a
leal 0x1(%r14), %ebp
cmpq %rbx, (%rsp)
movq (%rsp), %rcx
jbe 0x7063
testb %al, %al
jne 0x703f
cmpb $0x2a, %r15b
jne 0x7075
movl %ebp, %eax
cmpq %rax, %rcx
ja 0x703f
incl %r14d
jmp 0x7078
decl %r14d
movl %r14d, %ebp
cmpl $-0x1, %ebp
je 0x709c
xorl %ebx, %ebx
xorl %eax, %eax
callq 0x82d2
testq %rax, %rax
je 0x709e
movl 0x10(%rsp), %ecx
movl %ecx, (%rax)
movl %ebp, 0x4(%rax)
movq %rax, %rbx
jmp 0x709e
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq