// File: /workspace/github_c_makefile_star2_O0/System-Glitch[P]ESGILinter-C/src/parsing_functions.c
// Function: parse_function_parameters
static arraylist_t *parse_function_parameters(char *line, unsigned char is_prototype, int line_index) {
	arraylist_t *list            = arraylist_init(5);
	unsigned int start_index     = 0;
	unsigned int index           = 0;
	unsigned int sub_index       = 0;
	unsigned int length          = strlen(line);
	unsigned int type_length     = 0;
	unsigned int star_count_type = 0;
	unsigned int star_count_name = 0;
	unsigned int array_count     = 0;
	unsigned int type_sub_index;
	unsigned char c;
	char *tmp           = NULL;
	char *tmp_name      = NULL;
	char *type          = NULL;
	char *name          = NULL;
	match_t *match_type = NULL;
	match_t *match_name = NULL;
	field_t *field      = NULL;

	do {
		SKIP_WHITESPACES

		start_index = index;

		//Until comma
		while((c = line[index]) != ',' && index < length) {
			index++;
		}

		tmp = strsubstr(line, start_index, index - start_index);
		if(strlen(tmp) == 0) {
			free(tmp);
			break;
		}

		//Parse type
		match_type = parse_type(tmp);
		if(match_type == NULL) {
			free(tmp);
			field_list_free(list);
			return NULL;
		}

		type = substr_match(tmp, *match_type);
		free(match_type);
		type_length     = strlen(type);
		star_count_type = strcount(type, '*');
		type_sub_index  = strcountuntil(type, '*', 1, 1);

		//Remove stars
		type[type_length - type_sub_index] = '\0';

		//If no name and not prototype, invalid syntax
		match_name = parse_variable_name(tmp + type_length, &sub_index, &array_count, NULL);
		if(match_name != NULL) {
			tmp_name = substr_match(tmp + type_length, *match_name);
			free(match_name);

			if(strlen(tmp_name) == 0 && !is_prototype) { //Parameter names compulsory when not prototype
				free(tmp);
				field_list_free(list);
				return NULL;
			}

			star_count_name = strcount(tmp_name, '*');
			sub_index       = strcountuntil(tmp_name, '*', 0, 1);

			//Remove stars
			name = strsubstr(tmp_name, sub_index, strlen(tmp_name) - star_count_name);
			free(tmp_name);
		} else if(!is_prototype) { //Parameter names compulsory when not prototype
			free(tmp);
			field_list_free(list);
			return NULL;
		}

		field = field_init(name, type, star_count_type + star_count_name + array_count, line_index);
		field->is_param = 1;
		arraylist_add(list, field);

		free(tmp);

		index++;
		
	} while(index < length);

	return list;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %sil, %al
movq %rdi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movl %edx, -0x18(%rbp)
movl $0x5, %edi
callq 0x8580
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x2090
movl %eax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0x0, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq $0x0, -0x70(%rbp)
movq $0x0, -0x78(%rbp)
movq $0x0, -0x80(%rbp)
jmp 0xf57d
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x45(%rbp)
movsbl %al, %edi
callq 0xa7d0
movsbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x81(%rbp)
je 0xf5b1
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
setb %al
movb %al, -0x81(%rbp)
movb -0x81(%rbp), %al
testb $0x1, %al
jne 0xf5bd
jmp 0xf5c8
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xf57d
movl -0x28(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movl -0x28(%rbp), %ecx
movb (%rax,%rcx), %al
movb %al, -0x45(%rbp)
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x2c, %ecx
movb %al, -0x82(%rbp)
je 0xf5fa
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
setb %al
movb %al, -0x82(%rbp)
movb -0x82(%rbp), %al
testb $0x1, %al
jne 0xf606
jmp 0xf611
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xf5ce
movq -0x10(%rbp), %rdi
movl -0x24(%rbp), %esi
movl -0x28(%rbp), %edx
subl -0x24(%rbp), %edx
callq 0xa5e0
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x2090
cmpq $0x0, %rax
jne 0xf644
movq -0x50(%rbp), %rdi
callq 0x2030
jmp 0xf840
movq -0x50(%rbp), %rdi
callq 0x8a90
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0xf677
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x20(%rbp), %rdi
callq 0x81d0
movq $0x0, -0x8(%rbp)
jmp 0xf848
movq -0x50(%rbp), %rdi
movq -0x70(%rbp), %rax
movq (%rax), %rsi
callq 0xac10
movq %rax, -0x60(%rbp)
movq -0x70(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rdi
callq 0x2090
movl %eax, -0x34(%rbp)
movq -0x60(%rbp), %rdi
movl $0x2a, %esi
callq 0xa660
movl %eax, -0x38(%rbp)
movq -0x60(%rbp), %rdi
movl $0x2a, %esi
movl $0x1, %ecx
movl %ecx, %edx
callq 0xa6d0
movl %eax, -0x44(%rbp)
movq -0x60(%rbp), %rax
movl -0x34(%rbp), %ecx
subl -0x44(%rbp), %ecx
movl %ecx, %ecx
movb $0x0, (%rax,%rcx)
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %eax
addq %rax, %rdi
leaq -0x2c(%rbp), %rsi
leaq -0x40(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0xb2e0
movq %rax, -0x78(%rbp)
cmpq $0x0, -0x78(%rbp)
je 0xf7c9
movq -0x50(%rbp), %rdi
movl -0x34(%rbp), %eax
addq %rax, %rdi
movq -0x78(%rbp), %rax
movq (%rax), %rsi
callq 0xac10
movq %rax, -0x58(%rbp)
movq -0x78(%rbp), %rdi
callq 0x2030
movq -0x58(%rbp), %rdi
callq 0x2090
cmpq $0x0, %rax
jne 0xf75a
cmpb $0x0, -0x11(%rbp)
jne 0xf75a
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x20(%rbp), %rdi
callq 0x81d0
movq $0x0, -0x8(%rbp)
jmp 0xf848
movq -0x58(%rbp), %rdi
movl $0x2a, %esi
callq 0xa660
movl %eax, -0x3c(%rbp)
movq -0x58(%rbp), %rdi
movl $0x2a, %esi
xorl %edx, %edx
movl $0x1, %ecx
callq 0xa6d0
movl %eax, -0x2c(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0x90(%rbp)
movl -0x2c(%rbp), %eax
movl %eax, -0x88(%rbp)
movq -0x58(%rbp), %rdi
callq 0x2090
movq -0x90(%rbp), %rdi
movl -0x88(%rbp), %esi
movl -0x3c(%rbp), %ecx
subq %rcx, %rax
movl %eax, %edx
callq 0xa5e0
movq %rax, -0x68(%rbp)
movq -0x58(%rbp), %rdi
callq 0x2030
jmp 0xf7ed
cmpb $0x0, -0x11(%rbp)
jne 0xf7eb
movq -0x50(%rbp), %rdi
callq 0x2030
movq -0x20(%rbp), %rdi
callq 0x81d0
movq $0x0, -0x8(%rbp)
jmp 0xf848
jmp 0xf7ed
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
movl -0x38(%rbp), %eax
addl -0x3c(%rbp), %eax
addl -0x40(%rbp), %eax
movl -0x18(%rbp), %ecx
movsbl %al, %edx
callq 0x7600
movq %rax, -0x80(%rbp)
movq -0x80(%rbp), %rax
movb $0x1, 0x24(%rax)
movq -0x20(%rbp), %rdi
movq -0x80(%rbp), %rsi
callq 0x8730
movq -0x50(%rbp), %rdi
callq 0x2030
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jb 0xf57b
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)